Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.storemate.store;
  
  
  
Simple abstraction for storing "decorated BLOBs", with a single secondary index that can be used for traversing entries by "last modified" time.
 
 public abstract class StorableStore
 {
     /*
     /**********************************************************************
     /* Life-cycle methods
     /**********************************************************************
      */
 
     public abstract void start();
     
     public abstract void stop();
     
     /*
     /**********************************************************************
     /* API, simple accessors for state, helper objects
     /**********************************************************************
      */
 
     public abstract boolean isClosed();
 
     public abstract FileManager getFileManager();
 
     public abstract TimeMaster getTimeMaster();
     
     /*
     /**********************************************************************
     /* API, store metadata access
     /**********************************************************************
      */

    
Accessor for getting approximate count of entries in the underlying main BDB database
 
     public abstract long getEntryCount();

    
Accessor for getting approximate count of entries accessible via last-modifed index.
 
     public abstract long getIndexedCount();

    
Method that can be called to find if there are write operations in-flight, and if so, find the oldest associated timestamp (minimum of all timestamps to be used as last-modified values) and return it. This can be used to calculate high-water marks for traversing last-modified index (to avoid accessing things modified after start of traversal). Note that this only establishes conservative lower bound: due to race condition, the oldest operation may finish before this method returns.

Returns:
Timestamp of the "oldest" write operation still being performed, if any, or 0L if none
 
     public abstract long getOldestInFlightTimestamp();
     
     /*
     /**********************************************************************
     /* API, data reads
     /**********************************************************************
      */

    
Method that can be called to quickly see if there is an entry for given key at this point. Note that soft deletions leave "tombstones", so soft-deleted entries may return true from this method.
 
     public abstract boolean hasEntry(StorableKey keythrows StoreException;

    
Accessor for getting entry for given key; this includes soft-deleted entries ("tombstones") that have not yet been hard deleted (which typically is done with some delay).
 
     public abstract Storable findEntry(StorableKey keythrows StoreException;
 
     /*
     /**********************************************************************
     /* API, entry creation
     /**********************************************************************
      */
    
    
Method for inserting entry, if and only if no entry exists for given key.

Parameters:
input Input stream used for reading the content. NOTE: method never closes this stream
    public abstract StorableCreationResult insert(StorableKey keyInputStream input,
            StorableCreationMetadata stdMetadataByteContainer customMetadata)
        throws IOExceptionStoreException;

    
Method for inserting entry, if and only if no entry exists for given key.

Parameters:
input Input data to store (usually inlined)
    public abstract StorableCreationResult insert(StorableKey keyByteContainer input,
            StorableCreationMetadata stdMetadataByteContainer customMetadata)
        throws IOExceptionStoreException;

    
Method for inserting entry, if no entry exists for the key, or updating entry if one does. In case of update, results will contain information about overwritten entry.

Parameters:
input Input stream used for reading the content. NOTE: method never closes this stream
removeOldDataFile Whether method should delete backing data file for the existing entry (if one was found) or not.
    public abstract StorableCreationResult upsert(StorableKey keyInputStream input,
            StorableCreationMetadata stdMetadataByteContainer customMetadata,
            boolean removeOldDataFile)
        throws IOExceptionStoreException;

    
Method for inserting entry, if no entry exists for the key, or updating entry if one does. In case of update, results will contain information about overwritten entry.

Parameters:
input Payload to store with entry
removeOldDataFile Whether method should delete backing data file for the existing entry (if one was found) or not.
    public abstract StorableCreationResult upsert(StorableKey keyByteContainer input,
            StorableCreationMetadata stdMetadataByteContainer customMetadata,
            boolean removeOldDataFile)
        throws IOExceptionStoreException;

    
Method for inserting an entry, or possibly updating existing entry; latter depending in result of a callback caller passes, which lets it determine whether update should proceed.

Parameters:
input Payload to store with entry
removeOldDataFile Whether method should delete backing data file for the existing entry (if one was found) or not.
checker Object that is called if overwriting of content is necessary, to check whether update is allowed.
Since:
0.9.3
    public abstract StorableCreationResult upsertConditionally(StorableKey keyInputStream input,
            StorableCreationMetadata stdMetadataByteContainer customMetadata,
            boolean removeOldDataFileOverwriteChecker checker)
        throws IOExceptionStoreException;

    
Method for inserting an entry, or possibly updating existing entry; latter depending in result of a callback caller passes, which lets it determine whether update should proceed.

Parameters:
input Payload to store with entry
removeOldDataFile Whether method should delete backing data file for the existing entry (if one was found) or not.
checker Object that is called if overwriting of content is necessary, to check whether update is allowed.
Since:
0.9.3
            StorableCreationMetadata stdMetadataByteContainer customMetadata,
            boolean removeOldDataFileOverwriteChecker checker)
        throws IOExceptionStoreException;
    
    /*
    /**********************************************************************
    /* API, entry deletion
    /**********************************************************************
     */

    
Operation that will try to mark given entry as "tombstone", to indicate logical deletion, but without deleting entry metadata. This is often necessary to ensure that deletes are properly propagated, similar to how insertions are. Note that entry data may be deleted, depending on arguments.

Parameters:
key Key of entry to soft delete
removeInlinedData Whether operation should remove inlined data, if entry has any
removeExternalData Whether operation should remove external data, if entry has any.
Returns:
Status of the operation, including state of entry after changes specified have been made.
    public abstract StorableDeletionResult softDelete(StorableKey key,
            final boolean removeInlinedDatafinal boolean removeExternalData)
        throws IOExceptionStoreException;
    
    
Operation that will try to physical delete entry matching given key. It may also remove related external data, depending on arguments.

Parameters:
key Key of entry to soft delete
removeExternalData Whether operation should remove external data, if entry has any.
Returns:
Status of the operation, including state of entry after changes specified have been made.
    public abstract StorableDeletionResult hardDelete(StorableKey key,
            final boolean removeExternalData)
        throws IOExceptionStoreException;
    /*
    /**********************************************************************
    /* API, iteration
    /**********************************************************************
     */

    
Method for iterating over entries store has, in key order, starting with specified key (inclusive).

Note that iteration is not transactional, in that operations may modify entries during iteration process.

Parameters:
cb Callback used for actual iteration
firstKey (optional) If not null, key for the first entry to include (inclusive); if null, starts from the very first entry
Returns:
Value that indicates how iteration ended
            StorableKey firstKey)
        throws StoreException;

    
Method for iterating over entries store has, in key order, starting with entry AFTER specified key.

Note that iteration is not transactional, in that operations may modify entries during iteration process.

Parameters:
cb Callback used for actual iteration
firstKey (optional) If not null, key for the first entry to include (inclusive); if null, starts from the very first entry
Returns:
Value that indicates how iteration ended
            StorableKey firstKey)
        throws StoreException;
    
    
Method for iterating over entries store has, in key order, starting with specified key (inclusive).

Note that iteration is not transactional, in that operations may modify entries during iteration process.

Parameters:
cb Callback used for actual iteration
firstTimestamp (optional) Last-modified timestamp of the first entry to include (inclusive).
Returns:
True if iteration completed successfully; false if it was terminated
            long firstTimestamp)
        throws StoreException;
New to GrepCode? Check out our FAQ X