242 yield entry |
242 yield entry |
243 |
243 |
244 |
244 |
245 /* properties (YXML) */ |
245 /* properties (YXML) */ |
246 |
246 |
247 val xml_cache: XML.Cache = XML.Cache.make() |
247 val cache: XML.Cache = XML.Cache.make() |
248 |
248 |
249 def parse_props(text: String): Properties.T = |
249 def parse_props(text: String): Properties.T = |
250 try { xml_cache.props(XML.Decode.properties(YXML.parse_body(text))) } |
250 try { cache.props(XML.Decode.properties(YXML.parse_body(text))) } |
251 catch { case _: XML.Error => log_file.err("malformed properties") } |
251 catch { case _: XML.Error => log_file.err("malformed properties") } |
252 |
252 |
253 def filter_props(marker: Protocol_Message.Marker): List[Properties.T] = |
253 def filter_props(marker: Protocol_Message.Marker): List[Properties.T] = |
254 for (text <- filter(marker) if YXML.detect(text)) yield parse_props(text) |
254 for (text <- filter(marker) if YXML.detect(text)) yield parse_props(text) |
255 |
255 |
848 } |
848 } |
849 |
849 |
850 |
850 |
851 /* database access */ |
851 /* database access */ |
852 |
852 |
853 def store(options: Options, |
853 def store(options: Options, cache: XML.Cache = XML.Cache.make()): Store = |
854 xml_cache: XML.Cache = XML.Cache.make(), |
854 new Store(options, cache) |
855 xz_cache: XZ.Cache = XZ.Cache.make()): Store = |
855 |
856 new Store(options, xml_cache, xz_cache) |
856 class Store private[Build_Log](options: Options, val cache: XML.Cache) |
857 |
|
858 class Store private[Build_Log]( |
|
859 options: Options, |
|
860 val xml_cache: XML.Cache, |
|
861 val xz_cache: XZ.Cache) |
|
862 { |
857 { |
863 def open_database( |
858 def open_database( |
864 user: String = options.string("build_log_database_user"), |
859 user: String = options.string("build_log_database_user"), |
865 password: String = options.string("build_log_database_password"), |
860 password: String = options.string("build_log_database_password"), |
866 database: String = options.string("build_log_database_name"), |
861 database: String = options.string("build_log_database_name"), |
994 stmt.long(11) = session.ml_timing.cpu.proper_ms |
989 stmt.long(11) = session.ml_timing.cpu.proper_ms |
995 stmt.long(12) = session.ml_timing.gc.proper_ms |
990 stmt.long(12) = session.ml_timing.gc.proper_ms |
996 stmt.double(13) = session.ml_timing.factor |
991 stmt.double(13) = session.ml_timing.factor |
997 stmt.long(14) = session.heap_size |
992 stmt.long(14) = session.heap_size |
998 stmt.string(15) = session.status.map(_.toString) |
993 stmt.string(15) = session.status.map(_.toString) |
999 stmt.bytes(16) = compress_errors(session.errors, cache = xz_cache) |
994 stmt.bytes(16) = compress_errors(session.errors, cache = cache.xz) |
1000 stmt.string(17) = session.sources |
995 stmt.string(17) = session.sources |
1001 stmt.execute() |
996 stmt.execute() |
1002 } |
997 } |
1003 }) |
998 }) |
1004 } |
999 } |
1032 val table = Data.ml_statistics_table |
1027 val table = Data.ml_statistics_table |
1033 db.using_statement(db.insert_permissive(table))(stmt => |
1028 db.using_statement(db.insert_permissive(table))(stmt => |
1034 { |
1029 { |
1035 val ml_stats: List[(String, Option[Bytes])] = |
1030 val ml_stats: List[(String, Option[Bytes])] = |
1036 Par_List.map[(String, Session_Entry), (String, Option[Bytes])]( |
1031 Par_List.map[(String, Session_Entry), (String, Option[Bytes])]( |
1037 { case (a, b) => (a, Properties.compress(b.ml_statistics, cache = xz_cache).proper) }, |
1032 { case (a, b) => (a, Properties.compress(b.ml_statistics, cache = cache.xz).proper) }, |
1038 build_info.sessions.iterator.filter(p => p._2.ml_statistics.nonEmpty).toList) |
1033 build_info.sessions.iterator.filter(p => p._2.ml_statistics.nonEmpty).toList) |
1039 val entries = if (ml_stats.nonEmpty) ml_stats else List("" -> None) |
1034 val entries = if (ml_stats.nonEmpty) ml_stats else List("" -> None) |
1040 for ((session_name, ml_statistics) <- entries) { |
1035 for ((session_name, ml_statistics) <- entries) { |
1041 stmt.string(1) = log_name |
1036 stmt.string(1) = log_name |
1042 stmt.string(2) = session_name |
1037 stmt.string(2) = session_name |
1161 ml_timing = |
1156 ml_timing = |
1162 res.timing(Data.ml_timing_elapsed, Data.ml_timing_cpu, Data.ml_timing_gc), |
1157 res.timing(Data.ml_timing_elapsed, Data.ml_timing_cpu, Data.ml_timing_gc), |
1163 sources = res.get_string(Data.sources), |
1158 sources = res.get_string(Data.sources), |
1164 heap_size = res.get_long(Data.heap_size), |
1159 heap_size = res.get_long(Data.heap_size), |
1165 status = res.get_string(Data.status).map(Session_Status.withName), |
1160 status = res.get_string(Data.status).map(Session_Status.withName), |
1166 errors = uncompress_errors(res.bytes(Data.errors), cache = xz_cache), |
1161 errors = uncompress_errors(res.bytes(Data.errors), cache = cache.xz), |
1167 ml_statistics = |
1162 ml_statistics = |
1168 if (ml_statistics) { |
1163 if (ml_statistics) { |
1169 Properties.uncompress( |
1164 Properties.uncompress(res.bytes(Data.ml_statistics), cache = cache) |
1170 res.bytes(Data.ml_statistics), cache = xz_cache, xml_cache = xml_cache) |
|
1171 } |
1165 } |
1172 else Nil) |
1166 else Nil) |
1173 session_name -> session_entry |
1167 session_name -> session_entry |
1174 }).toMap |
1168 }).toMap |
1175 }) |
1169 }) |