/** * Clears the cache, deleting all stored records. */ public final void clear() throws IOException { clearInternal(); recordCount.set(0L); }
/** * Gets all records that are stored in the cache, throwing an {@link IllegalStateException} if the cache * is no longer {@link #isValid() valid}. * * @return An iterator over all records. * @throws IllegalStateException * If the cache is not/no longer {@link #isValid() valid}. */ public final RecordIterator getRecords() { if (isValid()) { return getRecordsInternal(); } throw new IllegalStateException(); }
/** * 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(); } }
if ((data[FLAG_IDX] & REMOVED_FLAG) == 0) { data[FLAG_IDX] |= REMOVED_FLAG; removedTriplesCache.storeRecord(data); count = (int)removedTriplesCache.getRecordCount(); updatedTriplesCache.storeRecords(removedTriplesCache); BTree btree = index.getBTree(); RecordIterator recIter = removedTriplesCache.getRecords(); try { while ((data = recIter.next()) != null) { removedTriplesCache.discard();
boolean validCache = updatedTriplesCache != null && updatedTriplesCache.isValid(); if (validCache) { iter = updatedTriplesCache.getRecords(); updatedTriplesCache.clear();
public void startTransaction() throws IOException { txnStatusFile.setTxnStatus(TxnStatus.ACTIVE); // Create a record cache for storing updated triples with a maximum of // some 10% of the number of triples long maxRecords = indexes.get(0).getBTree().getValueCountEstimate() / 10L; if (updatedTriplesCache == null) { updatedTriplesCache = new SortedRecordCache(dir, RECORD_LENGTH, maxRecords, new TripleComparator("spoc")); } else { assert updatedTriplesCache.getRecordCount() == 0L : "updatedTripleCache should have been cleared upon commit or rollback"; updatedTriplesCache.setMaxRecords(maxRecords); } }
/** * 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(); } } }
/** * Gets the number of records currently stored in the cache, throwing an {@link IllegalStateException} if * the cache is no longer {@link #isValid() valid}. * * @return * @throws IllegalStateException * If the cache is not/no longer {@link #isValid() valid}. */ public final long getRecordCount() { if (isValid()) { return recordCount.get(); } throw new IllegalStateException(); }
updatedTriplesCache = null; if (toCloseUpdatedTriplesCache != null) { toCloseUpdatedTriplesCache.discard();
updatedTriplesCache.storeRecord(data);
if ((data[FLAG_IDX] & REMOVED_FLAG) == 0) { data[FLAG_IDX] |= REMOVED_FLAG; removedTriplesCache.storeRecord(data); count = (int)removedTriplesCache.getRecordCount(); updatedTriplesCache.storeRecords(removedTriplesCache); BTree btree = index.getBTree(); RecordIterator recIter = removedTriplesCache.getRecords(); try { while ((data = recIter.next()) != null) { removedTriplesCache.discard();
boolean validCache = updatedTriplesCache != null && updatedTriplesCache.isValid(); if (validCache) { iter = updatedTriplesCache.getRecords(); updatedTriplesCache.clear();
public void startTransaction() throws IOException { txnStatusFile.setTxnStatus(TxnStatus.ACTIVE); // Create a record cache for storing updated triples with a maximum of // some 10% of the number of triples long maxRecords = indexes.get(0).getBTree().getValueCountEstimate() / 10L; if (updatedTriplesCache == null) { updatedTriplesCache = new SortedRecordCache(dir, RECORD_LENGTH, maxRecords, new TripleComparator("spoc")); } else { assert updatedTriplesCache.getRecordCount() == 0L : "updatedTripleCache should have been cleared upon commit or rollback"; updatedTriplesCache.setMaxRecords(maxRecords); } }
/** * 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(); } } }
/** * Gets the number of records currently stored in the cache, throwing an {@link IllegalStateException} if * the cache is no longer {@link #isValid() valid}. * * @return * @throws IllegalStateException * If the cache is not/no longer {@link #isValid() valid}. */ public final long getRecordCount() { if (isValid()) { return recordCount.get(); } throw new IllegalStateException(); }
updatedTriplesCache = null; if (toCloseUpdatedTriplesCache != null) { toCloseUpdatedTriplesCache.discard();
updatedTriplesCache.storeRecord(data);
boolean validCache = updatedTriplesCache != null && updatedTriplesCache.isValid(); if (validCache) { iter = updatedTriplesCache.getRecords(); updatedTriplesCache.clear();
/** * Gets all records that are stored in the cache, throwing an {@link IllegalStateException} if the cache * is no longer {@link #isValid() valid}. * * @return An iterator over all records. * @throws IllegalStateException * If the cache is not/no longer {@link #isValid() valid}. */ public final RecordIterator getRecords() { if (isValid()) { return getRecordsInternal(); } throw new IllegalStateException(); }
/** * Clears the cache, deleting all stored records. */ public final void clear() throws IOException { clearInternal(); recordCount.set(0L); }