Skip to content

Commit

Permalink
add reverse converter (#224)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
bbrehm authored Jul 11, 2024
1 parent 176e151 commit 852eeb9
Show file tree
Hide file tree
Showing 2 changed files with 365 additions and 117 deletions.
8 changes: 4 additions & 4 deletions core/src/main/scala/flatgraph/storage/Deserialization.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object Deserialization {
val fileChannel = new java.io.RandomAccessFile(storagePath.toAbsolutePath.toFile, "r").getChannel
try {
// fixme: Use convenience methods from schema to translate string->id. Fix after we get strict schema checking.
val manifest = readManifest(fileChannel)
val manifest = GraphItem.read(readManifest(fileChannel))
val pool = readPool(manifest, fileChannel)
val schema = schemaMaybe.getOrElse(freeSchemaFromManifest(manifest))
val storagePathMaybe =
Expand Down Expand Up @@ -140,7 +140,7 @@ object Deserialization {
}
}

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

Expand All @@ -162,8 +162,8 @@ object Deserialization {
readBytes += channel.read(manifestBytes, readBytes + manifestOffset)
}
manifestBytes.flip()
val jsonObj = ujson.read(manifestBytes)
GraphItem.read(jsonObj)
ujson.read(manifestBytes)

}

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

0 comments on commit 852eeb9

Please sign in to comment.