Documentation
¶
Index ¶
- Constants
- Variables
- func BasicWhitespaceLowerTokenizer(value any) []string
- func ConvertToInt64(value any) (int64, bool)
- func ConvertToMinMaxInt64(value any) (minVal int64, maxVal int64, ok bool)
- func EvaluateDataBlockMetadata(metadata *DataBlockMetadata, query *QueryPrefilter) bool
- func EvaluateMinMaxCondition(minMaxIndex MinMaxIndex, condition NumericCondition) bool
- func EvaluateNumericCondition(value int64, condition NumericCondition) bool
- func EvaluateStringCondition(value string, condition StringCondition) bool
- func FormatBytesPerSecond(bytes int64, duration time.Duration) string
- func FormatRate(count int64, duration time.Duration) string
- func SendWithContext[T any](ctx context.Context, ch chan<- T, value T) error
- func TestGJSONForField(value gjson.Result, fieldPath, delimiter string) bool
- func TestGJSONForFieldToken(value gjson.Result, fieldPath, delimiter, token string, ...) bool
- func TestGJSONForToken(value gjson.Result, token string, tokenizer ValueTokenizerFunc) bool
- func TestJSONForBloomCondition(jsonBytes []byte, condition *BloomCondition, delimiter string, ...) bool
- func TestJSONForBloomQuery(jsonBytes []byte, bloomQuery *BloomQuery, delimiter string, ...) bool
- func TestJSONForField(jsonStr, fieldPath, delimiter string) bool
- func TestJSONForFieldToken(jsonStr, fieldPath, delimiter, token string, tokenizer ValueTokenizerFunc) bool
- func TestJSONForToken(jsonStr, token string, tokenizer ValueTokenizerFunc) bool
- func TryWriteChannel[T any](ch chan<- T, value T) bool
- func TryWriteToChannels[T any](channels []chan T, value T)
- type BlockStats
- type BloomCondition
- type BloomConditionType
- type BloomExpression
- type BloomExpressionType
- type BloomFilters
- type BloomQuery
- type BloomSearchEngine
- func (b *BloomSearchEngine) Flush(ctx context.Context) error
- func (b *BloomSearchEngine) IngestRows(ctx context.Context, rows []map[string]any, doneChan chan error) error
- func (b *BloomSearchEngine) Merge(ctx context.Context) (*MergeStats, error)
- func (b *BloomSearchEngine) Query(ctx context.Context, query *Query, resultChan chan<- map[string]any, ...) error
- func (b *BloomSearchEngine) Start()
- func (b *BloomSearchEngine) Stop(ctx context.Context) error
- type BloomSearchEngineConfig
- type Combinator
- type CompressionType
- type DataBlockMetadata
- type DataStore
- type DeleteOperation
- type FieldValues
- type FileMetadata
- type FileSystemDataStore
- func (fs *FileSystemDataStore) CreateFile(ctx context.Context) (io.WriteCloser, []byte, error)
- func (fs *FileSystemDataStore) GetMaybeFilesForQuery(ctx context.Context, query *QueryPrefilter) ([]MaybeFile, error)
- func (fs *FileSystemDataStore) OpenFile(ctx context.Context, filePointerBytes []byte) (io.ReadSeekCloser, error)
- func (fs *FileSystemDataStore) Update(ctx context.Context, writes []WriteOperation, deletes []DeleteOperation) error
- type FileSystemDataStoreFilePointer
- type MaybeFile
- type MemoryMetaStore
- type MergeStats
- type MetaStore
- type MinMaxIndex
- type NullDataStore
- type NullDataStoreFilePointer
- type NullMetaStore
- type NumericCondition
- func NumericBetween(min, max int64) NumericCondition
- func NumericEquals(value int64) NumericCondition
- func NumericGreaterThan(value int64) NumericCondition
- func NumericGreaterThanEqual(value int64) NumericCondition
- func NumericIn(values ...int64) NumericCondition
- func NumericLessThan(value int64) NumericCondition
- func NumericLessThanEqual(value int64) NumericCondition
- func NumericNotBetween(min, max int64) NumericCondition
- func NumericNotEquals(value int64) NumericCondition
- func NumericNotIn(values ...int64) NumericCondition
- type PartitionFunc
- type PrefilterCondition
- type PrefilterExpression
- type Query
- type QueryBuilder
- func (b *QueryBuilder) Build() *Query
- func (b *QueryBuilder) Field(field string) *QueryBuilder
- func (b *QueryBuilder) FieldToken(field, token string) *QueryBuilder
- func (b *QueryBuilder) Match(expression BloomExpression) *QueryBuilder
- func (b *QueryBuilder) MatchPrefilter(expression PrefilterExpression) *QueryBuilder
- func (b *QueryBuilder) Token(token string) *QueryBuilder
- type QueryOperator
- type QueryPrefilter
- type StringCondition
- func PartitionBetween(min, max string) StringCondition
- func PartitionEquals(value string) StringCondition
- func PartitionGreaterThan(value string) StringCondition
- func PartitionGreaterThanEqual(value string) StringCondition
- func PartitionIn(values ...string) StringCondition
- func PartitionLessThan(value string) StringCondition
- func PartitionLessThanEqual(value string) StringCondition
- func PartitionNotBetween(min, max string) StringCondition
- func PartitionNotEquals(value string) StringCondition
- func PartitionNotIn(values ...string) StringCondition
- type ValueTokenizerFunc
- type WriteOperation
Constants ¶
const ( FileVersion = uint32(1) MagicBytes = "BLOMSRCH" LengthPrefixSize = 4 VersionPrefixSize = 4 HashSize = 4 )
File format constants
Variables ¶
var (
ErrInvalidConfig = errors.New("invalid configuration")
)
var (
ErrInvalidHash = errors.New("invalid hash")
)
Functions ¶
func BasicWhitespaceLowerTokenizer ¶
BasicWhitespaceLowerTokenizer tokenizes values by splitting on whitespace and converting to lowercase
func ConvertToInt64 ¶
ConvertToInt64 converts any numeric value to int64. For floats, it rounds to the nearest integer. Returns false if the value is not a numeric type.
func ConvertToMinMaxInt64 ¶
ConvertToMinMaxInt64 converts any numeric value to int64 min/max values. For integers, min and max are the same. For floats, min uses Floor and max uses Ceil. Returns false if the value is not a numeric type.
func EvaluateDataBlockMetadata ¶
func EvaluateDataBlockMetadata(metadata *DataBlockMetadata, query *QueryPrefilter) bool
EvaluateDataBlockMetadata checks if a DataBlockMetadata matches the prefilter expression.
func EvaluateMinMaxCondition ¶
func EvaluateMinMaxCondition(minMaxIndex MinMaxIndex, condition NumericCondition) bool
EvaluateMinMaxCondition checks if a MinMaxIndex overlaps with the given condition This is used for range-based filtering where we want to include data blocks that might contain matching values
func EvaluateNumericCondition ¶
func EvaluateNumericCondition(value int64, condition NumericCondition) bool
EvaluateNumericCondition checks if a numeric value matches the given condition
func EvaluateStringCondition ¶
func EvaluateStringCondition(value string, condition StringCondition) bool
EvaluateStringCondition checks if a string value matches the given condition
func FormatBytesPerSecond ¶
FormatBytesPerSecond formats bytes per second into human-readable format (B/s, KB/s, MB/s, GB/s, TB/s)
func FormatRate ¶
FormatRate formats rate per second
func SendWithContext ¶
SendWithContext attempts to send a value to a channel while respecting context cancellation. Returns an error if the context is done before the send completes.
func TestGJSONForField ¶
Byte-based helpers that operate on a pre-parsed gjson.Result
func TestGJSONForFieldToken ¶
func TestGJSONForFieldToken(value gjson.Result, fieldPath, delimiter, token string, tokenizer ValueTokenizerFunc) bool
func TestGJSONForToken ¶
func TestGJSONForToken(value gjson.Result, token string, tokenizer ValueTokenizerFunc) bool
func TestJSONForBloomCondition ¶
func TestJSONForBloomCondition(jsonBytes []byte, condition *BloomCondition, delimiter string, tokenizer ValueTokenizerFunc) bool
TestJSONForBloomCondition tests a JSON string against a bloom condition using gjson
func TestJSONForBloomQuery ¶
func TestJSONForBloomQuery(jsonBytes []byte, bloomQuery *BloomQuery, delimiter string, tokenizer ValueTokenizerFunc) bool
TestJSONForBloomQuery tests a JSON string against a bloom query using gjson
func TestJSONForField ¶
TestJSONForField tests if a field path exists in JSON, handling arrays by walking them
func TestJSONForFieldToken ¶
func TestJSONForFieldToken(jsonStr, fieldPath, delimiter, token string, tokenizer ValueTokenizerFunc) bool
TestJSONForFieldToken tests if a specific field contains a specific token, handling arrays by walking them
func TestJSONForToken ¶
func TestJSONForToken(jsonStr, token string, tokenizer ValueTokenizerFunc) bool
TestJSONForToken tests if a token exists in any field value, handling arrays by walking them
func TryWriteChannel ¶
TryWriteChannel attempts to write a value to a channel without blocking. Returns true if the write was successful, false if the channel is full, nobody is listening, or the channel is nil.
func TryWriteToChannels ¶
func TryWriteToChannels[T any](channels []chan T, value T)
TryWriteToChannels sends a value to all channels using TryWriteChannel
Types ¶
type BlockStats ¶
type BloomCondition ¶
type BloomCondition struct {
Type BloomConditionType
Field string // for FIELD and FIELD_TOKEN
Token string // for TOKEN and FIELD_TOKEN
}
type BloomConditionType ¶
type BloomConditionType string
const ( BloomField BloomConditionType = "FIELD" BloomToken BloomConditionType = "TOKEN" BloomFieldToken BloomConditionType = "FIELD_TOKEN" )
type BloomExpression ¶
type BloomExpression struct {
// contains filtered or unexported fields
}
func And ¶
func And(expressions ...BloomExpression) BloomExpression
func Field ¶
func Field(field string) BloomExpression
func FieldToken ¶
func FieldToken(field, token string) BloomExpression
func Or ¶
func Or(expressions ...BloomExpression) BloomExpression
func Token ¶
func Token(token string) BloomExpression
type BloomExpressionType ¶
type BloomExpressionType string
type BloomFilters ¶
type BloomFilters struct {
FieldBloomFilter *bloom.BloomFilter
TokenBloomFilter *bloom.BloomFilter
FieldTokenBloomFilter *bloom.BloomFilter
}
BloomFilters contains the bloom filters for a data block This struct is serialized and stored at the beginning of each data block
func DataBlockBloomFiltersFromBytesWithHash ¶
func DataBlockBloomFiltersFromBytesWithHash(bytes []byte, expectedHashBytes []byte) (*BloomFilters, error)
func ReadDataBlockBloomFilters ¶
func ReadDataBlockBloomFilters(file io.ReadSeeker, blockMetadata DataBlockMetadata) (*BloomFilters, error)
ReadDataBlockBloomFilters reads bloom filters from a data block given a file reader and block metadata
func (*BloomFilters) Bytes ¶
func (d *BloomFilters) Bytes() ([]byte, []byte)
Returns the data block bloom filters as a byte slice and the CRC32C of the bloom filters
type BloomQuery ¶
type BloomQuery struct {
Expression *BloomExpression `json:",omitempty"`
}
type BloomSearchEngine ¶
type BloomSearchEngine struct {
// contains filtered or unexported fields
}
func NewBloomSearchEngine ¶
func NewBloomSearchEngine(config BloomSearchEngineConfig, metaStore MetaStore, dataStore DataStore) (*BloomSearchEngine, error)
func (*BloomSearchEngine) Flush ¶
func (b *BloomSearchEngine) Flush(ctx context.Context) error
Flush forces a flush of any buffered data
func (*BloomSearchEngine) IngestRows ¶
func (b *BloomSearchEngine) IngestRows(ctx context.Context, rows []map[string]any, doneChan chan error) error
IngestRows queues rows for ingestion by the actor
func (*BloomSearchEngine) Merge ¶
func (b *BloomSearchEngine) Merge(ctx context.Context) (*MergeStats, error)
Merge executes file merging to optimize storage and query performance
func (*BloomSearchEngine) Query ¶
func (b *BloomSearchEngine) Query(ctx context.Context, query *Query, resultChan chan<- map[string]any, errorChan chan<- error, statsChan chan<- BlockStats) error
Query executes a query and sends results to the provided channels. The result channel feeds individual matching rows. Canceling the context will stop all workers. When the result channel closes, no more work is happening.
The error channel is written to for any errors that occur per-worker. If a worker writes to this channel, it has stopped processing.
Example usage:
resultChan := make(chan map[string]any, 1000)
errorChan := make(chan error, 100)
err := engine.Query(ctx, query, resultChan, errorChan, nil)
if err != nil { return err }
for {
select {
case <-ctx.Done():
return ctx.Err()
case row, ok := <-resultChan:
if !ok { return nil } // done
// process row
case err := <-errorChan:
return err
}
}
func (*BloomSearchEngine) Start ¶
func (b *BloomSearchEngine) Start()
Start begins the ingestion and flush workers
type BloomSearchEngineConfig ¶
type BloomSearchEngineConfig struct {
Tokenizer ValueTokenizerFunc
PartitionFunc PartitionFunc
MinMaxIndexes []string
MaxRowGroupBytes int
MaxRowGroupRows int
MaxFileSize int
MaxBufferedRows int
MaxBufferedBytes int
MaxBufferedTime time.Duration
IngestBufferSize int
// The maximum number of total data blocks that can be processed concurrently across all queries
MaxQueryConcurrency int
// Bloom filter parameters
FileBloomExpectedItems uint
BloomFalsePositiveRate float64
// Compression configuration
RowDataCompression CompressionType
// Compression level for zstd (1-22, higher = better compression, slower)
// Ignored for snappy compression
ZstdCompressionLevel int
// Maximum number of files to merge together in a single merge operation
MaxFilesToMergePerOperation int
}
func DefaultBloomSearchEngineConfig ¶
func DefaultBloomSearchEngineConfig() BloomSearchEngineConfig
type Combinator ¶
type Combinator string
Combinator specifies how conditions should be combined
const ( CombinatorAND Combinator = "AND" CombinatorOR Combinator = "OR" )
type CompressionType ¶
type CompressionType string
CompressionType represents the compression algorithm used for row data
const ( CompressionNone CompressionType = "none" CompressionSnappy CompressionType = "snappy" CompressionZstd CompressionType = "zstd" )
type DataBlockMetadata ¶
type DataBlockMetadata struct {
// Absolute file offset (includes bloom filters at the beginning)
Offset int
// Size includes the bloom filters, their hash, and row data (no trailing hash)
Size int
Rows int
// Size of the bloom filters section (bloom filters + hash)
BloomFiltersSize int
MinMaxIndexes map[string]MinMaxIndex `json:",omitempty"`
PartitionID string `json:",omitempty"`
// Compression algorithm used for the row data in this block
Compression CompressionType `json:",omitempty"`
// Uncompressed size of row data (for decompression buffer allocation)
UncompressedSize int `json:",omitempty"`
// Hash of the compressed row data (for integrity verification)
RowDataHash uint32 `json:",omitempty"`
BloomExpectedItems uint
BloomFalsePositiveRate float64
}
func FilterDataBlocks ¶
func FilterDataBlocks(blocks []DataBlockMetadata, query *QueryPrefilter) []DataBlockMetadata
FilterDataBlocks filters a slice of DataBlockMetadata based on query conditions
type DataStore ¶
type DataStore interface {
// CreateFile creates a file for single-pass writing, returning the handle for writing and the file pointer bytes.
CreateFile(ctx context.Context) (io.WriteCloser, []byte, error)
// OpenFile opens a file for reading.
OpenFile(ctx context.Context, filePointerBytes []byte) (io.ReadSeekCloser, error)
}
DataStore is used to read and write the file from storage.
filePointerBytes is the serialized file pointer that is passed to the DataStore to open the file for reading, and stored within the MetaStore. For example, for an S3DataStore, this might be a serialzed JSON object of the bucket and file key.
type DeleteOperation ¶
type DeleteOperation struct {
FilePointerBytes []byte
}
type FieldValues ¶
FieldValues represents a field path and its associated values
func UniqueFields ¶
func UniqueFields(row map[string]any, delimiter string) []FieldValues
UniqueFields extracts all unique field paths from a nested map structure using the specified delimiter, returning tuples of (field_name, []values) where values are deduplicated per field. Arrays are traversed but indices are ignored, so duplicate paths from array elements are deduplicated.
Example:
{"user": {"name": "John", "tags": [{"type": "user"}, {"role": "admin"}]}}
Returns:
[{Path: "user.name", Values: ["John"]}, {Path: "user.tags.type", Values: ["user"]}, {Path: "user.tags.role", Values: ["admin"]}] (with delimiter ".")
type FileMetadata ¶
type FileMetadata struct {
BloomFilters BloomFilters
BloomExpectedItems uint
BloomFalsePositiveRate float64
DataBlocks []DataBlockMetadata
}
func FileMetadataFromBytesWithHash ¶
func FileMetadataFromBytesWithHash(bytes []byte, expectedHashBytes []byte) (*FileMetadata, error)
func (*FileMetadata) Bytes ¶
func (f *FileMetadata) Bytes() ([]byte, []byte)
Returns the file metadata as a byte slice and the CRC32C of the file metadata
type FileSystemDataStore ¶
type FileSystemDataStore struct {
// contains filtered or unexported fields
}
func NewFileSystemDataStore ¶
func NewFileSystemDataStore(rootDir string) *FileSystemDataStore
func (*FileSystemDataStore) CreateFile ¶
func (fs *FileSystemDataStore) CreateFile(ctx context.Context) (io.WriteCloser, []byte, error)
func (*FileSystemDataStore) GetMaybeFilesForQuery ¶
func (fs *FileSystemDataStore) GetMaybeFilesForQuery(ctx context.Context, query *QueryPrefilter) ([]MaybeFile, error)
func (*FileSystemDataStore) OpenFile ¶
func (fs *FileSystemDataStore) OpenFile(ctx context.Context, filePointerBytes []byte) (io.ReadSeekCloser, error)
func (*FileSystemDataStore) Update ¶
func (fs *FileSystemDataStore) Update(ctx context.Context, writes []WriteOperation, deletes []DeleteOperation) error
type FileSystemDataStoreFilePointer ¶
type FileSystemDataStoreFilePointer struct {
ID string
}
type MaybeFile ¶
type MaybeFile struct {
// The file pointer is serialized to bytes and passed to the DataStore to open the file for reading.
PointerBytes []byte
// The FileMetadata.DataBlocks may choose to be a filtered list instead of the full list of data blocks
Metadata FileMetadata
// The size of the file in bytes
Size int
}
MaybeFile is a pointer to a file that may contain rows of interest based on pre-filtering conditions (partition IDs, minmax indexes). They have not had their bloom filters tested yet.
type MemoryMetaStore ¶
type MemoryMetaStore struct {
// contains filtered or unexported fields
}
MemoryMetaStore is a simple map-based implementation for testing
func NewSimpleMetaStore ¶
func NewSimpleMetaStore() *MemoryMetaStore
func (*MemoryMetaStore) GetMaybeFilesForQuery ¶
func (s *MemoryMetaStore) GetMaybeFilesForQuery(ctx context.Context, prefilter *QueryPrefilter) ([]MaybeFile, error)
GetMaybeFilesForQuery implements the MetaStore interface
func (*MemoryMetaStore) PrintFiles ¶
func (s *MemoryMetaStore) PrintFiles()
PrintFiles prints all files in the metastore for debugging
func (*MemoryMetaStore) Update ¶
func (s *MemoryMetaStore) Update(ctx context.Context, writeOps []WriteOperation, deleteOps []DeleteOperation) error
Update implements the MetaStore interface
type MergeStats ¶
type MetaStore ¶
type MetaStore interface {
// GetMaybeFilesForQuery returns pointers to files that may contain rows of interest based on the query conditions.
// The returned files have already been pre-filtered based on partition IDs and MinMaxIndex conditions,
// but their bloom filters have not been tested yet.
//
// If the query specifies partition ID or MinMax index conditions, but the file does not have them,
// the file must be included in the result set, as it may have rows of interest.
//
// The MaybeFile.Metadata.DataBlocks may choose to be a filtered list instead of the full list of data blocks
// if the query conditions are able to guarantee that some data blocks will not match the query conditions.
GetMaybeFilesForQuery(ctx context.Context, query *QueryPrefilter) ([]MaybeFile, error)
// Update atomically performes a set of operations on the MetaStore.
Update(ctx context.Context, writes []WriteOperation, deletes []DeleteOperation) error
}
MetaStore is a generic interface for a metadata store that can be used to store and retrieve file and data block metadata.
FilePointer is a pointer to a file in the metadata store, depending on the implementation of the MetaStore and DataStore.
type MinMaxIndex ¶
func UpdateMinMaxIndex ¶
func UpdateMinMaxIndex(existing MinMaxIndex, newMin, newMax int64) MinMaxIndex
UpdateMinMaxIndex updates an existing MinMaxIndex with new min/max values.
type NullDataStore ¶
type NullDataStore struct{}
TESTING
func (*NullDataStore) CreateFile ¶
func (n *NullDataStore) CreateFile(ctx context.Context) (io.WriteCloser, []byte, error)
func (*NullDataStore) OpenFile ¶
func (n *NullDataStore) OpenFile(ctx context.Context, filePointerBytes []byte) (io.ReadSeekCloser, error)
type NullDataStoreFilePointer ¶
type NullDataStoreFilePointer struct {
ID string
}
type NullMetaStore ¶
type NullMetaStore struct{}
func (*NullMetaStore) GetMaybeFilesForQuery ¶
func (n *NullMetaStore) GetMaybeFilesForQuery(ctx context.Context, query *QueryPrefilter) ([]MaybeFile, error)
func (*NullMetaStore) Update ¶
func (n *NullMetaStore) Update(ctx context.Context, writes []WriteOperation, deletes []DeleteOperation) error
type NumericCondition ¶
type NumericCondition struct {
Operator QueryOperator `json:",omitempty"` // for EQ, NE, GT, GTE, LT, LTE
Value int64 `json:",omitempty"` // for EQ, NE, GT, GTE, LT, LTE
Values []int64 `json:",omitempty"` // for IN, NOT_IN
Min int64 `json:",omitempty"` // for BETWEEN, NOT_BETWEEN
Max int64 `json:",omitempty"` // for BETWEEN, NOT_BETWEEN
}
NumericCondition represents a condition on numeric values (like MinMaxIndex)
func NumericBetween ¶
func NumericBetween(min, max int64) NumericCondition
NumericBetween creates a numeric BETWEEN condition (inclusive)
func NumericEquals ¶
func NumericEquals(value int64) NumericCondition
NumericEquals creates a numeric equality condition
func NumericGreaterThan ¶
func NumericGreaterThan(value int64) NumericCondition
NumericGreaterThan creates a numeric greater than condition
func NumericGreaterThanEqual ¶
func NumericGreaterThanEqual(value int64) NumericCondition
NumericGreaterThanEqual creates a numeric greater than or equal condition
func NumericIn ¶
func NumericIn(values ...int64) NumericCondition
NumericIn creates a numeric IN condition
func NumericLessThan ¶
func NumericLessThan(value int64) NumericCondition
NumericLessThan creates a numeric less than condition
func NumericLessThanEqual ¶
func NumericLessThanEqual(value int64) NumericCondition
NumericLessThanEqual creates a numeric less than or equal condition
func NumericNotBetween ¶
func NumericNotBetween(min, max int64) NumericCondition
NumericNotBetween creates a numeric NOT BETWEEN condition (exclusive)
func NumericNotEquals ¶
func NumericNotEquals(value int64) NumericCondition
NumericNotEquals creates a numeric not equal condition
func NumericNotIn ¶
func NumericNotIn(values ...int64) NumericCondition
NumericNotIn creates a numeric NOT IN condition
type PartitionFunc ¶
type PrefilterCondition ¶
type PrefilterCondition struct {
// contains filtered or unexported fields
}
type PrefilterExpression ¶
type PrefilterExpression struct {
// contains filtered or unexported fields
}
func MinMax ¶
func MinMax(fieldName string, condition NumericCondition) PrefilterExpression
func Partition ¶
func Partition(condition StringCondition) PrefilterExpression
func PrefilterAnd ¶
func PrefilterAnd(expressions ...PrefilterExpression) PrefilterExpression
func PrefilterOr ¶
func PrefilterOr(expressions ...PrefilterExpression) PrefilterExpression
type Query ¶
type Query struct {
Prefilter *QueryPrefilter // for partitions and minmax indexes
Bloom *BloomQuery // for field/token/fieldtoken searches
}
Query combines prefiltering (partitions/minmax) with bloom filtering
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
func NewQuery ¶
func NewQuery() *QueryBuilder
NewQuery creates a query builder with an implicit AND expression.
func (*QueryBuilder) Build ¶
func (b *QueryBuilder) Build() *Query
func (*QueryBuilder) Field ¶
func (b *QueryBuilder) Field(field string) *QueryBuilder
func (*QueryBuilder) FieldToken ¶
func (b *QueryBuilder) FieldToken(field, token string) *QueryBuilder
func (*QueryBuilder) Match ¶
func (b *QueryBuilder) Match(expression BloomExpression) *QueryBuilder
func (*QueryBuilder) MatchPrefilter ¶
func (b *QueryBuilder) MatchPrefilter(expression PrefilterExpression) *QueryBuilder
Prefilter methods
func (*QueryBuilder) Token ¶
func (b *QueryBuilder) Token(token string) *QueryBuilder
type QueryOperator ¶
type QueryOperator string
QueryOperator represents the type of comparison operation
const ( // Equality operators OpEqual QueryOperator = "EQ" OpNotEqual QueryOperator = "NE" // Comparison operators OpGreaterThan QueryOperator = "GT" OpGreaterThanEqual QueryOperator = "GTE" OpLessThan QueryOperator = "LT" OpLessThanEqual QueryOperator = "LTE" // Set operators OpIn QueryOperator = "IN" OpNotIn QueryOperator = "NOT_IN" // Range operators OpBetween QueryOperator = "BETWEEN" OpNotBetween QueryOperator = "NOT_BETWEEN" )
type QueryPrefilter ¶
type QueryPrefilter struct {
Expression *PrefilterExpression `json:",omitempty"`
}
QueryPrefilter represents prefilter conditions against partition IDs and minmax indexes. Expressions can be combined arbitrarily with AND/OR using PrefilterAnd and PrefilterOr.
func NewQueryPrefilter ¶
func NewQueryPrefilter() *QueryPrefilter
type StringCondition ¶
type StringCondition struct {
Operator QueryOperator `json:",omitempty"` // for EQ, NE, GT, GTE, LT, LTE
Value string `json:",omitempty"` // for EQ, NE, GT, GTE, LT, LTE
Values []string `json:",omitempty"` // for IN, NOT_IN
Min string `json:",omitempty"` // for BETWEEN, NOT_BETWEEN
Max string `json:",omitempty"` // for BETWEEN, NOT_BETWEEN
}
StringCondition represents a condition on string values (like partition IDs)
func PartitionBetween ¶
func PartitionBetween(min, max string) StringCondition
PartitionBetween creates a partition BETWEEN condition (inclusive)
func PartitionEquals ¶
func PartitionEquals(value string) StringCondition
PartitionEquals creates a partition equality condition
func PartitionGreaterThan ¶
func PartitionGreaterThan(value string) StringCondition
PartitionGreaterThan creates a partition greater than condition
func PartitionGreaterThanEqual ¶
func PartitionGreaterThanEqual(value string) StringCondition
PartitionGreaterThanEqual creates a partition greater than or equal condition
func PartitionIn ¶
func PartitionIn(values ...string) StringCondition
PartitionIn creates a partition IN condition
func PartitionLessThan ¶
func PartitionLessThan(value string) StringCondition
PartitionLessThan creates a partition less than condition
func PartitionLessThanEqual ¶
func PartitionLessThanEqual(value string) StringCondition
PartitionLessThanEqual creates a partition less than or equal condition
func PartitionNotBetween ¶
func PartitionNotBetween(min, max string) StringCondition
PartitionNotBetween creates a partition NOT BETWEEN condition (exclusive)
func PartitionNotEquals ¶
func PartitionNotEquals(value string) StringCondition
PartitionNotEquals creates a partition not equal condition
func PartitionNotIn ¶
func PartitionNotIn(values ...string) StringCondition
PartitionNotIn creates a partition NOT IN condition
type ValueTokenizerFunc ¶
ValueTokenizerFunc is a function that tokenizes a field value into a list of tokens
type WriteOperation ¶
type WriteOperation struct {
FileMetadata *FileMetadata
FilePointerBytes []byte
}