548 else |
548 else |
549 XML.Decode.list(XML.Decode.properties)(YXML.parse_body(bs.uncompress().text)). |
549 XML.Decode.list(XML.Decode.properties)(YXML.parse_body(bs.uncompress().text)). |
550 map(xml_cache.props(_)) |
550 map(xml_cache.props(_)) |
551 } |
551 } |
552 |
552 |
553 def read_string(db: SQLite.Database, table: SQL.Table, column: SQL.Column): String = |
553 def read_string(db: SQL.Database, table: SQL.Table, column: SQL.Column): String = |
554 using(db.select_statement(table, List(column)))(stmt => |
554 using(db.select_statement(table, List(column)))(stmt => |
555 { |
555 { |
556 val rs = stmt.executeQuery |
556 val rs = stmt.executeQuery |
557 if (!rs.next) "" else db.string(rs, column.name) |
557 if (!rs.next) "" else db.string(rs, column.name) |
558 }) |
558 }) |
559 |
559 |
560 def read_bytes(db: SQLite.Database, table: SQL.Table, column: SQL.Column): Bytes = |
560 def read_bytes(db: SQL.Database, table: SQL.Table, column: SQL.Column): Bytes = |
561 using(db.select_statement(table, List(column)))(stmt => |
561 using(db.select_statement(table, List(column)))(stmt => |
562 { |
562 { |
563 val rs = stmt.executeQuery |
563 val rs = stmt.executeQuery |
564 if (!rs.next) Bytes.empty else db.bytes(rs, column.name) |
564 if (!rs.next) Bytes.empty else db.bytes(rs, column.name) |
565 }) |
565 }) |
566 |
566 |
567 def read_properties(db: SQLite.Database, table: SQL.Table, column: SQL.Column) |
567 def read_properties(db: SQL.Database, table: SQL.Table, column: SQL.Column) |
568 : List[Properties.T] = uncompress_properties(read_bytes(db, table, column)) |
568 : List[Properties.T] = uncompress_properties(read_bytes(db, table, column)) |
569 |
569 |
570 |
570 |
571 /* output */ |
571 /* output */ |
572 |
572 |
629 val return_code = SQL.Column.int("return_code") |
629 val return_code = SQL.Column.int("return_code") |
630 val build_columns = List(sources, input_heaps, output_heap, return_code) |
630 val build_columns = List(sources, input_heaps, output_heap, return_code) |
631 |
631 |
632 val table = SQL.Table("isabelle_session_info", build_log_columns ::: build_columns) |
632 val table = SQL.Table("isabelle_session_info", build_log_columns ::: build_columns) |
633 |
633 |
634 def write(store: Store, db: SQLite.Database, |
634 def write(store: Store, db: SQL.Database, |
635 build_log: Build_Log.Session_Info, build: Build.Session_Info) |
635 build_log: Build_Log.Session_Info, build: Build.Session_Info) |
636 { |
636 { |
637 db.transaction { |
637 db.transaction { |
638 db.drop_table(table) |
638 db.drop_table(table) |
639 db.create_table(table) |
639 db.create_table(table) |
651 stmt.execute() |
651 stmt.execute() |
652 }) |
652 }) |
653 } |
653 } |
654 } |
654 } |
655 |
655 |
656 def read_session_timing(store: Store, db: SQLite.Database): Properties.T = |
656 def read_session_timing(store: Store, db: SQL.Database): Properties.T = |
657 store.decode_properties(store.read_bytes(db, table, session_timing)) |
657 store.decode_properties(store.read_bytes(db, table, session_timing)) |
658 |
658 |
659 def read_command_timings(store: Store, db: SQLite.Database): List[Properties.T] = |
659 def read_command_timings(store: Store, db: SQL.Database): List[Properties.T] = |
660 store.read_properties(db, table, command_timings) |
660 store.read_properties(db, table, command_timings) |
661 |
661 |
662 def read_ml_statistics(store: Store, db: SQLite.Database): List[Properties.T] = |
662 def read_ml_statistics(store: Store, db: SQL.Database): List[Properties.T] = |
663 store.read_properties(db, table, ml_statistics) |
663 store.read_properties(db, table, ml_statistics) |
664 |
664 |
665 def read_task_statistics(store: Store, db: SQLite.Database): List[Properties.T] = |
665 def read_task_statistics(store: Store, db: SQL.Database): List[Properties.T] = |
666 store.read_properties(db, table, task_statistics) |
666 store.read_properties(db, table, task_statistics) |
667 |
667 |
668 def read_build_log(store: Store, db: SQLite.Database, |
668 def read_build_log(store: Store, db: SQL.Database, |
669 default_name: String = "", |
669 default_name: String = "", |
670 command_timings: Boolean = false, |
670 command_timings: Boolean = false, |
671 ml_statistics: Boolean = false, |
671 ml_statistics: Boolean = false, |
672 task_statistics: Boolean = false): Build_Log.Session_Info = |
672 task_statistics: Boolean = false): Build_Log.Session_Info = |
673 { |
673 { |
681 command_timings = if (command_timings) read_command_timings(store, db) else Nil, |
681 command_timings = if (command_timings) read_command_timings(store, db) else Nil, |
682 ml_statistics = if (ml_statistics) read_ml_statistics(store, db) else Nil, |
682 ml_statistics = if (ml_statistics) read_ml_statistics(store, db) else Nil, |
683 task_statistics = if (task_statistics) read_task_statistics(store, db) else Nil) |
683 task_statistics = if (task_statistics) read_task_statistics(store, db) else Nil) |
684 } |
684 } |
685 |
685 |
686 def read_build(store: Store, db: SQLite.Database): Option[Build.Session_Info] = |
686 def read_build(store: Store, db: SQL.Database): Option[Build.Session_Info] = |
687 using(db.select_statement(table, table.columns))(stmt => |
687 using(db.select_statement(table, table.columns))(stmt => |
688 { |
688 { |
689 val rs = stmt.executeQuery |
689 val rs = stmt.executeQuery |
690 if (!rs.next) None |
690 if (!rs.next) None |
691 else { |
691 else { |