mirror of
https://github.com/wader/fq.git
synced 2024-11-23 00:57:15 +03:00
leveldb: updates per PR comments
This commit is contained in:
parent
2df0f0fbcf
commit
fe1099b95d
@ -126,8 +126,8 @@ var (
|
||||
JSON = &decode.Group{Name: "json"}
|
||||
JSONL = &decode.Group{Name: "jsonl"}
|
||||
LevelDB_Descriptor = &decode.Group{Name: "leveldb_descriptor"}
|
||||
LDB = &decode.Group{Name: "leveldb_table"}
|
||||
LOG = &decode.Group{Name: "leveldb_log"}
|
||||
LevelDB_LDB = &decode.Group{Name: "leveldb_table"}
|
||||
LevelDB_LOG = &decode.Group{Name: "leveldb_log"}
|
||||
LuaJIT = &decode.Group{Name: "luajit"}
|
||||
MachO = &decode.Group{Name: "macho"}
|
||||
MachO_Fat = &decode.Group{Name: "macho_fat"}
|
||||
|
@ -23,7 +23,6 @@ func init() {
|
||||
format.LevelDB_Descriptor,
|
||||
&decode.Format{
|
||||
Description: "LevelDB Descriptor",
|
||||
Groups: []*decode.Group{format.Probe},
|
||||
DecodeFn: ldbDescriptorDecode,
|
||||
})
|
||||
interp.RegisterFS(leveldbDescriptorFS)
|
||||
@ -70,10 +69,7 @@ func ldbDescriptorDecode(d *decode.D) any {
|
||||
// List of sorted tables for each level involving key ranges and other metadata.
|
||||
func readManifest(d *decode.D) {
|
||||
d.FieldArray("tags", func(d *decode.D) {
|
||||
for {
|
||||
if d.End() {
|
||||
break
|
||||
}
|
||||
for !d.End() {
|
||||
d.FieldStruct("tag", func(d *decode.D) {
|
||||
tag := d.FieldULEB128("key", tagTypes)
|
||||
switch tag {
|
||||
|
@ -21,10 +21,9 @@ var leveldbLogFS embed.FS
|
||||
|
||||
func init() {
|
||||
interp.RegisterFormat(
|
||||
format.LOG,
|
||||
format.LevelDB_LOG,
|
||||
&decode.Format{
|
||||
Description: "LevelDB Log",
|
||||
Groups: []*decode.Group{format.Probe},
|
||||
DecodeFn: ldbLogDecode,
|
||||
})
|
||||
interp.RegisterFS(leveldbLogFS)
|
||||
|
@ -26,7 +26,7 @@ var leveldbFS embed.FS
|
||||
|
||||
func init() {
|
||||
interp.RegisterFormat(
|
||||
format.LDB,
|
||||
format.LevelDB_LDB,
|
||||
&decode.Format{
|
||||
Description: "LevelDB Table",
|
||||
Groups: []*decode.Group{format.Probe},
|
||||
@ -82,9 +82,13 @@ func ldbTableDecode(d *decode.D) any {
|
||||
var metaIndexOffset int64
|
||||
var metaIndexSize int64
|
||||
|
||||
d.SeekAbs(d.Len() - footerEncodedLength)
|
||||
d.FieldStruct("footer", func(d *decode.D) {
|
||||
handleLength := d.LimitedFn(footerEncodedLength, func(d *decode.D) {
|
||||
// check for magic number and fail fast if it isn't there
|
||||
d.SeekAbs(d.Len() - magicNumberLength)
|
||||
d.FieldU64("magic_number", d.UintAssert(tableMagicNumber), scalar.UintHex)
|
||||
|
||||
d.SeekAbs(d.Len() - footerEncodedLength)
|
||||
d.LimitedFn(footerEncodedLength-magicNumberLength, func(d *decode.D) {
|
||||
d.FieldStruct("metaindex_handle", func(d *decode.D) {
|
||||
metaIndexOffset = int64(d.FieldULEB128("offset"))
|
||||
metaIndexSize = int64(d.FieldULEB128("size"))
|
||||
@ -93,9 +97,8 @@ func ldbTableDecode(d *decode.D) any {
|
||||
indexOffset = int64(d.FieldULEB128("offset"))
|
||||
indexSize = int64(d.FieldULEB128("size"))
|
||||
})
|
||||
d.FieldRawLen("padding", d.BitsLeft())
|
||||
})
|
||||
d.FieldRawLen("padding", footerEncodedLength-handleLength-magicNumberLength)
|
||||
d.FieldU64("magic_number", d.UintAssert(tableMagicNumber), scalar.UintHex)
|
||||
})
|
||||
|
||||
// metaindex
|
||||
|
Loading…
Reference in New Issue
Block a user