private static Object[] deserializeArrayObject(DataInputStream is) throws IOException, ClassNotFoundException { int size =LongPacker.unpackInt(is); Object[] s = new Object[size]; for(int i = 0; i<size;i++) s[i] = readObject(is); return s; }
@Override public boolean available() { return tuple.getKey() != null; }
private void prefetch() throws IOException { if ( stepForward ) { success = browser.getNext( jdbmTuple ); } else { success = browser.getPrevious( jdbmTuple ); } }
/** * Creates a soft-reference based L2 cache with a {@link MRU} cache as * the internal (L1) cache. The soft reference cache uses the * default load capacity of 1.5f, which is intended to sacrifice some * performance for space. This compromise is reasonable, since all * {@link #get(Object) get( )s} first try the L1 cache anyway. The * internal MRU is given a capacity of 128 elements. */ public SoftCache() { this( new MRU( INITIAL_CAPACITY ) ); }
/** * Adds the specified listener to this cache. Note that the events * fired by this correspond to the <em>internal</em> cache's events. * @param listener the (non-null) listener to add to this policy * @throws IllegalArgumentException if listener is null. */ public void addListener( CachePolicyListener listener ) throws IllegalArgumentException { internal.addListener( listener ); }
/** * Gets the value * @return the value; null if it is no longer accessible */ final Object getValue() { return this.get(); } }
/** * Gets all the objects stored by the internal (L1) cache. * @return an enumeration of objects in internal cache. */ public Enumeration elements() { return _internal.elements(); }
/** * Removes a listener that was added earlier. * @param listener the listener to remove. */ public void removeListener( CachePolicyListener listener ) { internal.removeListener( listener ); }
/** * Serialize the content of an object into a byte array. * * @param obj Object to serialize * @return a byte array representing the object's state */ public byte[] serialize( Object obj ) throws IOException { return Serialization.serialize( obj ); }
/** * Convert a long into a byte array. */ public static byte[] convertToByteArray( long n ) { n = ( n ^ 0x8000000000000000L ); // flip MSB because "long" is signed byte[] key = new byte[8]; pack8( key, 0, n ); return key; }
/** * Convert a short into a byte array. */ public static byte[] convertToByteArray( short n ) { n = (short) ( n ^ ( (short) 0x8000 ) ); // flip MSB because "short" is signed byte[] key = new byte[ 2 ]; pack2( key, 0, n ); return key; }
/** * Convert a byte array into an integer (signed 32-bit) value. */ public static int convertToInt( byte[] buf ) { int value = unpack4( buf, 0 ); value = ( value ^ 0x80000000 ); // flip MSB because "int" is signed return value; }
private static StoreReference deserializeStoreReference(DataInputStream is) throws IOException { StoreReference r = new StoreReference(); r.readExternal(is); return r; }
@SuppressWarnings("unchecked") public <A extends Comparable> SecondaryTreeMap<A, K, V> secondaryTreeMap( String objectName, SecondaryKeyExtractor<A, K, V> secondaryKeyExtractor) { return SecondaryKeyHelper.secondaryTreeMap(objectName,secondaryKeyExtractor, ComparableComparator.INSTANCE,this); }
@SuppressWarnings("unchecked") public <A extends Comparable> SecondaryTreeMap<A, K, V> secondaryTreeMapManyToOne( String objectName, SecondaryKeyExtractor<Iterable<A>, K, V> secondaryKeyExtractor) { return SecondaryKeyHelper.secondarySortedMapManyToOne(objectName,secondaryKeyExtractor, ComparableComparator.INSTANCE,this); }
private void prefetch() throws IOException { if ( doAscending ) { success = browser.getNext( jdbmTuple ); } else { success = browser.getPrevious( jdbmTuple ); } }
/** * Convert an int into a byte array. */ public static byte[] convertToByteArray( int n ) { n = (n ^ 0x80000000); // flip MSB because "int" is signed byte[] key = new byte[4]; pack4(key, 0, n); return key; }