public boolean isEmpty() { return sstables.isEmpty() && liveMemtables.size() <= 1 && flushingMemtables.size() == 0 && (liveMemtables.size() == 0 || liveMemtables.get(0).getOperations() == 0); }
public Void call() { cfs.data.reset(new Memtable(new AtomicReference<>(CommitLogPosition.NONE), cfs)); return null; } }, true, false);
public Memtable getMemtableFor(OpOrder.Group opGroup, ReplayPosition replayPosition) { // since any new memtables appended to the list after we fetch it will be for operations started // after us, we can safely assume that we will always find the memtable that 'accepts' us; // if the barrier for any memtable is set whilst we are reading the list, it must accept us. // there may be multiple memtables in the list that would 'accept' us, however we only ever choose // the oldest such memtable, as accepts() only prevents us falling behind (i.e. ensures we don't // assign operations to a memtable that was retired/queued before we started) for (Memtable memtable : view.get().liveMemtables) { if (memtable.accepts(opGroup, replayPosition)) return memtable; } throw new AssertionError(view.get().liveMemtables.toString()); }
protected void runMayThrow() { synchronized (data) { Memtable current = data.getView().getCurrentMemtable(); // if we're not expired, we've been hit by a scheduled flush for an already flushed memtable, so ignore if (current.isExpired()) { if (current.isClean()) { // if we're still clean, instead of swapping just reschedule a flush for later scheduleFlush(); } else { // we'll be rescheduled by the constructor of the Memtable. forceFlush(); } } } } };
public void adjustMemtableSize(long additionalSpace, OpOrder.Group opGroup) { baseCfs.getTracker().getView().getCurrentMemtable().getAllocator().onHeap().allocate(additionalSpace, opGroup); } };
public Collection<SSTableReader> flushMemtable(Memtable memtable, boolean flushNonCf2i) if (memtable.isClean() || truncate) flushRunnables = memtable.flushRunnables(txn); t = memtable.abortRunnables(flushRunnables, t); t = txn.abort(t); throw Throwables.propagate(t);
Memtable newMemtable = new Memtable(commitLogUpperBound, cfs); Memtable oldMemtable = cfs.data.switchMemtable(truncate, newMemtable); oldMemtable.setDiscarding(writeBarrier, commitLogUpperBound); memtables.add(oldMemtable);
public Long getValue() { return cfs.getTracker().getView().getCurrentMemtable().getLiveDataSize(); } });
public Long getValue() { long memtablePartitions = 0; for (Memtable memtable : cfs.getTracker().getView().getAllMemtables()) memtablePartitions += memtable.partitionCount(); return SSTableReader.getApproximateKeyCount(cfs.getSSTables(SSTableSet.CANONICAL)) + memtablePartitions; } });
public void runMayThrow() { readBarrier.await(); memtable.setDiscarded(); } }, reclaimExecutor);
public boolean isCleanAfter(ReplayPosition position) { return isClean() || (position != null && minReplayPosition.compareTo(position) >= 0); }
/** * 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); }
if (memtable.isClean() || truncate) MoreExecutors.sameThreadExecutor().execute(memtable.flushRunnable()); reclaim(memtable);
public Long getValue() { return cfs.getTracker().getView().getCurrentMemtable().getAllocator().onHeap().owns(); } });
public Collection<SSTableReader> flushMemtable(Memtable memtable, boolean flushNonCf2i) if (memtable.isClean() || truncate) flushRunnables = memtable.flushRunnables(txn); t = memtable.abortRunnables(flushRunnables, t); t = txn.abort(t); throw Throwables.propagate(t);
protected void runMayThrow() { synchronized (data) { Memtable current = data.getView().getCurrentMemtable(); // if we're not expired, we've been hit by a scheduled flush for an already flushed memtable, so ignore if (current.isExpired()) { if (current.isClean()) { // if we're still clean, instead of swapping just reschedule a flush for later scheduleFlush(); } else { // we'll be rescheduled by the constructor of the Memtable. forceFlush(); } } } } };
Memtable newMemtable = new Memtable(commitLogUpperBound, cfs); Memtable oldMemtable = cfs.data.switchMemtable(truncate, newMemtable); oldMemtable.setDiscarding(writeBarrier, commitLogUpperBound); memtables.add(oldMemtable);
public Long getValue() { return cfs.getTracker().getView().getCurrentMemtable().getLiveDataSize(); } });
public Long getValue() { long memtablePartitions = 0; for (Memtable memtable : cfs.getTracker().getView().getAllMemtables()) memtablePartitions += memtable.partitionCount(); return SSTableReader.getApproximateKeyCount(cfs.getSSTables(SSTableSet.CANONICAL)) + memtablePartitions; } });
public void runMayThrow() { readBarrier.await(); memtable.setDiscarded(); } }, reclaimExecutor);