Skip to content

Commit 852eeb9

Browse files
authored
add reverse converter (#224)
* add reverse converter flatgraph->odb * add verbose option to command-line tool to dump the manifest * remove legacyId property that the odb->flatgraph converter inserted * fix converter bugs in odb->flatgraph for scanned cpgs (containedNodes)
1 parent 176e151 commit 852eeb9

File tree

2 files changed

+365
-117
lines changed

2 files changed

+365
-117
lines changed

core/src/main/scala/flatgraph/storage/Deserialization.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Deserialization {
1717
val fileChannel = new java.io.RandomAccessFile(storagePath.toAbsolutePath.toFile, "r").getChannel
1818
try {
1919
// fixme: Use convenience methods from schema to translate string->id. Fix after we get strict schema checking.
20-
val manifest = readManifest(fileChannel)
20+
val manifest = GraphItem.read(readManifest(fileChannel))
2121
val pool = readPool(manifest, fileChannel)
2222
val schema = schemaMaybe.getOrElse(freeSchemaFromManifest(manifest))
2323
val storagePathMaybe =
@@ -140,7 +140,7 @@ object Deserialization {
140140
}
141141
}
142142

143-
private def readManifest(channel: FileChannel): GraphItem = {
143+
def readManifest(channel: FileChannel): ujson.Value = {
144144
if (channel.size() < HeaderSize)
145145
throw new DeserializationException(s"corrupt file, expected at least $HeaderSize bytes, but only found ${channel.size()}")
146146

@@ -162,8 +162,8 @@ object Deserialization {
162162
readBytes += channel.read(manifestBytes, readBytes + manifestOffset)
163163
}
164164
manifestBytes.flip()
165-
val jsonObj = ujson.read(manifestBytes)
166-
GraphItem.read(jsonObj)
165+
ujson.read(manifestBytes)
166+
167167
}
168168

169169
private def readPool(manifest: GraphItem, fileChannel: FileChannel): Array[String] = {

0 commit comments

Comments
 (0)