Skip to content

Commit

Permalink
MB-61421: Interfaces for supporting online backup of an index (#48)
Browse files Browse the repository at this point in the history
* transfer interface

* fix interface

* fix comment
  • Loading branch information
CascadingRadium authored May 14, 2024
1 parent 3681af8 commit 42a777e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions index.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ type Index interface {
StatsMap() map[string]interface{}
}

// CopyIndex is an extended index that supports copying to a new location online.
// Use the CopyReader method to obtain a reader for initiating the copy operation.
type CopyIndex interface {
Index
// Obtain a copy reader for the online copy/backup operation,
// to handle necessary bookkeeping, instead of using the regular IndexReader.
CopyReader() CopyReader
}

type IndexReader interface {
TermFieldReader(ctx context.Context, term []byte, field string, includeFreq, includeNorm, includeTermVectors bool) (TermFieldReader, error)

Expand Down Expand Up @@ -79,6 +88,15 @@ type IndexReader interface {
Close() error
}

// CopyReader is an extended index reader for backup or online copy operations, replacing the regular index reader.
type CopyReader interface {
IndexReader
// CopyTo performs an online copy or backup of the index to the specified directory.
CopyTo(d Directory) error
// CloseCopyReader must be used instead of Close() to close the copy reader.
CloseCopyReader() error
}

type IndexReaderRegexp interface {
FieldDictRegexp(field string, regex string) (FieldDict, error)
}
Expand Down

0 comments on commit 42a777e

Please sign in to comment.