public void cleanupCache() { Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); for (Iterator<RowCacheKey> keyIter = CacheService.instance.rowCache.keyIterator(); keyIter.hasNext(); ) { RowCacheKey key = keyIter.next(); DecoratedKey dk = decorateKey(ByteBuffer.wrap(key.key)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) invalidateCachedPartition(dk); } if (metadata.isCounter()) { for (Iterator<CounterCacheKey> keyIter = CacheService.instance.counterCache.keyIterator(); keyIter.hasNext(); ) { CounterCacheKey key = keyIter.next(); DecoratedKey dk = decorateKey(ByteBuffer.wrap(key.partitionKey)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) CacheService.instance.counterCache.remove(key); } } }
public void cleanupCache() { Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); for (Iterator<RowCacheKey> keyIter = CacheService.instance.rowCache.keyIterator(); keyIter.hasNext(); ) { RowCacheKey key = keyIter.next(); DecoratedKey dk = decorateKey(ByteBuffer.wrap(key.key)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) invalidateCachedPartition(dk); } if (metadata.isCounter()) { for (Iterator<CounterCacheKey> keyIter = CacheService.instance.counterCache.keyIterator(); keyIter.hasNext(); ) { CounterCacheKey key = keyIter.next(); DecoratedKey dk = decorateKey(ByteBuffer.wrap(key.partitionKey)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) CacheService.instance.counterCache.remove(key); } } }
public void cleanupCache() { Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); for (Iterator<RowCacheKey> keyIter = CacheService.instance.rowCache.keyIterator(); keyIter.hasNext(); ) { RowCacheKey key = keyIter.next(); DecoratedKey dk = decorateKey(ByteBuffer.wrap(key.key)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) invalidateCachedPartition(dk); } if (metadata.isCounter()) { for (Iterator<CounterCacheKey> keyIter = CacheService.instance.counterCache.keyIterator(); keyIter.hasNext(); ) { CounterCacheKey key = keyIter.next(); DecoratedKey dk = decorateKey(ByteBuffer.wrap(key.partitionKey)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) CacheService.instance.counterCache.remove(key); } } }
@Override public UnfilteredRowIterator cleanup(UnfilteredRowIterator partition) { if (Range.isInRanges(partition.partitionKey().getToken(), ranges)) return partition; cfs.invalidateCachedPartition(partition.partitionKey()); cfs.indexManager.deletePartition(partition, nowInSec); return null; } }
@Override public UnfilteredRowIterator cleanup(UnfilteredRowIterator partition) { if (Range.isInRanges(partition.partitionKey().getToken(), ranges)) return partition; cfs.invalidateCachedPartition(partition.partitionKey()); cfs.indexManager.deletePartition(partition, nowInSec); return null; } }
@Override public UnfilteredRowIterator cleanup(UnfilteredRowIterator partition) { if (Range.isInRanges(partition.partitionKey().getToken(), ranges)) return partition; cfs.invalidateCachedPartition(partition.partitionKey()); cfs.indexManager.deletePartition(partition, nowInSec); return null; } }
@Override public SSTableIdentityIterator cleanup(SSTableIdentityIterator row) { if (Range.isInRanges(row.getKey().getToken(), ranges)) return row; cfs.invalidateCachedRow(row.getKey()); if (indexedColumnsInRow != null) indexedColumnsInRow.clear(); while (row.hasNext()) { OnDiskAtom column = row.next(); if (column instanceof Cell && cfs.indexManager.indexes((Cell) column)) { if (indexedColumnsInRow == null) indexedColumnsInRow = new ArrayList<>(); indexedColumnsInRow.add((Cell) column); } } if (indexedColumnsInRow != null && !indexedColumnsInRow.isEmpty()) { // acquire memtable lock here because secondary index deletion may cause a race. See CASSANDRA-3712 try (OpOrder.Group opGroup = cfs.keyspace.writeOrder.start()) { cfs.indexManager.deleteFromIndexes(row.getKey(), indexedColumnsInRow, opGroup); } } return null; } }
public void cleanupCache() { Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); for (RowCacheKey key : CacheService.instance.rowCache.getKeySet()) { DecoratedKey dk = partitioner.decorateKey(ByteBuffer.wrap(key.key)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) invalidateCachedRow(dk); } if (metadata.isCounter()) { for (CounterCacheKey key : CacheService.instance.counterCache.getKeySet()) { DecoratedKey dk = partitioner.decorateKey(ByteBuffer.wrap(key.partitionKey)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) CacheService.instance.counterCache.remove(key); } } }
@Override public boolean realAppend(UnfilteredRowIterator partition) { if(Range.isInRanges(partition.partitionKey().getToken(), sortedRanges)) { RowIndexEntry rie = sstableWriter.append(partition); return rie != null; } else { cfs.invalidateCachedPartition(partition.partitionKey()); cfs.indexManager.deletePartition(partition, nowInSec); return false; } }
/** * Called (in order) for every row present in the CF. * Hashes the row, and adds it to the tree being built. * * @param partition Partition to add hash */ public void add(UnfilteredRowIterator partition) { assert Range.isInRanges(partition.partitionKey().getToken(), desc.ranges) : partition.partitionKey().getToken() + " is not contained in " + desc.ranges; assert lastKey == null || lastKey.compareTo(partition.partitionKey()) < 0 : "partition " + partition.partitionKey() + " received out of order wrt " + lastKey; lastKey = partition.partitionKey(); if (range == null) range = ranges.next(); // generate new ranges as long as case 1 is true if (!findCorrectRange(lastKey.getToken())) { // add the empty hash, and move to the next range ranges = trees.invalids(); findCorrectRange(lastKey.getToken()); } assert range.contains(lastKey.getToken()) : "Token not in MerkleTree: " + lastKey.getToken(); // case 3 must be true: mix in the hashed row RowHash rowHash = rowHash(partition); if (rowHash != null) { range.addHash(rowHash); } }
/** * Called (in order) for every row present in the CF. * Hashes the row, and adds it to the tree being built. * * @param partition Partition to add hash */ public void add(UnfilteredRowIterator partition) { assert Range.isInRanges(partition.partitionKey().getToken(), desc.ranges) : partition.partitionKey().getToken() + " is not contained in " + desc.ranges; assert lastKey == null || lastKey.compareTo(partition.partitionKey()) < 0 : "partition " + partition.partitionKey() + " received out of order wrt " + lastKey; lastKey = partition.partitionKey(); if (range == null) range = ranges.next(); // generate new ranges as long as case 1 is true if (!findCorrectRange(lastKey.getToken())) { // add the empty hash, and move to the next range ranges = trees.invalids(); findCorrectRange(lastKey.getToken()); } assert range.contains(lastKey.getToken()) : "Token not in MerkleTree: " + lastKey.getToken(); // case 3 must be true: mix in the hashed row RowHash rowHash = rowHash(partition); if (rowHash != null) { range.addHash(rowHash); } }
/** * Called (in order) for every row present in the CF. * Hashes the row, and adds it to the tree being built. * * @param partition Partition to add hash */ public void add(UnfilteredRowIterator partition) { assert Range.isInRanges(partition.partitionKey().getToken(), desc.ranges) : partition.partitionKey().getToken() + " is not contained in " + desc.ranges; assert lastKey == null || lastKey.compareTo(partition.partitionKey()) < 0 : "partition " + partition.partitionKey() + " received out of order wrt " + lastKey; lastKey = partition.partitionKey(); if (range == null) range = ranges.next(); // generate new ranges as long as case 1 is true if (!findCorrectRange(lastKey.getToken())) { // add the empty hash, and move to the next range ranges = trees.invalids(); findCorrectRange(lastKey.getToken()); } assert range.contains(lastKey.getToken()) : "Token not in MerkleTree: " + lastKey.getToken(); // case 3 must be true: mix in the hashed row RowHash rowHash = rowHash(partition); if (rowHash != null) { range.addHash(rowHash); } }