1
1
mirror of https://github.com/wader/fq.git synced 2024-12-29 16:42:06 +03:00
fq/format/postgres/pg_btree.go

37 lines
754 B
Go
Raw Normal View History

2022-09-19 15:45:54 +03:00
package postgres
import (
2022-09-23 13:50:54 +03:00
"embed"
2022-10-31 14:02:08 +03:00
"github.com/wader/fq/format/postgres/common/pg_btree/postgres"
2022-10-05 19:37:42 +03:00
2022-09-19 15:45:54 +03:00
"github.com/wader/fq/format"
"github.com/wader/fq/pkg/decode"
"github.com/wader/fq/pkg/interp"
)
2022-09-23 13:50:54 +03:00
//go:embed pg_btree.md
var pgBTreeFS embed.FS
2022-09-19 15:45:54 +03:00
func init() {
2023-05-03 09:45:25 +03:00
interp.RegisterFormat(format.PG_BTREE, &decode.Format{
2022-09-19 15:45:54 +03:00
Description: "PostgreSQL btree index file",
DecodeFn: decodePgBTree,
2023-05-03 09:45:25 +03:00
DefaultInArg: format.PostgresBTreeIn{
Page: 0,
},
RootArray: true,
RootName: "pages",
2022-09-19 15:45:54 +03:00
})
2022-09-23 13:50:54 +03:00
interp.RegisterFS(pgBTreeFS)
2022-09-19 15:45:54 +03:00
}
2023-05-03 09:45:25 +03:00
func decodePgBTree(d *decode.D) any {
2022-12-26 14:47:23 +03:00
d.Endian = decode.LittleEndian
2023-05-03 09:45:25 +03:00
var pgIn format.PostgresBTreeIn
if !d.ArgAs(&pgIn) {
d.Fatalf("DecodeInArg must be PostgresBTreeIn!\n")
}
return postgres.DecodePgBTree(d, pgIn)
2022-09-19 15:45:54 +03:00
}