ScannerContext(boolean keepProgress, LimitFields limitsToCopy, boolean trackMetrics) { this.limits = new LimitFields(); if (limitsToCopy != null) { this.limits.copy(limitsToCopy); } // Progress fields are initialized to 0 progress = new ProgressFields(0, 0, 0); this.keepProgress = keepProgress; this.scannerState = DEFAULT_STATE; this.metrics = trackMetrics ? new ServerSideScanMetrics() : null; }
int getBatchProgress() { return progress.getBatch(); }
long getDataSizeProgress() { return progress.getDataSize(); }
long getHeapSizeProgress() { return progress.getHeapSize(); }
ProgressFields(int batch, long size, long heapSize) { setFields(batch, size, heapSize); }
void setBatchProgress(int batchProgress) { progress.setBatch(batchProgress); }
void setSizeProgress(long dataSizeProgress, long heapSizeProgress) { progress.setDataSize(dataSizeProgress); progress.setHeapSize(heapSizeProgress); }
/** * @param checkerScope The scope that the limit is being checked from * @return true when the limit is enforceable from the checker's scope and it has been reached */ boolean checkBatchLimit(LimitScope checkerScope) { return hasBatchLimit(checkerScope) && progress.getBatch() >= limits.getBatch(); }
/** * @param checkerScope The scope that the limit is being checked from * @return true when the limit is enforceable from the checker's scope and it has been reached */ boolean checkSizeLimit(LimitScope checkerScope) { return hasSizeLimit(checkerScope) && (progress.getDataSize() >= limits.getDataSize() || progress.getHeapSize() >= limits.getHeapSize()); }
/** * Progress towards the size limit has been made. Increment internal tracking of size progress */ void incrementSizeProgress(long dataSize, long heapSize) { long curDataSize = progress.getDataSize(); progress.setDataSize(curDataSize + dataSize); long curHeapSize = progress.getHeapSize(); progress.setHeapSize(curHeapSize + heapSize); }
/** * Clear away any progress that has been made so far. All progress fields are reset to initial * values */ void clearProgress() { progress.setFields(0, 0, 0); }
/** * Set all fields together. */ void setFields(int batch, long dataSize, long heapSize) { setBatch(batch); setDataSize(dataSize); setHeapSize(heapSize); }