mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
make chksum process All() results correctly for unkeyed indexes
This commit is contained in:
parent
ea267202bd
commit
53373240ef
3 changed files with 17 additions and 9 deletions
|
|
@ -183,12 +183,17 @@ func (cmd *BackupCommand) backupIDAllocData(ctx context.Context) error {
|
|||
func (cmd *BackupCommand) backupIndexTranslation(ctx context.Context, ii *pilosa.IndexInfo) error {
|
||||
logger := cmd.Logger()
|
||||
logger.Printf("backing up index translation: %q", ii.Name)
|
||||
if err := cmd.backupIndexTranslateData(ctx, ii.Name); err != nil {
|
||||
return err
|
||||
if ii.Options.Keys {
|
||||
if err := cmd.backupIndexTranslateData(ctx, ii.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Back up field translation data.
|
||||
for _, fi := range ii.Fields {
|
||||
if !fi.Options.Keys {
|
||||
continue
|
||||
}
|
||||
if err := cmd.backupFieldTranslateData(ctx, ii.Name, fi.Name); err != nil {
|
||||
return fmt.Errorf("cannot backup field translation data for field %q on index %q: %w", fi.Name, ii.Name, err)
|
||||
}
|
||||
|
|
@ -346,9 +351,7 @@ func (cmd *BackupCommand) backupFieldTranslateData(ctx context.Context, indexNam
|
|||
logger.Printf("backing up field translation data: %s/%s", indexName, fieldName)
|
||||
|
||||
rc, err := cmd.client.FieldTranslateDataReader(ctx, indexName, fieldName)
|
||||
if err == pilosa.ErrTranslateStoreNotFound {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
if err != nil {
|
||||
return fmt.Errorf("fetching translate data reader: %w", err)
|
||||
}
|
||||
defer rc.Close()
|
||||
|
|
|
|||
|
|
@ -66,9 +66,14 @@ func (cmd *ChkSumCommand) Run(ctx context.Context) (err error) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
all := rs.Results[0]
|
||||
as := fmt.Sprintf("all=%v", all)
|
||||
_, _ = h.Write([]byte(as))
|
||||
|
||||
all := rs.Results[0].(*pilosa.Row)
|
||||
if len(all.Keys) > 0 {
|
||||
allString := fmt.Sprintf("%v", all.Keys)
|
||||
_, _ = h.Write([]byte(allString))
|
||||
} else {
|
||||
_, _ = h.Write(all.Roaring())
|
||||
}
|
||||
|
||||
for _, field := range ii.Fields {
|
||||
switch field.Options.Type {
|
||||
|
|
|
|||
|
|
@ -7053,7 +7053,7 @@ func backupTest(t *testing.T, c *test.Cluster, index string) {
|
|||
sumNew := chkSumCluster(t, cnew)
|
||||
|
||||
if sum != sumNew {
|
||||
t.Fatalf("old/new checksum mismatch, old:\n%s\nnew:\n:%s", sum, sumNew)
|
||||
t.Fatalf("old/new checksum mismatch, old:\n%s\nnew:\n%s", sum, sumNew)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue