public KeyValue getKeyValue() { if (atEnd) return null; return delegate.getKeyValue(); }
public Cell getKeyValue() { if (atEnd) return null; return delegate.getKeyValue(); }
public HFileIterator(HFileScanner scanner) { this.scanner = scanner; this.curr = KeyValue.cloneAndAddTags(scanner.getKeyValue(), ImmutableList.<Tag>of()); }
@Override public KeyValue next() { KeyValue ret = curr; try { if (scanner.next()) { curr = KeyValue.cloneAndAddTags(scanner.getKeyValue(), ImmutableList.<Tag>of()); } else { curr = null; } } catch (IOException e) { throw new RuntimeException(e); } return ret; }
public KeyValue next() throws IOException { KeyValue retKey = cur; try { // only seek if we aren't at the end. cur == null implies 'end'. if (cur != null) { hfs.next(); cur = hfs.getKeyValue(); skipKVsNewerThanReadpoint(); } } catch(IOException e) { throw new IOException("Could not iterate " + this, e); } return retKey; }
public boolean seek(KeyValue key) throws IOException { seekCount.incrementAndGet(); try { try { if(!seekAtOrAfter(hfs, key)) { close(); return false; } this.isReseekable = true; cur = hfs.getKeyValue(); return skipKVsNewerThanReadpoint(); } finally { realSeekDone = true; } } catch (IOException ioe) { throw new IOException("Could not seek " + this + " to key " + key, ioe); } }
public boolean reseek(KeyValue key) throws IOException { seekCount.incrementAndGet(); try { try { if (!reseekAtOrAfter(hfs, key)) { close(); return false; } cur = hfs.getKeyValue(); return skipKVsNewerThanReadpoint(); } finally { realSeekDone = true; } } catch (IOException ioe) { throw new IOException("Could not reseek " + this + " to key " + key, ioe); } }
public Cell next() throws IOException { Cell retKey = cur; try { // only seek if we aren't at the end. cur == null implies 'end'. if (cur != null) { hfs.next(); setCurrentCell(hfs.getKeyValue()); if (hasMVCCInfo || this.reader.isBulkLoaded()) { skipKVsNewerThanReadpoint(); } } } catch (FileNotFoundException e) { throw e; } catch(IOException e) { throw new IOException("Could not iterate " + this, e); } return retKey; }
public boolean seek(Cell key) throws IOException { if (seekCount != null) seekCount.incrementAndGet(); try { try { if(!seekAtOrAfter(hfs, key)) { close(); return false; } setCurrentCell(hfs.getKeyValue()); if (!hasMVCCInfo && this.reader.isBulkLoaded()) { return skipKVsNewerThanReadpoint(); } else { return !hasMVCCInfo ? true : skipKVsNewerThanReadpoint(); } } finally { realSeekDone = true; } } catch (FileNotFoundException e) { throw e; } catch (IOException ioe) { throw new IOException("Could not seek " + this + " to key " + key, ioe); } }
public boolean reseek(Cell key) throws IOException { if (seekCount != null) seekCount.incrementAndGet(); try { try { if (!reseekAtOrAfter(hfs, key)) { close(); return false; } setCurrentCell(hfs.getKeyValue()); if (!hasMVCCInfo && this.reader.isBulkLoaded()) { return skipKVsNewerThanReadpoint(); } else { return !hasMVCCInfo ? true : skipKVsNewerThanReadpoint(); } } finally { realSeekDone = true; } } catch (FileNotFoundException e) { throw e; } catch (IOException ioe) { throw new IOException("Could not reseek " + this + " to key " + key, ioe); } }
return false; value = KeyValue.cloneAndAddTags(scanner.getKeyValue(), ImmutableList.<Tag>of()); if (stopRow != null && Bytes.compareTo(
private boolean walkForwardInSingleRow(final HFileScanner scanner, final KeyValue firstOnRow, final GetClosestRowBeforeTracker state) throws IOException { boolean foundCandidate = false; do { KeyValue kv = scanner.getKeyValue(); // If we are not in the row, skip. if (this.comparator.compareRows(kv, firstOnRow) < 0) continue; // Did we go beyond the target row? If so break. if (state.isTooFar(kv, firstOnRow)) break; if (state.isExpired(kv)) { continue; } // If we added something, this row is a contender. break. if (state.handle(kv)) { foundCandidate = true; break; } } while(scanner.next()); return foundCandidate; }
private boolean walkForwardInSingleRow(final HFileScanner scanner, final KeyValue firstOnRow, final GetClosestRowBeforeTracker state) throws IOException { boolean foundCandidate = false; do { Cell kv = scanner.getKeyValue(); // If we are not in the row, skip. if (this.comparator.compareRows(kv, firstOnRow) < 0) continue; // Did we go beyond the target row? If so break. if (state.isTooFar(kv, firstOnRow)) break; if (state.isExpired(kv)) { continue; } // If we added something, this row is a contender. break. if (state.handle(kv)) { foundCandidate = true; break; } } while(scanner.next()); return foundCandidate; }
return false; KeyValue firstKeyOfPreviousRow = KeyValueUtil.createFirstOnRow(hfs.getKeyValue() .getRowArray(), hfs.getKeyValue().getRowOffset(), hfs.getKeyValue().getRowLength()); setCurrentCell(hfs.getKeyValue()); this.stopSkippingKVsIfNextRow = true; boolean resultOfSkipKVs;
public static void doSmokeTest(FileSystem fs, Path path, String codec) throws Exception { Configuration conf = HBaseConfiguration.create(); HFileContext context = new HFileContextBuilder() .withCompression(AbstractHFileWriter.compressionByName(codec)).build(); HFile.Writer writer = HFile.getWriterFactoryNoCache(conf) .withPath(fs, path) .withFileContext(context) .create(); // Write any-old Cell... final byte [] rowKey = Bytes.toBytes("compressiontestkey"); Cell c = CellUtil.createCell(rowKey, Bytes.toBytes("compressiontestval")); writer.append(c); writer.appendFileInfo(Bytes.toBytes("compressioninfokey"), Bytes.toBytes("compressioninfoval")); writer.close(); Cell cc = null; HFile.Reader reader = HFile.createReader(fs, path, new CacheConfig(conf), conf); try { reader.loadFileInfo(); HFileScanner scanner = reader.getScanner(false, true); scanner.seekTo(); // position to the start of file // Scanner does not do Cells yet. Do below for now till fixed. cc = scanner.getKeyValue(); if (CellComparator.compareRows(c, cc) != 0) { throw new Exception("Read back incorrect result: " + c.toString() + " vs " + cc.toString()); } } finally { reader.close(); } }
protected boolean skipKVsNewerThanReadpoint() throws IOException { long readPoint = MultiVersionConsistencyControl.getThreadReadPoint(); // We want to ignore all key-values that are newer than our current // readPoint while(enforceMVCC && cur != null && (cur.getMemstoreTS() > readPoint)) { hfs.next(); cur = hfs.getKeyValue(); } if (cur == null) { close(); return false; } // For the optimisation in HBASE-4346, we set the KV's memstoreTS to // 0, if it is older than all the scanners' read points. It is possible // that a newer KV's memstoreTS was reset to 0. But, there is an // older KV which was not reset to 0 (because it was // not old enough during flush). Make sure that we set it correctly now, // so that the comparision order does not change. if (cur.getMemstoreTS() <= readPoint) { cur.setMemstoreTS(0); } return true; }
scanner.seekTo(); do { KeyValue kv = scanner.getKeyValue(); halfWriter.append(kv); } while (scanner.next());
protected boolean skipKVsNewerThanReadpoint() throws IOException { // We want to ignore all key-values that are newer than our current // readPoint Cell startKV = cur; while(enforceMVCC && cur != null && (cur.getMvccVersion() > readPt)) { hfs.next(); setCurrentCell(hfs.getKeyValue()); if (this.stopSkippingKVsIfNextRow && getComparator().compareRows(cur.getRowArray(), cur.getRowOffset(), cur.getRowLength(), startKV.getRowArray(), startKV.getRowOffset(), startKV.getRowLength()) > 0) { return false; } } if (cur == null) { close(); return false; } return true; }
scanner.seekTo(); do { halfWriter.append(scanner.getKeyValue()); } while (scanner.next());
KeyValue kv = scanner.getKeyValue(); if (!state.isTargetTable(kv)) break; if (!state.isBetterCandidate(kv)) break;