private Segment getLastSegment() { Segment localActive = getActive(); Segment tail = pipeline.getTail(); return tail == null ? localActive : tail; }
public void debug() { String msg = "active size=" + getActive().getDataSize(); msg += " allow compaction is "+ (allowCompaction.get() ? "true" : "false"); msg += " inMemoryCompactionInProgress is "+ (inMemoryCompactionInProgress.get() ? "true" : "false"); LOG.debug(msg); }
@VisibleForTesting @Override protected List<Segment> getSegments() { List<? extends Segment> pipelineList = pipeline.getSegments(); List<Segment> list = new ArrayList<>(pipelineList.size() + 2); list.add(getActive()); list.addAll(pipelineList); list.addAll(snapshot.getAllSegments()); return list; }
@Override protected long keySize() { // Need to consider dataSize/keySize of all segments in pipeline and active long keySize = getActive().getDataSize(); for (Segment segment : this.pipeline.getSegments()) { keySize += segment.getDataSize(); } return keySize; }
@Override protected long heapSize() { // Need to consider heapOverhead of all segments in pipeline and active long h = getActive().getHeapSize(); for (Segment segment : this.pipeline.getSegments()) { h += segment.getHeapSize(); } return h; }
@Override public List<KeyValueScanner> getScanners(long readPt) throws IOException { MutableSegment activeTmp = getActive(); List<? extends Segment> pipelineList = pipeline.getSegments(); List<? extends Segment> snapshotList = snapshot.getAllSegments(); long numberOfSegments = 1L + pipelineList.size() + snapshotList.size(); // The list of elements in pipeline + the active element + the snapshot segment List<KeyValueScanner> list = createList((int) numberOfSegments); addToScanners(activeTmp, readPt, list); addToScanners(pipelineList, readPt, list); addToScanners(snapshotList, readPt, list); return list; }
@VisibleForTesting void flushInMemory() { MutableSegment currActive = getActive(); if(currActive.setInMemoryFlushed()) { flushInMemory(currActive); } inMemoryCompaction(); }
@Override public MemStoreSize getFlushableSize() { MemStoreSize mss = getSnapshotSize(); if (mss.getDataSize() == 0) { // if snapshot is empty the tail of the pipeline (or everything in the memstore) is flushed if (compositeSnapshot) { MemStoreSizing memStoreSizing = new NonThreadSafeMemStoreSizing(pipeline.getPipelineSize()); MutableSegment currActive = getActive(); if(!currActive.isEmpty()) { memStoreSizing.incMemStoreSize(currActive.getMemStoreSize()); } mss = memStoreSizing.getMemStoreSize(); } else { mss = pipeline.getTailSize(); } } return mss.getDataSize() > 0? mss: getActive().getMemStoreSize(); }
/** * @return Total memory occupied by this MemStore. This won't include any size occupied by the * snapshot. We assume the snapshot will get cleared soon. This is not thread safe and * the memstore may be changed while computing its size. It is the responsibility of the * caller to make sure this doesn't happen. */ @Override public MemStoreSize size() { MemStoreSizing memstoreSizing = new NonThreadSafeMemStoreSizing(); memstoreSizing.incMemStoreSize(getActive().getMemStoreSize()); for (Segment item : pipeline.getSegments()) { memstoreSizing.incMemStoreSize(item.getMemStoreSize()); } return memstoreSizing.getMemStoreSize(); }
pushActiveToPipeline(getActive()); snapshotId = EnvironmentEdgeManager.currentTime();