Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
if: matrix.os == 'ubuntu-20.04'
uses: golangci/golangci-lint-action@v3
with:
version: v1.53
version: v1.54

- name: Test win
if: matrix.os == 'windows-2022'
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ lintci-deps-clean: golangci-lint-clean

# download and build golangci-lint (https://golangci-lint.run)
$(GOBINREL)/golangci-lint: | $(GOBINREL)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(GOBIN)" v1.53.3
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(GOBIN)" v1.54.0

golangci-lint-clean:
rm -f "$(GOBIN)/golangci-lint"
Expand Down
3 changes: 2 additions & 1 deletion recsplit/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package recsplit

import (
"bufio"
"context"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -47,7 +48,7 @@ func TestReWriteIndex(t *testing.T) {
t.Fatal(err)
}
}
if err := rs.Build(); err != nil {
if err := rs.Build(context.Background()); err != nil {
t.Fatal(err)
}
idx := MustOpen(indexFile)
Expand Down
6 changes: 3 additions & 3 deletions recsplit/recsplit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package recsplit

import (
"bufio"
"context"
"crypto/rand"
"encoding/binary"
"fmt"
Expand Down Expand Up @@ -534,8 +535,7 @@ func (rs *RecSplit) loadFuncOffset(k, _ []byte, _ etl.CurrentTableReader, _ etl.

// Build has to be called after all the keys have been added, and it initiates the process
// of building the perfect hash function and writing index into a file
func (rs *RecSplit) Build() error {

func (rs *RecSplit) Build(ctx context.Context) error {
if rs.built {
return fmt.Errorf("already built")
}
Expand Down Expand Up @@ -570,7 +570,7 @@ func (rs *RecSplit) Build() error {
if rs.lvl < log.LvlTrace {
log.Log(rs.lvl, "[index] calculating", "file", rs.indexFileName)
}
if err := rs.bucketCollector.Load(nil, "", rs.loadFuncBucket, etl.TransformArgs{}); err != nil {
if err := rs.bucketCollector.Load(nil, "", rs.loadFuncBucket, etl.TransformArgs{Quit: ctx.Done()}); err != nil {
return err
}
if len(rs.currentBucket) > 0 {
Expand Down
3 changes: 2 additions & 1 deletion recsplit/recsplit_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package recsplit

import (
"context"
"path/filepath"
"testing"

Expand Down Expand Up @@ -73,7 +74,7 @@ func FuzzRecSplit(f *testing.F) {
if err := rs.AddKey(in[i:], off); err != nil {
t.Fatal(err)
}
if err = rs.Build(); err != nil {
if err = rs.Build(context.Background()); err != nil {
t.Fatal(err)
}
// Check that there is a bijection
Expand Down
13 changes: 7 additions & 6 deletions recsplit/recsplit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package recsplit

import (
"context"
"fmt"
"path/filepath"
"testing"
Expand All @@ -41,16 +42,16 @@ func TestRecSplit2(t *testing.T) {
if err = rs.AddKey([]byte("first_key"), 0); err != nil {
t.Error(err)
}
if err = rs.Build(); err == nil {
if err = rs.Build(context.Background()); err == nil {
t.Errorf("test is expected to fail, too few keys added")
}
if err = rs.AddKey([]byte("second_key"), 0); err != nil {
t.Error(err)
}
if err = rs.Build(); err != nil {
if err = rs.Build(context.Background()); err != nil {
t.Error(err)
}
if err = rs.Build(); err == nil {
if err = rs.Build(context.Background()); err == nil {
t.Errorf("test is expected to fail, hash gunction was built already")
}
if err = rs.AddKey([]byte("key_to_fail"), 0); err == nil {
Expand Down Expand Up @@ -78,7 +79,7 @@ func TestRecSplitDuplicate(t *testing.T) {
if err := rs.AddKey([]byte("first_key"), 0); err != nil {
t.Error(err)
}
if err := rs.Build(); err == nil {
if err := rs.Build(context.Background()); err == nil {
t.Errorf("test is expected to fail, duplicate key")
}
}
Expand Down Expand Up @@ -119,7 +120,7 @@ func TestIndexLookup(t *testing.T) {
t.Fatal(err)
}
}
if err := rs.Build(); err != nil {
if err := rs.Build(context.Background()); err != nil {
t.Fatal(err)
}
idx := MustOpen(indexFile)
Expand Down Expand Up @@ -154,7 +155,7 @@ func TestTwoLayerIndex(t *testing.T) {
t.Fatal(err)
}
}
if err := rs.Build(); err != nil {
if err := rs.Build(context.Background()); err != nil {
t.Fatal(err)
}

Expand Down
2 changes: 1 addition & 1 deletion state/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ func buildIndex(ctx context.Context, d *compress.Decompressor, idxPath, tmpdir s

p.Processed.Add(1)
}
if err = rs.Build(); err != nil {
if err = rs.Build(ctx); err != nil {
if rs.Collision() {
logger.Info("Building recsplit. Collision happened. It's ok. Restarting...")
rs.ResetNextSalt()
Expand Down
4 changes: 2 additions & 2 deletions state/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func buildVi(ctx context.Context, historyItem, iiItem *filesItem, historyIdxPath

p.Processed.Add(1)
}
if err = rs.Build(); err != nil {
if err = rs.Build(ctx); err != nil {
if rs.Collision() {
logger.Info("Building recsplit. Collision happened. It's ok. Restarting...")
rs.ResetNextSalt()
Expand Down Expand Up @@ -940,7 +940,7 @@ func (h *History) buildFiles(ctx context.Context, step uint64, collation History
valOffset, _ = g.Skip()
}
}
if err = rs.Build(); err != nil {
if err = rs.Build(ctx); err != nil {
if rs.Collision() {
log.Info("Building recsplit. Collision happened. It's ok. Restarting...")
rs.ResetNextSalt()
Expand Down
2 changes: 1 addition & 1 deletion state/locality_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (li *LocalityIndex) buildFiles(ctx context.Context, ic *InvertedIndexContex
return nil, err
}

if err = rs.Build(); err != nil {
if err = rs.Build(ctx); err != nil {
if rs.Collision() {
li.logger.Debug("Building recsplit. Collision happened. It's ok. Restarting...")
rs.ResetNextSalt()
Expand Down
2 changes: 1 addition & 1 deletion state/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ func (h *History) mergeFiles(ctx context.Context, indexFiles, historyFiles []*fi
}
p.Processed.Add(1)
}
if err = rs.Build(); err != nil {
if err = rs.Build(ctx); err != nil {
if rs.Collision() {
log.Info("Building recsplit. Collision happened. It's ok. Restarting...")
rs.ResetNextSalt()
Expand Down