try { while (scanner != null) { Cell topKey = scanner.peek(); if (comparator.getComparator().compare(seekKey, topKey) <= 0) { if (isLazy && heap.size() > 0) { seekResult = scanner.requestSeek(seekKey, forward, useBloom); } else { seekResult = NonLazyKeyValueScanner.doRealSeek(scanner, seekKey, if (scanner != null) { try { scanner.close(); } catch (Exception ce) { LOG.warn("close KeyValueScanner error", ce);
static void doScan(MemStore ms, int iteration) throws IOException { long nanos = System.nanoTime(); KeyValueScanner s = ms.getScanners(0).get(0); s.seek(KeyValueUtil.createFirstOnRow(new byte[]{})); System.out.println(iteration + " create/seek took: " + (System.nanoTime() - nanos)/1000); int cnt=0; while(s.next() != null) ++cnt; System.out.println(iteration + " took usec: " + (System.nanoTime() - nanos) / 1000 + " for: " + cnt); }
while (kvScanner != null && !kvScanner.realSeekDone()) { if (kvScanner.peek() != null) { try { kvScanner.enforceSeek(); } catch (IOException ioe) { throw ioe; Cell curKV = kvScanner.peek(); if (curKV != null) { KeyValueScanner nextEarliestScanner = heap.peek(); Cell nextKV = nextEarliestScanner.peek(); if (nextKV == null || comparator.compare(curKV, nextKV) < 0) {
@Override public void shipped() throws IOException { for (KeyValueScanner scanner : this.scannersForDelayedClose) { scanner.close(); // There wont be further fetch of Cells from these scanners. Just close. } this.scannersForDelayedClose.clear(); if (this.current != null) { this.current.shipped(); } if (this.heap != null) { for (KeyValueScanner scanner : this.heap) { scanner.shipped(); } } } }
@Override public int compare(KeyValueScanner left, KeyValueScanner right) { int comparison = compare(left.peek(), right.peek()); if (comparison != 0) { return comparison; } else { // Since both the keys are exactly the same, we break the tie in favor of higher ordered // scanner since it'll have newer data. Since higher value should come first, we reverse // sort here. return Long.compare(right.getScannerOrder(), left.getScannerOrder()); } } /**
assertTrue(scan.seek(kv)); Cell res = scan.peek(); assertEquals(kvs[0], res); assertTrue(scan.seek(kv)); res = scan.peek(); assertEquals(kvs[2], res); assertTrue(scan.seek(kv)); assertEquals(kvs[0], scan.peek()); assertEquals(kvs[0], scan.next()); assertEquals(kvs[1], scan.peek()); assertEquals(kvs[1], scan.next()); assertEquals(kvs[2], scan.peek()); assertEquals(kvs[2], scan.next()); assertEquals(null, scan.peek()); assertEquals(null, scan.next());
@Test public void testCountOfCellsAfterFlatteningByScan() throws IOException { String[] keys1 = { "A", "B", "C" }; // A, B, C addRowsByKeysWith50Cols(memstore, keys1); // this should only flatten as there are no duplicates ((CompactingMemStore) memstore).flushInMemory(); while (((CompactingMemStore) memstore).isMemStoreFlushingInMemory()) { Threads.sleep(10); } List<KeyValueScanner> scanners = memstore.getScanners(Long.MAX_VALUE); // seek int count = 0; for(int i = 0; i < scanners.size(); i++) { scanners.get(i).seek(KeyValue.LOWESTKEY); while (scanners.get(i).next() != null) { count++; } } assertEquals("the count should be ", 150, count); for(int i = 0; i < scanners.size(); i++) { scanners.get(i).close(); } }
while (kvScanner != null && !kvScanner.realSeekDone()) { if (kvScanner.peek() != null) { kvScanner.enforceSeek(); KeyValue curKV = kvScanner.peek(); if (curKV != null) { KeyValueScanner nextEarliestScanner = heap.peek(); KeyValue nextKV = nextEarliestScanner.peek(); if (nextKV == null || comparator.compare(curKV, nextKV) < 0) { kvScanner.close(); kvScanner.close();
@Override public void close() { if (this.scanners != null) { for (KeyValueScanner scanner : scanners) { scanner.close(); } } } }
scanner.requestSeek(seekKey, false, true); + ", but row is bigger than that"); scanner.seek(seekKey); Cell c = scanner.peek(); if (c != null) { totalScannersSoughtBytes += PrivateCellUtil.estimatedSerializedSizeOf(c);
assertTrue(scanner.seekToLastRow()); assertEquals(makeKV(ROWSIZE - 1, 0), scanner.peek()); assertTrue(scanner.backwardSeek(seekKey)); assertEquals(seekKey, scanner.peek()); assertTrue(scanner.backwardSeek(KeyValueUtil.createLastOnRow(ROWS[seekRowNum]))); KeyValue expectedKey = makeKV(seekRowNum - 1, 0); assertEquals(expectedKey, scanner.peek()); assertFalse(scanner.backwardSeek(KeyValueUtil.createLastOnRow(ROWS[0]))); assertEquals(null, scanner.peek()); assertTrue(scanner.seekToPreviousRow(KeyValueUtil .createFirstOnRow(ROWS[seekRowNum]))); expectedKey = makeKV(seekRowNum - 1, 0); assertEquals(expectedKey, scanner.peek()); assertFalse(scanner.seekToPreviousRow(makeKV(0, 0))); assertEquals(null, scanner.peek());
public KeyValue next() throws IOException { if(this.current == null) { return null; } KeyValue kvReturn = this.current.next(); KeyValue kvNext = this.current.peek(); if (kvNext == null) { this.current.close(); this.current = pollRealKV(); } else { KeyValueScanner topScanner = this.heap.peek(); if (topScanner == null || this.comparator.compare(kvNext, topScanner.peek()) >= 0) { this.heap.add(this.current); this.current = pollRealKV(); } } return kvReturn; }
boolean isFile = kvs.isFileScanner(); if ((!isFile && filesOnly) || (isFile && memOnly)) { continue; if (kvs.shouldUseScanner(scan, store, expiredTimestampCutoff)) { scanners.add(kvs); } else { kvs.close();
@Override public Cell next() throws IOException { if (this.current == null) { return null; } Cell kvReturn = this.current.next(); Cell kvNext = this.current.peek(); if (kvNext == null || this.comparator.kvComparator.compareRows(kvNext, kvReturn) > 0) { if (this.current.seekToPreviousRow(kvReturn)) { this.heap.add(this.current); } else { this.scannersForDelayedClose.add(this.current); } this.current = null; this.current = pollRealKV(); } else { KeyValueScanner topScanner = this.heap.peek(); if (topScanner != null && this.comparator.compare(this.current, topScanner) > 0) { this.heap.add(this.current); this.current = null; this.current = pollRealKV(); } } return kvReturn; }
@Override public void process() { try { scanner.seek(keyValue); } catch (IOException e) { LOG.error("", e); setErr(e); } finally { latch.countDown(); } }
@Override public Cell peek() { if (this.current == null) { return null; } return this.current.peek(); }
@Override public Cell next() throws IOException { if(this.current == null) { return null; } Cell kvReturn = this.current.next(); Cell kvNext = this.current.peek(); if (kvNext == null) { this.scannersForDelayedClose.add(this.current); this.current = null; this.current = pollRealKV(); } else { KeyValueScanner topScanner = this.heap.peek(); // no need to add current back to the heap if it is the only scanner left if (topScanner != null && this.comparator.compare(kvNext, topScanner.peek()) >= 0) { this.heap.add(this.current); this.current = null; this.current = pollRealKV(); } } return kvReturn; }
assert kvs.isFileScanner(); if (kvs.peek() == null) { continue; filesToReopen.add(name2File.get(kvs.getFilePath().getName()));