/** * {@inheritDoc} */ public void close() { objectStore.close(); if (indexStoreReader != null) { indexStoreReader.close(); indexStoreReader = null; } indexStore.close(); } }
/** * Returns an iterator for reading objects from the underlying data store. * * @return An iterator for reading objects from the data store. This * iterator must be released after use. */ public ReleasableIterator<T> iterate() { return iterate(0, -1); }
/** * Stops the current writing operation and begins a new one saving the * current position against a new interval index. */ public void closeChunk() { // We can only close a chunk if one is in progress. if (chunkInProgress) { // Create an interval in the underlying object store and note the // current position. newChunkFilePosition = objectStore.closeChunk(); // Flag that no chunk is in progress so that the next add will store // the start file index. chunkInProgress = false; // Write then reset the object count of the current chunk. indexStore.write(new LongLongIndexElement((chunkCount * 2) + 1, chunkObjectCount)); chunkObjectCount = 0; // Increment the chunk count. chunkCount++; } }
/** * Adds the specified object to the store. * * @param data * The object to be added. */ public void add(T data) { objectStore.add(data); chunkObjectCount++; if (!chunkInProgress) { // Write the file index of the new chunk. indexStore.write(new LongLongIndexElement((chunkCount * 2), newChunkFilePosition)); chunkInProgress = true; } }
String indexFilePrefix, boolean useCompression) { objectStore = new SegmentedObjectStore<T>(serializationFactory, storageFilePrefix, useCompression);
ObjectReader objectReader; if (!initializeIteratingStage()) { return new EmptyIterator<T>();
/** * Stops the current writing operation and begins a new one saving the * current position against a new interval index. */ public void closeChunk() { // We can only close a chunk if one is in progress. if (chunkInProgress) { // Create an interval in the underlying object store and note the // current position. newChunkFilePosition = objectStore.closeChunk(); // Flag that no chunk is in progress so that the next add will store // the start file index. chunkInProgress = false; // Write then reset the object count of the current chunk. indexStore.write(new LongLongIndexElement((chunkCount * 2) + 1, chunkObjectCount)); chunkObjectCount = 0; // Increment the chunk count. chunkCount++; } }
/** * Adds the specified object to the store. * * @param data * The object to be added. */ public void add(T data) { objectStore.add(data); chunkObjectCount++; if (!chunkInProgress) { // Write the file index of the new chunk. indexStore.write(new LongLongIndexElement((chunkCount * 2), newChunkFilePosition)); chunkInProgress = true; } }
String indexFilePrefix, boolean useCompression) { objectStore = new SegmentedObjectStore<T>(serializationFactory, storageFilePrefix, useCompression);
ObjectReader objectReader; if (!initializeIteratingStage()) { return new EmptyIterator<T>();
/** * Returns an iterator for reading objects from the underlying data store. * * @return An iterator for reading objects from the data store. This * iterator must be released after use. */ public ReleasableIterator<T> iterate() { return iterate(0, -1); }
/** * {@inheritDoc} */ public void close() { objectStore.close(); if (indexStoreReader != null) { indexStoreReader.close(); indexStoreReader = null; } indexStore.close(); } }
/** * Provides access to the contents of this store. * * @param chunk * The chunk to read objects from. * @return An iterator providing access to contents of the store. */ public ReleasableIterator<T> iterate(long chunk) { complete(); if (indexStoreReader == null) { indexStoreReader = indexStore.createReader(); } // Retrieve the file position and number of objects for the specified // chunk and iterate. return objectStore.iterate( indexStoreReader.get(chunk * 2).getValue(), indexStoreReader.get(chunk * 2 + 1).getValue() ); }
/** * Provides access to the contents of this store. * * @param chunk * The chunk to read objects from. * @return An iterator providing access to contents of the store. */ public ReleasableIterator<T> iterate(long chunk) { complete(); if (indexStoreReader == null) { indexStoreReader = indexStore.createReader(); } // Retrieve the file position and number of objects for the specified // chunk and iterate. return objectStore.iterate( indexStoreReader.get(chunk * 2).getValue(), indexStoreReader.get(chunk * 2 + 1).getValue() ); }