/** * Pick the next cell that the scanner should seek to. Since this can skip any number of cells * any of which can be a delete this can resurect old data. * * The method will only be used if canHint was set to true while creating the filter. * * @throws IOException This will never happen. */ @Override public Cell getNextCellHint(Cell currentCell) throws IOException { if (!canHint) { return null; } Long nextTimestampObject = timestamps.lower(currentCell.getTimestamp()); if (nextTimestampObject == null) { // This should only happen if the current column's // timestamp is below the last one in the list. // // It should never happen as the filterCell should return NEXT_COL // but it's always better to be extra safe and protect against future // behavioral changes. return PrivateCellUtil.createLastOnRowCol(currentCell); } // Since we know the nextTimestampObject isn't null here there must still be // timestamps that can be included. Cast the Long to a long and return the // a cell with the current row/cf/col and the next found timestamp. long nextTimestamp = nextTimestampObject; return PrivateCellUtil.createFirstOnRowColTS(currentCell, nextTimestamp); }
public Cell getKeyForNextColumn(Cell cell) { // We aren't sure whether any DeleteFamily cells exist, so we can't skip to next column. // TODO: Current way disable us to seek to next column quickly. Is there any better solution? // see HBASE-18471 for more details // see TestFromClientSide3#testScanAfterDeletingSpecifiedRow // see TestFromClientSide3#testScanAfterDeletingSpecifiedRowV2 if (cell.getQualifierLength() == 0) { Cell nextKey = PrivateCellUtil.createNextOnRowCol(cell); if (nextKey != cell) { return nextKey; } // The cell is at the end of row/family/qualifier, so it is impossible to find any DeleteFamily cells. // Let us seek to next column. } ColumnCount nextColumn = columns.getColumnHint(); if (nextColumn == null) { return PrivateCellUtil.createLastOnRowCol(cell); } else { return PrivateCellUtil.createFirstOnRowCol(cell, nextColumn.getBuffer(), nextColumn.getOffset(), nextColumn.getLength()); } }
checkSeekingConsistency(encodedSeekers, seekBefore, sampleKv.get(sampleKv.size() - 1)); KeyValue midKv = sampleKv.get(sampleKv.size() / 2); Cell lastMidKv =PrivateCellUtil.createLastOnRowCol(midKv); checkSeekingConsistency(encodedSeekers, seekBefore, lastMidKv);
/** * This is a cryptic test. It is checking that we don't include a fake cell, one that has a * timestamp of {@link HConstants#OLDEST_TIMESTAMP}. See HBASE-16074 for background. * @throws IOException */ @Test public void testNeverIncludeFakeCell() throws IOException { long now = EnvironmentEdgeManager.currentTime(); // Do with fam2 which has a col2 qualifier. UserScanQueryMatcher qm = UserScanQueryMatcher.create(scan, new ScanInfo(this.conf, fam2, 10, 1, ttl, KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false), get.getFamilyMap().get(fam2), now - ttl, now, null); Cell kv = new KeyValue(row1, fam2, col2, 1, data); Cell cell = PrivateCellUtil.createLastOnRowCol(kv); qm.setToNewRow(kv); MatchCode code = qm.match(cell); assertFalse(code.compareTo(MatchCode.SEEK_NEXT_COL) != 0); }
setCurrentCell(PrivateCellUtil.createLastOnRowCol(kv));
/** * Pick the next cell that the scanner should seek to. Since this can skip any number of cells * any of which can be a delete this can resurect old data. * * The method will only be used if canHint was set to true while creating the filter. * * @throws IOException This will never happen. */ @Override public Cell getNextCellHint(Cell currentCell) throws IOException { if (!canHint) { return null; } Long nextTimestampObject = timestamps.lower(currentCell.getTimestamp()); if (nextTimestampObject == null) { // This should only happen if the current column's // timestamp is below the last one in the list. // // It should never happen as the filterCell should return NEXT_COL // but it's always better to be extra safe and protect against future // behavioral changes. return PrivateCellUtil.createLastOnRowCol(currentCell); } // Since we know the nextTimestampObject isn't null here there must still be // timestamps that can be included. Cast the Long to a long and return the // a cell with the current row/cf/col and the next found timestamp. long nextTimestamp = nextTimestampObject; return PrivateCellUtil.createFirstOnRowColTS(currentCell, nextTimestamp); }
/** * Pick the next cell that the scanner should seek to. Since this can skip any number of cells * any of which can be a delete this can resurect old data. * * The method will only be used if canHint was set to true while creating the filter. * * @throws IOException This will never happen. */ @Override public Cell getNextCellHint(Cell currentCell) throws IOException { if (!canHint) { return null; } Long nextTimestampObject = timestamps.lower(currentCell.getTimestamp()); if (nextTimestampObject == null) { // This should only happen if the current column's // timestamp is below the last one in the list. // // It should never happen as the filterCell should return NEXT_COL // but it's always better to be extra safe and protect against future // behavioral changes. return PrivateCellUtil.createLastOnRowCol(currentCell); } // Since we know the nextTimestampObject isn't null here there must still be // timestamps that can be included. Cast the Long to a long and return the // a cell with the current row/cf/col and the next found timestamp. long nextTimestamp = nextTimestampObject; return PrivateCellUtil.createFirstOnRowColTS(currentCell, nextTimestamp); }
checkSeekingConsistency(encodedSeekers, seekBefore, sampleKv.get(sampleKv.size() - 1)); KeyValue midKv = sampleKv.get(sampleKv.size() / 2); Cell lastMidKv =PrivateCellUtil.createLastOnRowCol(midKv); checkSeekingConsistency(encodedSeekers, seekBefore, lastMidKv);
/** * This is a cryptic test. It is checking that we don't include a fake cell, one that has a * timestamp of {@link HConstants#OLDEST_TIMESTAMP}. See HBASE-16074 for background. * @throws IOException */ @Test public void testNeverIncludeFakeCell() throws IOException { long now = EnvironmentEdgeManager.currentTime(); // Do with fam2 which has a col2 qualifier. UserScanQueryMatcher qm = UserScanQueryMatcher.create(scan, new ScanInfo(this.conf, fam2, 10, 1, ttl, KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false), get.getFamilyMap().get(fam2), now - ttl, now, null); Cell kv = new KeyValue(row1, fam2, col2, 1, data); Cell cell = PrivateCellUtil.createLastOnRowCol(kv); qm.setToNewRow(kv); MatchCode code = qm.match(cell); assertFalse(code.compareTo(MatchCode.SEEK_NEXT_COL) != 0); }