Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.storemate.store;
  
  import java.io.File;
  
Class that represents an entry read from the backing BDB-JE store.
 
 public class Storable
 {
   
Primary key of this instance, when stored in the data store
 
     protected final StorableKey _key;
 
     protected final ByteContainer _rawEntry;
     
     /*
     /**********************************************************************
     /* Status metadata
     /**********************************************************************
      */
 
     protected final long _lastModified;
 
     protected final Compression _compression;
 
     protected final boolean _isDeleted;
     protected final boolean _isReplicated;
 
     @Override
     public String toString()
     {
         return "Storable: key="++", rawLength="+.byteLength()
                 +", compression="++", deleted="+
                 +", extPathLen="+
                 ;
     }
     
     /*
     /**********************************************************************
     /* Metadata
     /**********************************************************************
      */
     
     protected final int _metadataOffset_metadataLength;
     
     /*
     /**********************************************************************
     /* Content fields
     /**********************************************************************
      */
     
     // Murmur3/32 hash of uncompressed content, if available; 0 if not
     protected final int _contentHash;

    
Length of physical storage (inlined or offlined)
 
     protected final long _storageLength;

    
Length of data before compression, iff compression used; otherwise -1.
 
     protected final long _originalLength;
     
     protected final int _compressedHash;
 
     protected final int _externalPathLength;

    
Pointer to either inlined data, or external path
 
     protected final int _payloadOffset;
     
     /*
     /**********************************************************************
     /* Construction
     /**********************************************************************
      */
     
     public Storable(StorableKey keyByteContainer bytes,
             long lastModint statusFlags,
             Compression compint externalPathLength,
             int contentHashint compressedHashlong originalLength,
             int metadataOffsetint metadataLength,
             int payloadOffsetlong storageLength)
     {
          = key;
          = bytes;
 
         = lastMod;
         = (statusFlags & .) != 0;
         =  (statusFlags & .) != 0;
         = (comp == null) ? . : comp;
         = externalPathLength;
        
         = contentHash;
         = compressedHash;
         = originalLength;
        
         = metadataOffset;
         = metadataLength;
        
         = payloadOffset;
         = storageLength;
    }

    
"Mutant factory" used by StorableConverter when simply marking an entry as soft-deleted, without actually removing inlined or external data.
    public Storable softDeletedCopy(ByteContainer bytesboolean removeData)
    {
        // clear deleted flag, i.e. just retain replicated flag
        int statusFlags = .;
        if () {
            statusFlags |= .;
        }
        return new Storable(bytes,
                statusFlags,
                removeData ? 0 : ,
                ,
                ,
                ,
                removeData ? 0 : );
    }
    
    /*
    /**********************************************************************
    /* API, accessors, simple/boolean
    /**********************************************************************
     */
    public StorableKey getKey() { return ; }
    
    public long getLastModified() { return ; }
    public Compression getCompression() { return ; }
    public int getContentHash() { return ; }
    public int getCompressedHash() { return ; }
    
    public long getStorageLength() { return ; }
    public long getOriginalLength() { return ; }
    public int getMetadataLength() { return ; }
    public int getInlineDataLength() {
        if ( > 0L) {
            return 0;
        }
        return (int;
    }
    public boolean isDeleted() { return ; }
    
    
Method to check whether this entry was created (or last updated) by replication process; if not, it was created by directly. Exact semantics depend on surrounding context, StoreMate simply notes this setting.
    public boolean isReplicated() { return ; }
    public boolean hasInlineData() {
        return ( == 0L) && ( > 0L);
    }
    public boolean hasExternalData() {
        return ( > 0L);
    }

    
Accessor for getting length of the content, uncompressed if necessary.
    public long getActualUncompressedLength() {
        if ( != .) {
            return ;
        }
        return ;
    }
    
    /*
    /**********************************************************************
    /* API, accessors for data
    /**********************************************************************
     */
    
    public File getExternalFile(FileManager mgr)
    {
        if ( <= 0) {
            return null;
        }
        return mgr.derefenceFile(IOUtil.getAsciiString(extRef));
    }

    
Accessor for getting relative path to external data File, if one exists; or null if no external data used.
    public String getExternalFilePath()
    {
        if ( <= 0) {
            return null;
        }
    }
    
    public ByteContainer getMetadata() {
        if ( <= 0) {
            return ByteContainer.emptyContainer();
        }
        return .view();
    }
    public <T> T withMetadata(WithBytesCallback<T> cb) {
        if ( <= 0) {
            return ByteContainer.emptyContainer().withBytes(cb);
        }
        return .withBytes(cb);
    }
    public ByteContainer getInlinedData()
    {
        if ( > 0) {
            return ByteContainer.emptyContainer();
        }
        int len = (int;
        if (len <= 0) {
            return ByteContainer.emptyContainer();
        }
        return .view(len);
    }
    public <T> T withInlinedData(WithBytesCallback<T> cb)
    {
        if ( > 0) {
            return ByteContainer.emptyContainer().withBytes(cb);
        }
        int len = (int;
        if (len <= 0) {
            return ByteContainer.emptyContainer().withBytes(cb);
        }
        return .withBytes(cblen);
    }
    
    /*
    /**********************************************************************
    /* API, access to raw serialization
    /**********************************************************************
     */
    public <T> T withRaw(WithBytesCallback<T> cb) {
        return .withBytes(cb);
    }

    
Method for accessing content up to and including opaque metadata section, but without payload section.
    public <T> T withRawWithoutPayload(WithBytesCallback<T> cb) {
        final int len =  + ;
        return .withBytes(cb, 0, len);
    }
New to GrepCode? Check out our FAQ X