Skip to content

Commit

Permalink
Remove firestore and memory cache (#26)
Browse files Browse the repository at this point in the history
* Remove firestore and memory cache

* Increase word list buffer
  • Loading branch information
mpppk committed Dec 21, 2019
1 parent 7da8b39 commit a53af24
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
5 changes: 2 additions & 3 deletions cmd/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ var genCmd = &cobra.Command{
panic("invalid storage type: " + config.Storage)
}

memoryStorage := storage.NewMemoryWithOtherStorage(store)
iroha := lib.NewIroha(words, memoryStorage, config.DepthOptions)
iroha := lib.NewIroha(words, store, config.DepthOptions)

if config.ResetProgress {
log.Println("progress is reset")
if err := memoryStorage.ResetProgress(ctx); err != nil {
if err := store.ResetProgress(ctx); err != nil {
panic(err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/iroha.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (i *Iroha) searchByBits(usedIndices []int, katakanaBitsAndWords []*ktkn.Kat
goroutineMode := depth >= i.depths.MinParallel && depth <= i.depths.MaxParallel
if goroutineMode {
eg := errgroup.Group{}
wordListChan := make(chan []*ktkn.Word, 100)
wordListChan := make(chan []*ktkn.Word, 1000000)
for index, word := range katakanaAndWordBits.Words {
gWord := word
newIndices := generateNewUsedIndices(usedIndices, index)
Expand Down
25 changes: 1 addition & 24 deletions storage/firestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"reflect"
"time"

cstorage "cloud.google.com/go/storage"

Expand Down Expand Up @@ -100,7 +99,7 @@ func (f *FireStore) removeProgressByState(ctx context.Context, progress int) err
}

func (f *FireStore) Start(ctx context.Context, indices []int) error {
return f.updateProgress(ctx, indices, progressProcessing)
return nil
}

func (f *FireStore) ResetProgress(ctx context.Context) error {
Expand All @@ -125,31 +124,9 @@ func (f *FireStore) Set(ctx context.Context, indices []int, wordsList [][]*ktkn.
if err := f.cstorageClient.SaveWordsList(ctx, indices, wordsList); err != nil {
return errors.Wrap(err, "failed to set wordsList to cloud storage")
}
if err := f.updateProgress(ctx, indices, progressDone); err != nil {
return errors.Wrap(err, "failed to update progress to done")
}

return nil
}

func (f *FireStore) Get(ctx context.Context, indices []int) ([][]*ktkn.Word, bool, error) {
L:
for {
// FIXME: watch document
progress, err := f.getProgress(ctx, indices)
if err != nil {
return nil, false, err
}

switch progress {
case progressNotStarted:
return nil, false, nil
case progressDone:
break L
case progressProcessing:
time.Sleep(500 * time.Millisecond)
}
}

return f.cstorageClient.Get(ctx, indices)
}

0 comments on commit a53af24

Please sign in to comment.