From 42a777e696356b0b2d4ddcbc2b92afdeba77dcd2 Mon Sep 17 00:00:00 2001 From: Rahul Rampure Date: Tue, 14 May 2024 19:51:12 +0530 Subject: [PATCH] MB-61421: Interfaces for supporting online backup of an index (#48) * transfer interface * fix interface * fix comment --- index.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/index.go b/index.go index 4c916d5..a003556 100644 --- a/index.go +++ b/index.go @@ -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) @@ -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) }