-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sstable interface for committed data (#971)
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package sstable | ||
|
||
import ( | ||
"github.com/treeverse/lakefs/catalog/rocks" | ||
) | ||
|
||
// SSTableID is an identifier for an SSTable | ||
type SSTableID string | ||
|
||
type Manager interface { | ||
// GetEntry returns the entry matching the path in the SSTable referenced by the id. | ||
// If path not found, (nil, ErrPathNotFound) is returned. | ||
GetEntry(path rocks.Path, tid SSTableID) (*rocks.Entry, error) | ||
|
||
// NewSSTableIterator takes a given SSTable and returns an EntryIterator seeked to >= "from" path | ||
NewSSTableIterator(tid SSTableID, from rocks.Path) (rocks.EntryIterator, error) | ||
|
||
// GetWriter returns a new SSTable writer instance | ||
GetWriter() (Writer, error) | ||
} | ||
|
||
// WriteResult is the result of a completed write of an SSTable | ||
type WriteResult struct { | ||
// SSTableID is the identifier for the written SSTable. | ||
// Calculated by an hash function to all paths and entries. | ||
SSTableID SSTableID | ||
|
||
// First is the Path of the first entry in the SSTable. | ||
First rocks.Path | ||
|
||
// Last is the Path of the last entry in the SSTable. | ||
Last rocks.Path | ||
|
||
// Count is the number of entries in the SSTable. | ||
Count int | ||
} | ||
|
||
// Writer is an abstraction for writing SSTables. | ||
// Written entries must be sorted by path. | ||
type Writer interface { | ||
// WriteEntry appends the given entry to the SSTable | ||
WriteEntry(path rocks.Path, entry rocks.Entry) error | ||
|
||
// Close flushes all entries to the disk and returns the WriteResult. | ||
Close() (*WriteResult, error) | ||
} |