@Test public void testSkipFiltering() throws Exception { long timestamp = System.currentTimeMillis(); Filter filter = new CellSkipFilter(new MyFilter(0)); assertEquals(Filter.ReturnCode.INCLUDE, filter.filterKeyValue(newKeyValue(ROW1KEY, FAM1KEY, COL1KEY, VALUE, timestamp))); assertEquals(Filter.ReturnCode.INCLUDE_AND_NEXT_COL, filter.filterKeyValue(newKeyValue(ROW1KEY, FAM1KEY, COL1KEY, VALUE, timestamp - 1))); assertEquals(Filter.ReturnCode.NEXT_COL, filter.filterKeyValue(newKeyValue(ROW1KEY, FAM1KEY, COL1KEY, VALUE, timestamp - 2))); assertEquals(Filter.ReturnCode.NEXT_COL, filter.filterKeyValue(newKeyValue(ROW1KEY, FAM1KEY, COL1KEY, VALUE, timestamp - 3))); assertEquals(Filter.ReturnCode.SKIP, filter.filterKeyValue(newKeyValue(ROW1KEY, FAM2KEY, COL1KEY, VALUE, timestamp - 4))); filter = new CellSkipFilter(new MyFilter(2)); assertEquals(Filter.ReturnCode.SKIP, filter.filterKeyValue(newKeyValue(ROW1KEY, FAM1KEY, COL1KEY, VALUE, timestamp))); assertEquals(Filter.ReturnCode.NEXT_COL, filter.filterKeyValue(newKeyValue(ROW1KEY, FAM1KEY, COL1KEY, VALUE, timestamp - 1))); assertEquals(Filter.ReturnCode.NEXT_COL, filter.filterKeyValue(newKeyValue(ROW1KEY, FAM1KEY, COL1KEY, VALUE, timestamp - 2))); assertEquals(Filter.ReturnCode.NEXT_COL, filter.filterKeyValue(newKeyValue(ROW1KEY, FAM1KEY, COL1KEY, VALUE, timestamp - 3))); assertEquals(Filter.ReturnCode.NEXT_ROW, filter.filterKeyValue(newKeyValue(ROW1KEY, FAM1KEY, COL2KEY, VALUE, timestamp - 4))); assertEquals(Filter.ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(newKeyValue(ROW2KEY, FAM1KEY, COL1KEY, VALUE, timestamp - 5))); }
@Override public ReturnCode filterKeyValue(Cell cell) throws IOException { if (skipCellVersion(cell)) { return ReturnCode.NEXT_COL; } ReturnCode code = filter.filterKeyValue(cell); if (code == ReturnCode.NEXT_COL || code == ReturnCode.INCLUDE_AND_NEXT_COL) { skipColumn = KeyValue.createFirstOnRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); } else { skipColumn = null; } return code; }
CellSkipFilter extends FilterBase { @Override public ReturnCode filterKeyValue(Cell cell) throws IOException { if (skipCellVersion(cell)) { return ReturnCode.NEXT_COL; } ReturnCode code = filter.filterKeyValue(cell); if (code == ReturnCode.NEXT_COL || code == ReturnCode.INCLUDE_AND_NEXT_COL) { skipColumn = KeyValue.createFirstOnRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); } else { skipColumn = null; } return code; } }
CellSkipFilter extends FilterBase { @Override public ReturnCode filterKeyValue(Cell cell) throws IOException { if (skipCellVersion(cell)) { return ReturnCode.NEXT_COL; } ReturnCode code = filter.filterKeyValue(cell); if (code == ReturnCode.NEXT_COL || code == ReturnCode.INCLUDE_AND_NEXT_COL) { skipColumn = KeyValue.createFirstOnRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); } else { skipColumn = null; } return code; } CellSkipFilter(Filter filter); }
CellSkipFilter extends FilterBase { @Override public ReturnCode filterKeyValue(Cell cell) throws IOException { if (skipCellVersion(cell)) { return ReturnCode.NEXT_COL; } ReturnCode code = filter.filterKeyValue(cell); if (code == ReturnCode.NEXT_COL || code == ReturnCode.INCLUDE_AND_NEXT_COL) { skipColumn = KeyValue.createFirstOnRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); } else { skipColumn = null; } return code; } CellSkipFilter(Filter filter); @Override ReturnCode filterKeyValue(Cell cell); @Override boolean filterRow(); @Override Cell transformCell(Cell cell); @Override void reset(); @Override boolean filterRowKey(byte[] buffer, int offset, int length); @Override boolean filterAllRemaining(); @Override void filterRowCells(List<Cell> kvs); @Override boolean hasFilterRow(); @SuppressWarnings("deprecation") @Override KeyValue getNextKeyHint(KeyValue currentKV); @Override Cell getNextCellHint(Cell currentKV); @Override boolean isFamilyEssential(byte[] name); @Override byte[] toByteArray(); }
CellSkipFilter extends FilterBase { @Override public ReturnCode filterKeyValue(Cell cell) throws IOException { if (skipCellVersion(cell)) { return ReturnCode.NEXT_COL; } ReturnCode code = filter.filterKeyValue(cell); if (code == ReturnCode.NEXT_COL || code == ReturnCode.INCLUDE_AND_NEXT_COL) { skipColumn = KeyValue.createFirstOnRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); } else { skipColumn = null; } return code; } CellSkipFilter(Filter filter); @Override ReturnCode filterKeyValue(Cell cell); @Override boolean filterRow(); @Override Cell transformCell(Cell cell); @Override void reset(); @Override boolean filterRowKey(byte[] buffer, int offset, int length); @Override boolean filterAllRemaining(); @Override void filterRowCells(List<Cell> kvs); @Override boolean hasFilterRow(); @SuppressWarnings("deprecation") @Override KeyValue getNextKeyHint(KeyValue currentKV); @Override Cell getNextCellHint(Cell currentKV); @Override boolean isFamilyEssential(byte[] name); @Override byte[] toByteArray();  }