@Override public String toString() { StringBuilder sb = new StringBuilder(super.toString()); sb.append(";iterations=").append(getIterations()); sb.append(";iterationTime=").append(getIterationTime()); return sb.toString(); } }
public ByteBuffer nextBB() throws IOException { long startNext = scanStat.beginIteration(); if (prefetchedKey == null) { throw new NoSuchElementException(); } currentKey = prefetchedKey; currentValue = prefetchedValue; prefetchedKey = null; prefetchedValue = null; if (scan.next()) { populateKV(startNext, true); } return currentKey; }
private void populateKV(long nextStartTime, boolean scanSuccessful) { if (!scanSuccessful) { //end of file reached. collect stats and return scanStat.endIteration(0, nextStartTime); return; } prefetchedKey = scan.getKey(); prefetchedValue = scan.getValue(); if (to != null) { // TODO Optimization? Perform int comparison instead of byte[]. Identify // offset of key greater than two. int compare = -1; compare = scan.getReader().getComparator().compare (prefetchedKey.array(), prefetchedKey.arrayOffset(), prefetchedKey.remaining(), to, 0, to.length); if (compare > 0 || (compare == 0 && !toInclusive)) { prefetchedKey = null; prefetchedValue = null; return; } } // account for bytes read and time spent int byteCount = prefetchedKey.remaining() + prefetchedValue.remaining(); scanStat.endIteration(byteCount, nextStartTime); }
scan = new ScanOperation(scanCount.getId(), scanInProgress.getId(), scanTime.getId(), scanBytes.getId(), scanErrors.getId(), scanIterations.getId(), scanIterationTime.getId()); write = new IOOperation(writeCount.getId(), writeInProgress.getId(), writeTime.getId(), writeBytes.getId(), writeErrors.getId()); put = new IOOperation(putCount.getId(), putInProgress.getId(), putTime.getId(), putBytes.getId(), putErrors.getId());
scan = new ScanOperation(scanCount.getId(), scanInProgress.getId(), scanTime.getId(), scanBytes.getId(), scanErrors.getId(), scanIterations.getId(), scanIterationTime.getId()); write = new IOOperation(writeCount.getId(), writeInProgress.getId(), writeTime.getId(), writeBytes.getId(), writeErrors.getId()); put = new IOOperation(putCount.getId(), putInProgress.getId(), putTime.getId(), putBytes.getId(), putErrors.getId());
assertEquals(0, stats.getScan().getCount()); assertEquals(0, stats.getScan().getBytes()); assertEquals(0, stats.getScan().getTime()); assertEquals(0, stats.getScan().getIterations()); assertEquals(0, stats.getScan().getIterationTime()); assertEquals(0, stats.getScan().getCount()); int count = 0; for (byte[] bs = null; scanner.hasNext(); ) { count += bs.length + scanner.getValue().length; assertEquals(count, stats.getScan().getBytes()); assertEquals(5, stats.getScan().getIterations()); assertTrue(0 < stats.getScan().getIterationTime()); assertEquals(0, stats.getScan().getCount()); assertEquals(0, stats.getScan().getTime()); assertEquals(1, stats.getScan().getInProgress()); assertEquals(1, stats.getScan().getCount()); assertTrue(0 < stats.getScan().getTime()); assertTrue(stats.getScan().getIterationTime() <= stats.getScan().getTime());
private void populateKV(long nextStartTime, boolean scanSuccessful) { if (!scanSuccessful) { //end of file reached. collect stats and return scanStat.endIteration(0, nextStartTime); return; } prefetchedKey = scan.getKey(); prefetchedValue = scan.getValue(); if (to != null) { // TODO Optimization? Perform int comparison instead of byte[]. Identify // offset of key greater than two. int compare = -1; compare = scan.getReader().getComparator().compare (prefetchedKey.array(), prefetchedKey.arrayOffset(), prefetchedKey.remaining(), to, 0, to.length); if (compare > 0 || (compare == 0 && !toInclusive)) { prefetchedKey = null; prefetchedValue = null; return; } } // account for bytes read and time spent int byteCount = prefetchedKey.remaining() + prefetchedValue.remaining(); scanStat.endIteration(byteCount, nextStartTime); }
public HFileSortedIterator(HFileScanner scan, byte[] from, boolean fromInclusive, byte[] to, boolean toInclusive) throws IOException { this.scan = scan; this.from = from; this.fromInclusive = fromInclusive; this.to = to; this.toInclusive = toInclusive; scanStat = (stats == null) ? new SortedOplogStatistics("", "").new ScanOperation( 0, 0, 0, 0, 0, 0, 0) : stats.getScan(); scanStart = scanStat.begin(); if (scan == null) { return; } assert from == null || to == null || scan.getReader().getComparator().compare(from, to) <= 0; initIterator(); }
public HFileSortedIterator(HFileScanner scan, byte[] from, boolean fromInclusive, byte[] to, boolean toInclusive) throws IOException { this.scan = scan; this.from = from; this.fromInclusive = fromInclusive; this.to = to; this.toInclusive = toInclusive; scanStat = (stats == null) ? new SortedOplogStatistics("", "").new ScanOperation( 0, 0, 0, 0, 0, 0, 0) : stats.getScan(); scanStart = scanStat.begin(); if (scan == null) { return; } assert from == null || to == null || scan.getReader().getComparator().compare( from, 0, from.length, to, 0, to.length) <= 0; initIterator(); }
public HFileSortedIterator(HFileScanner scan, SerializedComparator comparator, byte[] from, boolean fromInclusive, byte[] to, boolean toInclusive) throws IOException { this.scan = scan; this.comparator = comparator; this.from = from; this.fromInclusive = fromInclusive; this.to = to; this.toInclusive = toInclusive; assert from == null || to == null || comparator.compare(from, 0, from.length, to, 0, to.length) <= 0; start = sopConfig.getStatistics().getScan().begin(); foundNext = evalFrom(); }
@Override public ByteBuffer next() { long startNext = sopConfig.getStatistics().getScan().beginIteration(); if (!hasNext()) { throw new NoSuchElementException(); } foundNext = false; key = scan.getKey(); value = scan.getValue(); int len = key.remaining() + value.remaining(); bytes += len; sopConfig.getStatistics().getScan().endIteration(len, startNext); return key; }
private void initIterator() throws IOException { long startNext = scanStat.beginIteration(); boolean scanSuccessful = true; if (from == null) { scanSuccessful = scan.seekTo(); } else { int compare = scan.seekTo(from); if (compare == 0 && !fromInclusive || compare > 0) { // as from in exclusive and first key is same as from, skip the first key scanSuccessful = scan.next(); } } populateKV(startNext, scanSuccessful); }
public ByteBuffer nextBB() throws IOException { long startNext = scanStat.beginIteration(); if (prefetchedKey == null) { throw new NoSuchElementException(); } currentKey = prefetchedKey; currentValue = prefetchedValue; prefetchedKey = null; prefetchedValue = null; if (scan.next()) { populateKV(startNext, true); } return currentKey; }
private void initIterator() throws IOException { long startNext = scanStat.beginIteration(); boolean scanSuccessful = true; if (from == null) { scanSuccessful = scan.seekTo(); } else { int compare = scan.seekTo(from); if (compare == 0 && !fromInclusive || compare > 0) { // as from in exclusive and first key is same as from, skip the first key scanSuccessful = scan.next(); } } populateKV(startNext, scanSuccessful); }
@Override public void close() { sopConfig.getStatistics().getScan().end(bytes, start); }
@Override public void close() { scanStat.end(scanStart); } }
@Override public void close() { scanStat.end(scanStart); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(super.toString()); sb.append(";iterations=").append(getIterations()); sb.append(";iterationTime=").append(getIterationTime()); return sb.toString(); } }