Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CascadingRadium committed Nov 15, 2024
1 parent 0a5d3bf commit 1cc3774
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 61 deletions.
5 changes: 0 additions & 5 deletions section_inverted_text_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,6 @@ func (io *invertedIndexOpaque) writeDicts(w *CountHashWriter) (dictOffsets []uin

for fieldID, terms := range io.DictKeys {
dict := io.Dicts[fieldID]
// dict is nil if the field is excluded from inverted index
// processing, so skip it
if len(dict) == 0 {
continue
}

if cap(docTermMap) < len(io.results) {
docTermMap = make([][]byte, len(io.results))
Expand Down
15 changes: 0 additions & 15 deletions synonym_test.go

This file was deleted.

82 changes: 41 additions & 41 deletions thesaurus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func buildTestSynonymDocument(id string, collection string, terms []string, syno
}

func buildTestSegmentForThesaurus(results []index.Document) (*SegmentBase, error) {
seg, _, err := zapPlugin.newWithChunkMode(results, 1024)
seg, _, err := zapPlugin.newWithChunkMode(results, DefaultChunkMode)
return seg.(*SegmentBase), err
}

Expand Down Expand Up @@ -182,15 +182,6 @@ func createExpectedSynonymMap(input []testSynonymDefinition) map[string][]string
}

func buildSegment(testSynonymDefinitions []testSynonymDefinition) (segment.Segment, error) {
tmpDir, err := os.MkdirTemp("", "zap-")
if err != nil {
return nil, err
}

err = os.RemoveAll(tmpDir)
if err != nil {
return nil, err
}
var testSynonymDocuments []index.Document
for i, testSynonymDefinition := range testSynonymDefinitions {
testSynonymDocuments = append(testSynonymDocuments, buildTestSynonymDocument(
Expand All @@ -204,6 +195,15 @@ func buildSegment(testSynonymDefinitions []testSynonymDefinition) (segment.Segme
if err != nil {
return nil, err
}
tmpDir, err := os.MkdirTemp("", "zap-")
if err != nil {
return nil, err
}

err = os.RemoveAll(tmpDir)
if err != nil {
return nil, err
}
err = PersistSegmentBase(sb, tmpDir)
if err != nil {
return nil, err
Expand Down Expand Up @@ -327,39 +327,39 @@ func TestSynonymSegment(t *testing.T) {
}()

// // multiple segment test
// numSegs := 3
// numDocs := 5
// segData := make([][]testSynonymDefinition, numSegs)
numSegs := 3
numDocs := 5
segData := make([][]testSynonymDefinition, numSegs)

// segData[0] = make([]testSynonymDefinition, 0)
// segData[0] = testSynonymDefinitions[:2] // 2 docs
segData[0] = make([]testSynonymDefinition, 0)
segData[0] = testSynonymDefinitions[:2] // 2 docs

// segData[1] = make([]testSynonymDefinition, 0)
// segData[1] = testSynonymDefinitions[2:4] // 2 docs
segData[1] = make([]testSynonymDefinition, 0)
segData[1] = testSynonymDefinitions[2:4] // 2 docs

// segData[2] = make([]testSynonymDefinition, 0)
// segData[2] = testSynonymDefinitions[4:] // 1 doc
segData[2] = make([]testSynonymDefinition, 0)
segData[2] = testSynonymDefinitions[4:] // 1 doc

// segs := make([]segment.Segment, numSegs)
// for i, data := range segData {
// seg, err := buildSegment(data)
// if err != nil {
// t.Fatalf("error building segment: %v", err)
// }
// segs[i] = seg
// }
// drops := make([]*roaring.Bitmap, numDocs)
// for i := 0; i < numDocs; i++ {
// drops[i] = roaring.New()
// }
// err = mergeSegments(segs, drops, testSynonymDefinitions)
// if err != nil {
// t.Fatalf("error merging segments: %v", err)
// }
// for _, seg := range segs {
// cerr := seg.Close()
// if cerr != nil {
// t.Fatalf("error closing seg: %v", err)
// }
// }
segs := make([]segment.Segment, numSegs)
for i, data := range segData {
seg, err := buildSegment(data)
if err != nil {
t.Fatalf("error building segment: %v", err)
}
segs[i] = seg
}
drops := make([]*roaring.Bitmap, numDocs)
for i := 0; i < numDocs; i++ {
drops[i] = roaring.New()
}
err = mergeSegments(segs, drops, testSynonymDefinitions)
if err != nil {
t.Fatalf("error merging segments: %v", err)
}
for _, seg := range segs {
cerr := seg.Close()
if cerr != nil {
t.Fatalf("error closing seg: %v", err)
}
}
}

0 comments on commit 1cc3774

Please sign in to comment.