func (f Index) ItemKey(item Item) (key []byte, err error) {
	return f.encodeKeyFunc(item)
}
ItemKey accepts an Item and returns generated key for it.
package shed
import (
	"bytes"
	"errors"
	"fmt"
	"github.com/syndtr/goleveldb/leveldb"
	"github.com/syndtr/goleveldb/leveldb/iterator"
)
type Item struct {
	Address         []byte
	Data            []byte
	AccessTimestamp int64
	StoreTimestamp  int64
	BinID           uint64
	PinCounter      uint64  
	Tag             uint32
	BatchID         []byte  
	Index           []byte  
	Timestamp       []byte  
	Sig             []byte  
	BucketDepth     uint8   
	Depth           uint8   
	Radius          uint8   
	Immutable       bool    
}
func (i Item) Merge(i2 Item) Item {
	if i.Address == nil {
		i.Address = i2.Address
	}
	if i.Data == nil {
		i.Data = i2.Data
	}
	if i.AccessTimestamp == 0 {
		i.AccessTimestamp = i2.AccessTimestamp
	}
	if i.StoreTimestamp == 0 {
		i.StoreTimestamp = i2.StoreTimestamp
	}
	if i.BinID == 0 {
		i.BinID = i2.BinID
	}
	if i.PinCounter == 0 {
		i.PinCounter = i2.PinCounter
	}
	if i.Tag == 0 {
		i.Tag = i2.Tag
	}
	if len(i.BatchID) == 0 {
		i.BatchID = i2.BatchID
	}
	if len(i.Index) == 0 {
		i.Index = i2.Index
	}
	if len(i.Timestamp) == 0 {
		i.Timestamp = i2.Timestamp
	}
	if len(i.Sig) == 0 {
		i.Sig = i2.Sig
	}
	if i.BucketDepth == 0 {
		i.BucketDepth = i2.BucketDepth
	}
	if i.Depth == 0 {
		i.Depth = i2.Depth
	}
	if i.Radius == 0 {
		i.Radius = i2.Radius
	}
	if !i.Immutable {
		i.Immutable = i2.Immutable
	}
	return i
}
type Index struct {
	db              *DB
	prefix          []byte
	encodeKeyFunc   func(fields Item) (key []byte, err error)
	decodeKeyFunc   func(key []byte) (e Item, err error)
	encodeValueFunc func(fields Item) (value []byte, err error)
	decodeValueFunc func(keyFields Item, value []byte) (e Item, err error)
}
type IndexFuncs struct {
	EncodeKey   func(fields Item) (key []byte, err error)
	DecodeKey   func(key []byte) (e Item, err error)
	EncodeValue func(fields Item) (value []byte, err error)
	DecodeValue func(keyFields Item, value []byte) (e Item, err error)
}
func (db *DB) NewIndex(name string, funcs IndexFuncs) (f Index, err error) {
	id, err := db.schemaIndexPrefix(name)
	if err != nil {
		return f, fmt.Errorf("get schema index prefix: %w", err)
	}
	prefix := []byte{id}
	return Index{
		db:     db,
		prefix: prefix,
		encodeKeyFunc: func(e Item) (key []byte, err error) {
			key, err = funcs.EncodeKey(e)
			if err != nil {
				return nil, err
			}
			return append(append(make([]byte, 0, len(key)+1), prefix...), key...), nil
		},
		decodeKeyFunc: func(key []byte) (e Item, err error) {
			return funcs.DecodeKey(key[1:])
		},
		encodeValueFunc: funcs.EncodeValue,
		decodeValueFunc: funcs.DecodeValue,
	}, nil
}