Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
CascadingRadium committed Apr 22, 2024
1 parent 642b034 commit 5eb6899
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
32 changes: 25 additions & 7 deletions index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,15 @@ func TestBytesRead(t *testing.T) {
}
stats, _ := idx.StatsMap()["index"].(map[string]interface{})
prevBytesRead, _ := stats["num_bytes_read_at_query_time"].(uint64)
if prevBytesRead != 21639 && res.Cost == prevBytesRead {
t.Fatalf("expected bytes read for query string 21639, got %v",
prevBytesRead)

expectedBytesRead := uint64(21639)
if BleveFeatureVectorSearch {
expectedBytesRead = 22049
}

if prevBytesRead != expectedBytesRead && res.Cost == prevBytesRead {
t.Fatalf("expected bytes read for query string %v, got %v",
expectedBytesRead, prevBytesRead)
}

// subsequent queries on the same field results in lesser amount
Expand Down Expand Up @@ -553,8 +559,14 @@ func TestBytesReadStored(t *testing.T) {

stats, _ := idx.StatsMap()["index"].(map[string]interface{})
bytesRead, _ := stats["num_bytes_read_at_query_time"].(uint64)
if bytesRead != 11501 && bytesRead == res.Cost {
t.Fatalf("expected the bytes read stat to be around 11501, got %v", bytesRead)

expectedBytesRead := uint64(11501)
if BleveFeatureVectorSearch {
expectedBytesRead = 11911
}

if bytesRead != expectedBytesRead && bytesRead == res.Cost {
t.Fatalf("expected the bytes read stat to be around %v, got %v", expectedBytesRead, bytesRead)
}
prevBytesRead := bytesRead

Expand Down Expand Up @@ -624,8 +636,14 @@ func TestBytesReadStored(t *testing.T) {

stats, _ = idx1.StatsMap()["index"].(map[string]interface{})
bytesRead, _ = stats["num_bytes_read_at_query_time"].(uint64)
if bytesRead != 3687 && bytesRead == res.Cost {
t.Fatalf("expected the bytes read stat to be around 3687, got %v", bytesRead)

expectedBytesRead = uint64(3687)
if BleveFeatureVectorSearch {
expectedBytesRead = 4097
}

if bytesRead != expectedBytesRead && bytesRead == res.Cost {
t.Fatalf("expected the bytes read stat to be around %v, got %v", expectedBytesRead, bytesRead)
}
prevBytesRead = bytesRead

Expand Down
2 changes: 2 additions & 0 deletions search_knn.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (
index "github.com/blevesearch/bleve_index_api"
)

const BleveFeatureVectorSearch = true

type knnOperator string

// Must be updated only at init
Expand Down
2 changes: 2 additions & 0 deletions search_no_knn.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
index "github.com/blevesearch/bleve_index_api"
)

const BleveFeatureVectorSearch = false

// A SearchRequest describes all the parameters
// needed to search the index.
// Query is required.
Expand Down

0 comments on commit 5eb6899

Please sign in to comment.