public class TabIndexStore extends java.lang.Object implements IndexStore, java.io.Serializable
Implements IndexStore as a serialized file for the java data and a tab-delimited file of offsets.
Use the constructor to create a new index store. Use the static factory method open() to load an existing store.
The tab-delimited file looks like:fileNumber \t offset \t id \n
| Constructor and Description |
|---|
TabIndexStore(java.io.File storeFile,
java.io.File indexFile,
java.lang.String name,
SequenceFormat format,
SequenceBuilderFactory sbFactory,
SymbolTokenization symbolParser)
Create a new TabIndexStore.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addFile(java.io.File f) |
void |
commit()
Commit the stored indices to permanent storage.
|
protected void |
commitStore() |
Index |
fetch(java.lang.String id)
Fetch an Index based upon an ID.
|
protected int |
getFileIndex(java.io.File file) |
java.util.Set |
getFiles()
Retrieve the Set of files that are currently indexed.
|
SequenceFormat |
getFormat()
Retrieve the format of the index file.
|
java.util.Set |
getIDs()
Retrieve the set of all current IDs.
|
java.lang.String |
getName()
Retrieve the name of this store.
|
SequenceBuilderFactory |
getSBFactory()
Retrieve the SequenceBuilderFactory used to build Sequence instances.
|
SymbolTokenization |
getSymbolParser()
Retrieve the symbol parser used to turn the sequence characters
into Symobl objects.
|
protected void |
initialize() |
static TabIndexStore |
open(java.io.File storeFile)
Open an existing index store.
|
void |
rollback()
Discard all uncommited changes.
|
void |
store(Index indx)
Add the Index to the store.
|
public TabIndexStore(java.io.File storeFile,
java.io.File indexFile,
java.lang.String name,
SequenceFormat format,
SequenceBuilderFactory sbFactory,
SymbolTokenization symbolParser)
throws java.io.IOException,
BioException
The store file and index file must not exist. This is to prevent you from accidentally destroying an existing index.
storeFile - the file that will be used to persist this index storeindexFile - the file that will hold the actual indeciesname - the name that will be used by the database backed by
this indexformat - the SequenceFormat for files being indexedsbFactory - the SequenceBuilderFactory used in building sequencessymbolParser - the SymbolTokenization to usejava.io.IOException - if there was a problem writing the filesBioException - if any of the parameters were not acceptablepublic static TabIndexStore open(java.io.File storeFile) throws java.io.IOException
storeFile - the File encapsulating the storejava.io.IOException - if the storeFile could not be processedpublic void store(Index indx) throws IllegalIDException, BioException
IndexStoreThis method should be transactional. If the store fails, the IndexStore should be left in its original state.
If the file of the Index is not known yet, it is the responsibility of the IndexStore to add it to the set returned by getFiles.
store in interface IndexStoreindx - the Index to addIllegalIDException - if the index has an invalid ID fieldBioException - if the store failedpublic Index fetch(java.lang.String id) throws IllegalIDException, BioException
IndexStorefetch in interface IndexStoreid - The ID of the sequence Index to retrieveIllegalIDException - if the ID couldn't be foundBioException - if the fetch fails in the underlying storage mechanismpublic void commit()
throws BioException
IndexStorecommit in interface IndexStoreBioException - if for any reason the commit failspublic void rollback()
IndexStorerollback in interface IndexStorepublic java.lang.String getName()
IndexStoregetName in interface IndexStorepublic java.util.Set getIDs()
IndexStoreThis set should either be immutable, or modifiable totally separately from the IndexStore.
getIDs in interface IndexStorepublic java.util.Set getFiles()
IndexStoregetFiles in interface IndexStorepublic SequenceFormat getFormat()
IndexStoreThis set should either be immutable, or modifiable totally separately from the IndexStore.
getFormat in interface IndexStorepublic SequenceBuilderFactory getSBFactory()
IndexStoregetSBFactory in interface IndexStorepublic SymbolTokenization getSymbolParser()
IndexStoregetSymbolParser in interface IndexStoreprotected void commitStore()
throws java.io.IOException
java.io.IOExceptionprotected void addFile(java.io.File f)
protected int getFileIndex(java.io.File file)
protected void initialize()
throws java.io.IOException
java.io.IOException