/** * Stores a record in the cache. * * @param data * The record to store. */ public final void storeRecord(byte[] data) throws IOException { long spareSlots = maxRecords.get() - recordCount.get(); if (spareSlots > 0L) { storeRecordInternal(data); recordCount.incrementAndGet(); } else if (spareSlots == 0L) { // invalidate the cache recordCount.incrementAndGet(); } }
/** * Stores a record in the cache. * * @param data * The record to store. */ public final void storeRecord(byte[] data) throws IOException { long spareSlots = maxRecords.get() - recordCount.get(); if (spareSlots > 0L) { storeRecordInternal(data); recordCount.incrementAndGet(); } else if (spareSlots == 0L) { // invalidate the cache recordCount.incrementAndGet(); } }
/** * Stores the records from the supplied cache into this cache. * * @param otherCache * The cache to copy the records from. */ public final void storeRecords(RecordCache otherCache) throws IOException { if (recordCount.get() <= maxRecords.get()) { RecordIterator recIter = otherCache.getRecords(); try { byte[] record; while ((record = recIter.next()) != null && recordCount.incrementAndGet() <= maxRecords.get()) { storeRecordInternal(record); } } finally { recIter.close(); } } }
/** * Stores the records from the supplied cache into this cache. * * @param otherCache * The cache to copy the records from. */ public final void storeRecords(RecordCache otherCache) throws IOException { if (recordCount.get() <= maxRecords.get()) { RecordIterator recIter = otherCache.getRecords(); try { byte[] record; while ((record = recIter.next()) != null && recordCount.incrementAndGet() <= maxRecords.get()) { storeRecordInternal(record); } } finally { recIter.close(); } } }