Java Code Examples for org.apache.hadoop.hbase.client.Result#mayHaveMoreCellsInRow()
The following examples show how to use
org.apache.hadoop.hbase.client.Result#mayHaveMoreCellsInRow() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestPartialResultsFromClientSide.java From hbase with Apache License 2.0 | 5 votes |
public void testPartialResultsAndBatch(final int batch, final int cellsPerPartialResult) throws Exception { if (LOG.isInfoEnabled()) { LOG.info("batch: " + batch + " cellsPerPartialResult: " + cellsPerPartialResult); } Scan scan = new Scan(); scan.setMaxResultSize(getResultSizeForNumberOfCells(cellsPerPartialResult)); scan.setBatch(batch); ResultScanner scanner = TABLE.getScanner(scan); Result result = scanner.next(); int repCount = 0; while ((result = scanner.next()) != null) { assertTrue(result.rawCells() != null); if (result.mayHaveMoreCellsInRow()) { final String error = "Cells:" + result.rawCells().length + " Batch size:" + batch + " cellsPerPartialResult:" + cellsPerPartialResult + " rep:" + repCount; assertTrue(error, result.rawCells().length == batch); } else { assertTrue(result.rawCells().length <= batch); } repCount++; } scanner.close(); }
Example 2
Source File: TestPartialResultsFromClientSide.java From hbase with Apache License 2.0 | 5 votes |
public void testPartialResultsReassembly(Scan scanBase) throws Exception { Scan partialScan = new Scan(scanBase); partialScan.setMaxResultSize(1); partialScan.setAllowPartialResults(true); ResultScanner partialScanner = TABLE.getScanner(partialScan); Scan oneShotScan = new Scan(scanBase); oneShotScan.setMaxResultSize(Long.MAX_VALUE); ResultScanner oneShotScanner = TABLE.getScanner(oneShotScan); ArrayList<Result> partials = new ArrayList<>(); for (int i = 0; i < NUM_ROWS; i++) { Result partialResult = null; Result completeResult = null; Result oneShotResult = null; partials.clear(); do { partialResult = partialScanner.next(); partials.add(partialResult); } while (partialResult != null && partialResult.mayHaveMoreCellsInRow()); completeResult = Result.createCompleteResult(partials); oneShotResult = oneShotScanner.next(); compareResults(completeResult, oneShotResult, null); } assertTrue(oneShotScanner.next() == null); assertTrue(partialScanner.next() == null); oneShotScanner.close(); partialScanner.close(); }
Example 3
Source File: TestPartialResultsFromClientSide.java From hbase with Apache License 2.0 | 4 votes |
public void testOrderingOfCellsInPartialResults(final Scan basePartialScan) throws Exception { // Scan that retrieves results in pieces (partials). By setting allowPartialResults to be true // the results will NOT be reconstructed and instead the caller will see the partial results // returned by the server Scan partialScan = new Scan(basePartialScan); partialScan.setAllowPartialResults(true); ResultScanner partialScanner = TABLE.getScanner(partialScan); // Scan that retrieves all table results in single RPC request Scan oneShotScan = new Scan(basePartialScan); oneShotScan.setMaxResultSize(Long.MAX_VALUE); oneShotScan.setCaching(ROWS.length); ResultScanner oneShotScanner = TABLE.getScanner(oneShotScan); Result oneShotResult = oneShotScanner.next(); Result partialResult = null; int iterationCount = 0; while (oneShotResult != null && oneShotResult.rawCells() != null) { List<Cell> aggregatePartialCells = new ArrayList<>(); do { partialResult = partialScanner.next(); assertTrue("Partial Result is null. iteration: " + iterationCount, partialResult != null); assertTrue("Partial cells are null. iteration: " + iterationCount, partialResult.rawCells() != null); for (Cell c : partialResult.rawCells()) { aggregatePartialCells.add(c); } } while (partialResult.mayHaveMoreCellsInRow()); assertTrue("Number of cells differs. iteration: " + iterationCount, oneShotResult.rawCells().length == aggregatePartialCells.size()); final Cell[] oneShotCells = oneShotResult.rawCells(); for (int cell = 0; cell < oneShotCells.length; cell++) { Cell oneShotCell = oneShotCells[cell]; Cell partialCell = aggregatePartialCells.get(cell); assertTrue("One shot cell was null", oneShotCell != null); assertTrue("Partial cell was null", partialCell != null); assertTrue("Cell differs. oneShotCell:" + oneShotCell + " partialCell:" + partialCell, oneShotCell.equals(partialCell)); } oneShotResult = oneShotScanner.next(); iterationCount++; } assertTrue(partialScanner.next() == null); partialScanner.close(); oneShotScanner.close(); }