Documentation ¶
Index ¶
- Variables
- func ShardKeyForTraceID(traceID []byte, shardCount int) int
- func SortRecords(records []Record)
- func ValidateShardCount(shardCount int) int
- type DataReader
- type DataWriter
- type DataWriterGeneric
- type ID
- type IndexReader
- type IndexWriter
- type ObjectCombiner
- type ObjectReaderWriter
- type Record
- type RecordReaderWriter
- type Records
- type ShardedBloomFilter
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnsupported = fmt.Errorf("unsupported")
)
This file contains types that need to be referenced by both the ./encoding and ./encoding/vX packages. It primarily exists here to break dependency loops.
Functions ¶
func ShardKeyForTraceID ¶
func SortRecords ¶ added in v1.0.0
func SortRecords(records []Record)
SortRecords sorts a slice of record pointers
func ValidateShardCount ¶ added in v1.0.0
For backward compatibility
Types ¶
type DataReader ¶ added in v0.7.0
type DataReader interface { Read(context.Context, []Record, [][]byte, []byte) ([][]byte, []byte, error) Close() // NextPage can be used to iterate at a page at a time. May return ErrUnsupported for older formats // NextPage takes a reusable buffer to read the page into and returns it in case it needs to resize // NextPage returns the uncompressed page buffer ready for object iteration and the length of the // original page from the page header. len(page) might not equal page len! NextPage([]byte) ([]byte, uint32, error) }
DataReader returns a slice of pages in the encoding/v0 format referenced by the slice of *Records passed in. The length of the returned slice is guaranteed to be equal to the length of the provided records unless error is non nil. DataReader is the primary abstraction point for supporting multiple data formats.
type DataWriter ¶ added in v0.7.0
type DataWriter interface { // Write writes the passed ID/byte to the current page Write(ID, []byte) (int, error) // CutPage completes the current page and start a new one. It // returns the length in bytes of the cut page. CutPage() (int, error) // Complete must be called when the operation DataWriter is done. Complete() error }
DataWriter is used to write paged data to the backend
type DataWriterGeneric ¶ added in v1.2.0
type DataWriterGeneric interface { // Write writes the passed ID/obj to the current page Write(context.Context, ID, interface{}) (int, error) // CutPage completes the current page and start a new one. It // returns the length in bytes of the cut page. CutPage(context.Context) (int, error) // Complete must be called when the operation DataWriter is done. Complete(context.Context) error }
DataWriterGeneric writes objects instead of byte slices
type IndexReader ¶
type IndexReader interface { At(ctx context.Context, i int) (*Record, error) Find(ctx context.Context, id ID) (*Record, int, error) }
IndexReader is used to abstract away the details of an index. Currently only used in the paged finder, it could eventually provide a way to support multiple index formats. IndexReader is the primary abstraction point for supporting multiple index formats.
type IndexWriter ¶ added in v0.7.0
type IndexWriter interface { // Write returns a byte representation of the provided Records Write([]Record) ([]byte, error) }
IndexWriter is used to write paged indexes
type ObjectCombiner ¶
type ObjectCombiner interface { // Combine objects encoded using dataEncoding. The returned object must // use the same dataEncoding. Returns a bool indicating if it the objects required combining and // the combined slice Combine(dataEncoding string, objs ...[]byte) ([]byte, bool) }
ObjectCombiner is used to combine two objects in the backend
type ObjectReaderWriter ¶ added in v0.7.0
type ObjectReaderWriter interface { MarshalObjectToWriter(id ID, b []byte, w io.Writer) (int, error) UnmarshalObjectFromReader(r io.Reader) (ID, []byte, error) UnmarshalAndAdvanceBuffer(buffer []byte) ([]byte, ID, []byte, error) }
ObjectReaderWriter represents a library of methods to read and write at the object level
type RecordReaderWriter ¶ added in v0.7.0
type RecordReaderWriter interface { MarshalRecords(records []Record) ([]byte, error) MarshalRecordsToBuffer(records []Record, buffer []byte) error RecordCount(b []byte) int UnmarshalRecord(buff []byte) Record RecordLength() int }
RecordReaderWriter represents a library of methods to read and write records
type Records ¶
type Records []Record
Records is a slice of *Record
type ShardedBloomFilter ¶
type ShardedBloomFilter struct {
// contains filtered or unexported fields
}
func NewBloom ¶ added in v1.0.0
func NewBloom(fp float64, shardSize, estimatedObjects uint) *ShardedBloomFilter
NewBloom creates a ShardedBloomFilter
func (*ShardedBloomFilter) Add ¶
func (b *ShardedBloomFilter) Add(traceID []byte)
func (*ShardedBloomFilter) GetShardCount ¶ added in v1.0.0
func (b *ShardedBloomFilter) GetShardCount() int
func (*ShardedBloomFilter) Marshal ¶ added in v1.0.0
func (b *ShardedBloomFilter) Marshal() ([][]byte, error)
Marshal is a wrapper around bloom.WriteTo
func (*ShardedBloomFilter) Test ¶
func (b *ShardedBloomFilter) Test(traceID []byte) bool
Test implements bloom.Test -> required only for testing