@Override public boolean apply(@Nullable Row row) { return row != null && !row.key.getKey().equals(exceptKey); } });
/** * Insert/Update the column family for this key. * Caller is responsible for acquiring Keyspace.switchLock * param @ lock - lock that needs to be used. * param @ key - key for update/insert * param @ columnFamily - columnFamily changes */ public void apply(DecoratedKey key, ColumnFamily columnFamily, SecondaryIndexManager.Updater indexer, OpOrder.Group opGroup, ReplayPosition replayPosition) { long start = System.nanoTime(); Memtable mt = data.getMemtableFor(opGroup, replayPosition); final long timeDelta = mt.put(key, columnFamily, indexer, opGroup); maybeUpdateRowCache(key); metric.samplers.get(Sampler.WRITES).addSample(key.getKey(), key.hashCode(), 1); metric.writeLatency.addNano(System.nanoTime() - start); if(timeDelta < Long.MAX_VALUE) metric.colUpdateTimeDeltaHistogram.update(timeDelta); }
public int compare(DecoratedKey o1, DecoratedKey o2) { if ((right.compareTo(o1.getToken()) < 0 && right.compareTo(o2.getToken()) < 0) || (right.compareTo(o1.getToken()) > 0 && right.compareTo(o2.getToken()) > 0)) { // both tokens are on the same side of the wrap point return o1.compareTo(o2); } return o2.compareTo(o1); } };
protected boolean isPreviouslyReturnedPartition(DecoratedKey key) { // Note that lastReturnedKey can be null, but key cannot. return key.equals(lastReturnedKey); }
private static Map<SSTableReader, Bounds<Token>> genBounds(Iterable<SSTableReader> ssTableReaders) { Map<SSTableReader, Bounds<Token>> boundsMap = new HashMap<>(); for (SSTableReader sstable : ssTableReaders) { boundsMap.put(sstable, new Bounds<Token>(sstable.first.getToken(), sstable.last.getToken())); } return boundsMap; }
@Override public int compare(SSTableReader o1, SSTableReader o2) { return o1.last.compareTo(o2.last); } });
protected String getPartitionKeyString(ExtendedFilter mainFilter) { AbstractBounds<RowPosition> keyRange = mainFilter.dataRange.keyRange(); if (keyRange != null && keyRange.left != null && keyRange.left instanceof DecoratedKey) { DecoratedKey left = (DecoratedKey) keyRange.left; DecoratedKey right = (DecoratedKey) keyRange.right; if (left.equals(right)) { return tableMapper.primaryKeyAbstractType.getString(left.getKey()); } } return null; }
public KeyBound minValue() { return getPartitioner().getMinimumToken().minKeyBound(); }
public DigestMismatchException(DecoratedKey key, ByteBuffer digest1, ByteBuffer digest2) { super(String.format("Mismatch for key %s (%s vs %s)", key.toString(), ByteBufferUtil.bytesToHex(digest1), ByteBufferUtil.bytesToHex(digest2))); } }
public ColumnFamily getTopLevelColumns(QueryFilter filter, int gcBefore) { Tracing.trace("Executing single-partition query on {}", name); CollationController controller = new CollationController(this, filter, gcBefore); ColumnFamily columns; try (OpOrder.Group op = readOrdering.start()) { columns = controller.getTopLevelColumns(Memtable.MEMORY_POOL.needToCopyOnHeap()); } if (columns != null) metric.samplers.get(Sampler.READS).addSample(filter.key.getKey(), filter.key.hashCode(), 1); metric.updateSSTableIterated(controller.getSstablesIterated()); return columns; }
public int compare(DecoratedKey o1, DecoratedKey o2) { if ((right.compareTo(o1.getToken()) < 0 && right.compareTo(o2.getToken()) < 0) || (right.compareTo(o1.getToken()) > 0 && right.compareTo(o2.getToken()) > 0)) { // both tokens are on the same side of the wrap point return o1.compareTo(o2); } return o2.compareTo(o1); } };
protected boolean isPreviouslyReturnedPartition(DecoratedKey key) { // Note that lastReturnedKey can be null, but key cannot. return key.equals(lastReturnedKey); }
private List<Token> keysToTokens(Range<Token> range, List<DecoratedKey> keys) { List<Token> tokens = Lists.newArrayListWithExpectedSize(keys.size() + 2); tokens.add(range.left); for (DecoratedKey key : keys) tokens.add(key.getToken()); tokens.add(range.right); return tokens; }
public int compareTo(SSTableIdentityIterator o) { return key.compareTo(o.key); } }
public KeyBound minValue() { return getPartitioner().getMinimumToken().minKeyBound(); }
public DigestMismatchException(DecoratedKey key, ByteBuffer digest1, ByteBuffer digest2) { super(String.format("Mismatch for key %s (%s vs %s)", key.toString(), ByteBufferUtil.bytesToHex(digest1), ByteBufferUtil.bytesToHex(digest2))); } }
/** * If the given @param key occupies only part of a larger buffer, allocate a new buffer that is only * as large as necessary. */ public static DecoratedKey getMinimalKey(DecoratedKey key) { return key.getKey().position() > 0 || key.getKey().hasRemaining() || !key.getKey().hasArray() ? new BufferDecoratedKey(key.getToken(), HeapAllocator.instance.clone(key.getKey())) : key; }
/** * Return a wrapped iterator that when closed will update the sstables iterated and READ sample metrics. * Note that we cannot use the Transformations framework because they greedily get the static row, which * would cause all iterators to be initialized and hence all sstables to be accessed. */ private UnfilteredRowIterator withSSTablesIterated(List<UnfilteredRowIterator> iterators, TableMetrics metrics, SSTableReadMetricsCollector metricsCollector) { @SuppressWarnings("resource") // Closed through the closing of the result of the caller method. UnfilteredRowIterator merged = UnfilteredRowIterators.merge(iterators, nowInSec()); if (!merged.isEmpty()) { DecoratedKey key = merged.partitionKey(); metrics.samplers.get(TableMetrics.Sampler.READS).addSample(key.getKey(), key.hashCode(), 1); } class UpdateSstablesIterated extends Transformation { public void onPartitionClose() { int mergedSSTablesIterated = metricsCollector.getMergedSSTables(); metrics.updateSSTableIterated(mergedSSTablesIterated); Tracing.trace("Merged data from memtables and {} sstables", mergedSSTablesIterated); } }; return Transformation.apply(merged, new UpdateSstablesIterated()); }