Documentation ¶
Overview ¶
Package index provides access to files through multilevel indexes.
A multilevel index contains one or more levels where the lowest level contains file type index entries which directly reference file content and the above levels contain range type index entries which directly reference a range of index entries and indirectly reference ranges of file content. Multilevel indexes are created using writers which provide functionality for creating indexes for new files or creating indexes based on other indexes (rooted by file or range type indexes). Reading a multilevel index requires setting up a reader which provide various indexing strategies and filters.
Index ¶
- Constants
- Variables
- func Generate(s string) []string
- func Merge(ctx context.Context, storage *chunk.Storage, indexes []*Index, ...) error
- func Perm(a []rune, f func([]rune))
- func PointsTo(idx *Index) []chunk.ID
- func SizeBytes(idx *Index) int64
- type Cache
- type File
- func (*File) Descriptor() ([]byte, []int)
- func (m *File) GetDataRefs() []*chunk.DataRef
- func (m *File) GetDatum() string
- func (m *File) Marshal() (dAtA []byte, err error)
- func (x *File) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (m *File) MarshalTo(dAtA []byte) (int, error)
- func (m *File) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*File) ProtoMessage()
- func (m *File) Reset()
- func (m *File) Size() (n int)
- func (m *File) String() string
- func (m *File) Unmarshal(dAtA []byte) error
- func (m *File) XXX_DiscardUnknown()
- func (m *File) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *File) XXX_Merge(src proto.Message)
- func (m *File) XXX_Size() int
- func (m *File) XXX_Unmarshal(b []byte) error
- type Index
- func (*Index) Descriptor() ([]byte, []int)
- func (m *Index) GetFile() *File
- func (m *Index) GetNumFiles() int64
- func (m *Index) GetPath() string
- func (m *Index) GetRange() *Range
- func (m *Index) GetSizeBytes() int64
- func (m *Index) Marshal() (dAtA []byte, err error)
- func (x *Index) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (m *Index) MarshalTo(dAtA []byte) (int, error)
- func (m *Index) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Index) ProtoMessage()
- func (m *Index) Reset()
- func (m *Index) Size() (n int)
- func (m *Index) String() string
- func (m *Index) Unmarshal(dAtA []byte) error
- func (m *Index) XXX_DiscardUnknown()
- func (m *Index) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Index) XXX_Merge(src proto.Message)
- func (m *Index) XXX_Size() int
- func (m *Index) XXX_Unmarshal(b []byte) error
- type Option
- type PathRange
- type Range
- func (*Range) Descriptor() ([]byte, []int)
- func (m *Range) GetChunkRef() *chunk.DataRef
- func (m *Range) GetLastPath() string
- func (m *Range) GetOffset() int64
- func (m *Range) Marshal() (dAtA []byte, err error)
- func (x *Range) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (m *Range) MarshalTo(dAtA []byte) (int, error)
- func (m *Range) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Range) ProtoMessage()
- func (m *Range) Reset()
- func (m *Range) Size() (n int)
- func (m *Range) String() string
- func (m *Range) Unmarshal(dAtA []byte) error
- func (m *Range) XXX_DiscardUnknown()
- func (m *Range) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Range) XXX_Merge(src proto.Message)
- func (m *Range) XXX_Size() int
- func (m *Range) XXX_Unmarshal(b []byte) error
- type Reader
- type ShardConfig
- type Writer
Constants ¶
const ( // DefaultShardNumThreshold is the default for the NumFiles threshold that must // be met before a shard is created. DefaultShardNumThreshold = 1000000 // DefaultShardSizeThreshold is the default for the SizeBytes threshold that must // be met before a shard is created. DefaultShardSizeThreshold = units.GB )
const (
DefaultBatchThreshold = units.MB
)
Variables ¶
Functions ¶
func Generate ¶
Generate generates the permutations of the passed in string and returns them sorted.
Types ¶
type File ¶
type File struct { Datum string `protobuf:"bytes,1,opt,name=datum,proto3" json:"datum,omitempty"` DataRefs []*chunk.DataRef `protobuf:"bytes,2,rep,name=data_refs,json=dataRefs,proto3" json:"data_refs,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*File) Descriptor ¶
func (*File) GetDataRefs ¶
func (*File) MarshalLogObject ¶
func (x *File) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*File) ProtoMessage ¶
func (*File) ProtoMessage()
func (*File) XXX_DiscardUnknown ¶
func (m *File) XXX_DiscardUnknown()
func (*File) XXX_Unmarshal ¶
type Index ¶
type Index struct { Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` // NOTE: range and file are mutually exclusive. Range *Range `protobuf:"bytes,2,opt,name=range,proto3" json:"range,omitempty"` File *File `protobuf:"bytes,3,opt,name=file,proto3" json:"file,omitempty"` // NOTE: num_files and size_bytes did not exist in older versions of 2.x, so // they will not be set. NumFiles int64 `protobuf:"varint,4,opt,name=num_files,json=numFiles,proto3" json:"num_files,omitempty"` SizeBytes int64 `protobuf:"varint,5,opt,name=size_bytes,json=sizeBytes,proto3" json:"size_bytes,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Index stores an index to and metadata about a range of files or a file.
func (*Index) Descriptor ¶
func (*Index) GetNumFiles ¶
func (*Index) GetSizeBytes ¶
func (*Index) MarshalLogObject ¶
func (x *Index) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*Index) ProtoMessage ¶
func (*Index) ProtoMessage()
func (*Index) XXX_DiscardUnknown ¶
func (m *Index) XXX_DiscardUnknown()
func (*Index) XXX_Marshal ¶
func (*Index) XXX_Unmarshal ¶
type Option ¶
type Option func(r *Reader)
Option configures an index reader.
func WithPrefix ¶
WithPrefix sets a prefix filter for the read.
func WithShardConfig ¶
func WithShardConfig(config *ShardConfig) Option
WithShardConfig sets the sharding configuration.
type PathRange ¶
type PathRange struct {
Lower, Upper string
}
PathRange is a range of paths. The range is inclusive, exclusive: [Lower, Upper).
type Range ¶
type Range struct { Offset int64 `protobuf:"varint,1,opt,name=offset,proto3" json:"offset,omitempty"` LastPath string `protobuf:"bytes,2,opt,name=last_path,json=lastPath,proto3" json:"last_path,omitempty"` ChunkRef *chunk.DataRef `protobuf:"bytes,3,opt,name=chunk_ref,json=chunkRef,proto3" json:"chunk_ref,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Range) Descriptor ¶
func (*Range) GetChunkRef ¶
func (*Range) GetLastPath ¶
func (*Range) MarshalLogObject ¶
func (x *Range) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*Range) ProtoMessage ¶
func (*Range) ProtoMessage()
func (*Range) XXX_DiscardUnknown ¶
func (m *Range) XXX_DiscardUnknown()
func (*Range) XXX_Marshal ¶
func (*Range) XXX_Unmarshal ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is used for reading a multilevel index.
func (*Reader) Shards ¶
Shards creates shards for the index based on the sharding configuration provided to the reader. Sharding takes advantage of the NumFiles and SizeBytes index metadata to efficiently traverse the multilevel index. A subtree is traversed only when a split point exists within it, which we know based on the NumFiles and SizeBytes values at the root of each subtree.
type ShardConfig ¶
ShardConfig is a sharding configuration. NumFiles is the number of files to target for each shard. SizeBytes is the size, in bytes, to target for each shard.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is used for creating a multilevel index into a serialized file set. Each index level is a stream of byte length encoded index entries that are stored in chunk storage. Both file and range type indexes can be written to a writer. New levels above the written indexes will be created when the serialized indexes reach the batching threshold.
func (*Writer) WriteIndex ¶
WriteIndex writes an index entry.