Skip to content

Commit

Permalink
Revert "Recsplit: cancelable build (ledgerwatch#1073)"
Browse files Browse the repository at this point in the history
This reverts commit a48a2fc.
  • Loading branch information
pratikspatil024 authored Aug 18, 2023
1 parent f808b89 commit b378ae5
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 21 deletions.
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.54
version: v1.53

- 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://github.com/raw/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(GOBIN)" v1.54.0
curl -sSfL https://github.com/raw/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(GOBIN)" v1.53.3

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

import (
"bufio"
"context"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -48,7 +47,7 @@ func TestReWriteIndex(t *testing.T) {
t.Fatal(err)
}
}
if err := rs.Build(context.Background()); err != nil {
if err := rs.Build(); 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,7 +18,6 @@ package recsplit

import (
"bufio"
"context"
"crypto/rand"
"encoding/binary"
"fmt"
Expand Down Expand Up @@ -535,7 +534,8 @@ 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(ctx context.Context) error {
func (rs *RecSplit) Build() error {

if rs.built {
return fmt.Errorf("already built")
}
Expand Down Expand Up @@ -570,7 +570,7 @@ func (rs *RecSplit) Build(ctx context.Context) 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{Quit: ctx.Done()}); err != nil {
if err := rs.bucketCollector.Load(nil, "", rs.loadFuncBucket, etl.TransformArgs{}); err != nil {
return err
}
if len(rs.currentBucket) > 0 {
Expand Down
3 changes: 1 addition & 2 deletions recsplit/recsplit_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ limitations under the License.
package recsplit

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

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

import (
"context"
"fmt"
"path/filepath"
"testing"
Expand All @@ -42,16 +41,16 @@ func TestRecSplit2(t *testing.T) {
if err = rs.AddKey([]byte("first_key"), 0); err != nil {
t.Error(err)
}
if err = rs.Build(context.Background()); err == nil {
if err = rs.Build(); 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(context.Background()); err != nil {
if err = rs.Build(); err != nil {
t.Error(err)
}
if err = rs.Build(context.Background()); err == nil {
if err = rs.Build(); 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 @@ -79,7 +78,7 @@ func TestRecSplitDuplicate(t *testing.T) {
if err := rs.AddKey([]byte("first_key"), 0); err != nil {
t.Error(err)
}
if err := rs.Build(context.Background()); err == nil {
if err := rs.Build(); err == nil {
t.Errorf("test is expected to fail, duplicate key")
}
}
Expand Down Expand Up @@ -120,7 +119,7 @@ func TestIndexLookup(t *testing.T) {
t.Fatal(err)
}
}
if err := rs.Build(context.Background()); err != nil {
if err := rs.Build(); err != nil {
t.Fatal(err)
}
idx := MustOpen(indexFile)
Expand Down Expand Up @@ -155,7 +154,7 @@ func TestTwoLayerIndex(t *testing.T) {
t.Fatal(err)
}
}
if err := rs.Build(context.Background()); err != nil {
if err := rs.Build(); 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(ctx); err != nil {
if err = rs.Build(); 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(ctx); err != nil {
if err = rs.Build(); 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(ctx); err != nil {
if err = rs.Build(); 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(ctx); err != nil {
if err = rs.Build(); 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(ctx); err != nil {
if err = rs.Build(); err != nil {
if rs.Collision() {
log.Info("Building recsplit. Collision happened. It's ok. Restarting...")
rs.ResetNextSalt()
Expand Down

0 comments on commit b378ae5

Please sign in to comment.