@Override public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException { boolean ret = scanner.next(result, scannerContext); for (int i = 0; i < result.size(); i++) { Cell c = result.get(i); // Replace the Cell if the value is the one we're replacing if (CellUtil.isPut(c) && comparator.compare(CellUtil.cloneValue(c), sourceValue) == 0) { try { cellBuilder.setRow(CellUtil.copyRow(c)); cellBuilder.setFamily(CellUtil.cloneFamily(c)); cellBuilder.setQualifier(CellUtil.cloneQualifier(c)); cellBuilder.setTimestamp(c.getTimestamp()); cellBuilder.setType(Cell.Type.Put); // Make sure each cell gets a unique value byte[] clonedValue = new byte[replacedValue.length]; System.arraycopy(replacedValue, 0, clonedValue, 0, replacedValue.length); cellBuilder.setValue(clonedValue); result.set(i, cellBuilder.build()); } finally { cellBuilder.clear(); } } } return ret; }
assertTrue(cs.advance()); Cell c = cs.current(); assertTrue(CellUtil.isPut(c)); assertFalse(CellUtil.isDelete(c)); assertFalse(cs.advance()); assertFalse("Cell should not be a Put: " + c, CellUtil.isPut(c)); c = cs.current(); assertFalse("Cell should not be a Delete: " + c, CellUtil.isDelete(c)); assertTrue("Cell should be a Put: " + c, CellUtil.isPut(c));
private void assertNoIndexDeletes(Connection conn, long minTimestamp, String fullIndexName) throws IOException, SQLException { if (!this.mutable) { PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); PTable index = pconn.getTable(new PTableKey(null, fullIndexName)); byte[] physicalIndexTable = index.getPhysicalName().getBytes(); try (Table hIndex = pconn.getQueryServices().getTable(physicalIndexTable)) { Scan scan = new Scan(); scan.setRaw(true); if (this.transactional) { minTimestamp = TransactionUtil.convertToNanoseconds(minTimestamp); } scan.setTimeRange(minTimestamp, HConstants.LATEST_TIMESTAMP); ResultScanner scanner = hIndex.getScanner(scan); Result result; while ((result = scanner.next()) != null) { CellScanner cellScanner = result.cellScanner(); while (cellScanner.advance()) { Cell current = cellScanner.current(); assertTrue(CellUtil.isPut(current)); } } }; } }
@Override public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException { boolean ret = scanner.next(result, scannerContext); for (int i = 0; i < result.size(); i++) { Cell c = result.get(i); // Replace the Cell if the value is the one we're replacing if (CellUtil.isPut(c) && comparator.compare(CellUtil.cloneValue(c), sourceValue) == 0) { try { cellBuilder.setRow(CellUtil.copyRow(c)); cellBuilder.setFamily(CellUtil.cloneFamily(c)); cellBuilder.setQualifier(CellUtil.cloneQualifier(c)); cellBuilder.setTimestamp(c.getTimestamp()); cellBuilder.setType(Cell.Type.Put); // Make sure each cell gets a unique value byte[] clonedValue = new byte[replacedValue.length]; System.arraycopy(replacedValue, 0, clonedValue, 0, replacedValue.length); cellBuilder.setValue(clonedValue); result.set(i, cellBuilder.build()); } finally { cellBuilder.clear(); } } } return ret; }
assertTrue(cs.advance()); Cell c = cs.current(); assertTrue(CellUtil.isPut(c)); assertFalse(CellUtil.isDelete(c)); assertFalse(cs.advance()); assertFalse("Cell should not be a Put: " + c, CellUtil.isPut(c)); c = cs.current(); assertFalse("Cell should not be a Delete: " + c, CellUtil.isDelete(c)); assertTrue("Cell should be a Put: " + c, CellUtil.isPut(c));