Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .seqbench/baseline.env
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
GOGC=100

SEQDB_RESOURCES_SKIP_FSYNC=true

SEQDB_STORAGE_FRAC_SIZE=1MiB
SEQDB_STORAGE_TOTAL_SIZE=10GiB

SEQDB_COMPACTION_ENABLED=true
SEQDB_COMPACTION_ENABLED=false
SEQDB_COMPACTION_WORKERS=4
SEQDB_COMPACTION_TIME_WINDOW=1h
SEQDB_COMPACTION_TICK_INTERVAL=1s
Expand Down
4 changes: 3 additions & 1 deletion .seqbench/comparison.env
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
GOGC=100

SEQDB_RESOURCES_SKIP_FSYNC=true

SEQDB_STORAGE_FRAC_SIZE=1MiB
SEQDB_STORAGE_TOTAL_SIZE=10GiB

SEQDB_COMPACTION_ENABLED=true
SEQDB_COMPACTION_ENABLED=false
SEQDB_COMPACTION_WORKERS=4
SEQDB_COMPACTION_TIME_WINDOW=1h
SEQDB_COMPACTION_TICK_INTERVAL=1s
Expand Down
4 changes: 4 additions & 0 deletions frac/active_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ func (si *activeTokenIndex) GetValByTID(tid uint32, field string) []byte {
return si.tokenList.GetValByTID(tid, field)
}

func (si *activeTokenIndex) GetTIDsByField(field string) ([]uint32, error) {
return si.tokenList.GetTIDsByField(field), nil
}

func (si *activeTokenIndex) GetTIDsByTokenExpr(t parser.Token) ([]uint32, error) {
return si.tokenList.FindPattern(si.ctx, t)
}
Expand Down
8 changes: 5 additions & 3 deletions frac/processor/eval_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,13 @@ func iteratorFromLiteral(
iteratorLimit iteratorLimit,
order seq.DocsOrder,
) (*SourcedNodeIterator, error) {
m := sw.Start("get_tids_by_token_expr")
tids, err := ti.GetTIDsByTokenExpr(literal)
m := sw.Start("get_tids_by_field")
// For aggregations we can receive the first and the last TID for field,
// because we build tree over *all* token values.
tids, err := ti.GetTIDsByField(literal.Field)
m.Stop()
if err != nil {
return nil, fmt.Errorf("getting TIDs by token expression: %s", err)
return nil, fmt.Errorf("getting TIDs for field %q: %s", literal.Field, err)
}

if len(tids) > maxTIDs && maxTIDs > 0 {
Expand Down
1 change: 1 addition & 0 deletions frac/processor/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type idsIndex interface {

type tokenIndex interface {
GetValByTID(tid uint32, field string) []byte
GetTIDsByField(field string) ([]uint32, error)
GetTIDsByTokenExpr(token parser.Token) ([]uint32, error)
GetLIDsFromTIDs(tids []uint32, stats lids.Counter, minLID, maxLID uint32, order seq.DocsOrder) []node.Node
}
Expand Down
19 changes: 19 additions & 0 deletions frac/sealed_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,25 @@ func (ti *sealedTokenIndex) GetValByTID(tid uint32, field string) []byte {
return nil
}

func (ti *sealedTokenIndex) GetTIDsByField(field string) ([]uint32, error) {
table := ti.tokenTableLoader.Load()

entries := table.SelectEntries(field, "")
if len(entries) == 0 {
return nil, nil
}

first := entries[0].StartTID
last := entries[len(entries)-1].GetLastTID()

tids := make([]uint32, (last-first)+1)
for i := range tids {
tids[i] = first + uint32(i)
}

return tids, nil
}

func (ti *sealedTokenIndex) GetTIDsByTokenExpr(t parser.Token) ([]uint32, error) {
field := parser.GetField(t)
searchStr := parser.GetHint(t)
Expand Down
Loading