461 val status = SQL.Column.string("status") |
461 val status = SQL.Column.string("status") |
462 |
462 |
463 val table = SQL.Table("isabelle_build_log_build_info", |
463 val table = SQL.Table("isabelle_build_log_build_info", |
464 List(Meta_Info.log_name, session_name, chapter, groups, threads, timing_elapsed, timing_cpu, |
464 List(Meta_Info.log_name, session_name, chapter, groups, threads, timing_elapsed, timing_cpu, |
465 timing_gc, ml_timing_elapsed, ml_timing_cpu, ml_timing_gc, ml_statistics, heap_size, status)) |
465 timing_gc, ml_timing_elapsed, ml_timing_cpu, ml_timing_gc, ml_statistics, heap_size, status)) |
|
466 |
|
467 val table0 = table.copy(columns = table.columns.take(2)) |
466 } |
468 } |
467 |
469 |
468 sealed case class Build_Info(sessions: Map[String, Session_Entry]) |
470 sealed case class Build_Info(sessions: Map[String, Session_Entry]) |
469 { |
471 { |
470 def session(name: String): Session_Entry = sessions(name) |
472 def session(name: String): Session_Entry = sessions(name) |
721 val log_file = Log_File(file) |
723 val log_file = Log_File(file) |
722 val build_info = log_file.parse_build_info() |
724 val build_info = log_file.parse_build_info() |
723 |
725 |
724 using(db.delete(Build_Info.table, Meta_Info.log_name.sql_where_equal(log_file.name)))( |
726 using(db.delete(Build_Info.table, Meta_Info.log_name.sql_where_equal(log_file.name)))( |
725 _.execute) |
727 _.execute) |
726 using(db.insert(Build_Info.table))(stmt => |
728 if (build_info.sessions.isEmpty) { |
727 { |
729 using(db.insert(Build_Info.table0))(stmt => |
728 for ((session_name, session) <- build_info.sessions.iterator) { |
730 { |
729 db.set_string(stmt, 1, log_file.name) |
731 db.set_string(stmt, 1, log_file.name) |
730 db.set_string(stmt, 2, session_name) |
732 db.set_string(stmt, 2, "") |
731 db.set_string(stmt, 3, session.chapter) |
|
732 db.set_string(stmt, 4, cat_lines(session.groups)) |
|
733 db.set_int(stmt, 5, session.threads) |
|
734 db.set_long(stmt, 6, session.timing.elapsed.proper_ms) |
|
735 db.set_long(stmt, 7, session.timing.cpu.proper_ms) |
|
736 db.set_long(stmt, 8, session.timing.gc.proper_ms) |
|
737 db.set_long(stmt, 9, session.ml_timing.elapsed.proper_ms) |
|
738 db.set_long(stmt, 10, session.ml_timing.cpu.proper_ms) |
|
739 db.set_long(stmt, 11, session.ml_timing.gc.proper_ms) |
|
740 db.set_bytes(stmt, 12, compress_properties(session.ml_statistics)) |
|
741 db.set_long(stmt, 13, session.heap_size) |
|
742 db.set_string(stmt, 14, session.status.toString) |
|
743 stmt.execute() |
733 stmt.execute() |
744 } |
734 }) |
745 }) |
735 } |
|
736 else { |
|
737 using(db.insert(Build_Info.table))(stmt => |
|
738 { |
|
739 for ((session_name, session) <- build_info.sessions.iterator) { |
|
740 db.set_string(stmt, 1, log_file.name) |
|
741 db.set_string(stmt, 2, session_name) |
|
742 db.set_string(stmt, 3, session.chapter) |
|
743 db.set_string(stmt, 4, cat_lines(session.groups)) |
|
744 db.set_int(stmt, 5, session.threads) |
|
745 db.set_long(stmt, 6, session.timing.elapsed.proper_ms) |
|
746 db.set_long(stmt, 7, session.timing.cpu.proper_ms) |
|
747 db.set_long(stmt, 8, session.timing.gc.proper_ms) |
|
748 db.set_long(stmt, 9, session.ml_timing.elapsed.proper_ms) |
|
749 db.set_long(stmt, 10, session.ml_timing.cpu.proper_ms) |
|
750 db.set_long(stmt, 11, session.ml_timing.gc.proper_ms) |
|
751 db.set_bytes(stmt, 12, compress_properties(session.ml_statistics)) |
|
752 db.set_long(stmt, 13, session.heap_size) |
|
753 db.set_string(stmt, 14, session.status.toString) |
|
754 stmt.execute() |
|
755 } |
|
756 }) |
|
757 } |
746 } |
758 } |
747 } |
759 } |
748 } |
760 } |
749 } |
761 } |
750 |
762 |
751 def read_build_info( |
763 def read_build_info( |
752 db: SQL.Database, log_name: String, session_names: List[String] = Nil): Build_Info = |
764 db: SQL.Database, log_name: String, session_names: List[String] = Nil): Build_Info = |
753 { |
765 { |
754 val where_log_name = Meta_Info.log_name.sql_where_equal(log_name) |
766 val where0 = |
|
767 Meta_Info.log_name.sql_where_equal(log_name) + " AND " |
|
768 Build_Info.session_name.sql_name + " <> ''" |
755 val where = |
769 val where = |
756 if (session_names.isEmpty) where_log_name |
770 if (session_names.isEmpty) where0 |
757 else |
771 else |
758 where_log_name + " AND " + |
772 where0 + " AND " + |
759 session_names.map(a => Build_Info.session_name.sql_name + " = " + SQL.quote_string(a)). |
773 session_names.map(a => Build_Info.session_name.sql_name + " = " + SQL.quote_string(a)). |
760 mkString("(", " OR ", ")") |
774 mkString("(", " OR ", ")") |
761 val sessions = |
775 val sessions = |
762 using(db.select(Build_Info.table, Build_Info.table.columns.tail, where))(stmt => |
776 using(db.select(Build_Info.table, Build_Info.table.columns.tail, where))(stmt => |
763 { |
777 { |