/** * Based on the nextKv in the heap, and the current row, decide whether or not there are more * cells to be read in the heap. If the row of the nextKv in the heap matches the current row * then there are more cells to be read in the row. * @param nextKv * @param currentRowCell * @return true When there are more cells in the row to be read */ private boolean moreCellsInRow(final Cell nextKv, Cell currentRowCell) { return nextKv != null && CellUtil.matchingRows(nextKv, currentRowCell); }
/** * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. * Instead use {@link #matchingRows(Cell, byte[])} */ @Deprecated public static boolean matchingRow(final Cell left, final byte[] buf) { return matchingRows(left, buf); }
/** * @param left * @param right * @return True if the rows in <code>left</code> and <code>right</code> Cells match * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. * Instead use {@link #matchingRows(Cell, Cell)} */ @Deprecated public static boolean matchingRow(final Cell left, final Cell right) { return matchingRows(left, right); }
@Override protected boolean isNewKey(Cell cell) { if (this.getLastCell() != null) { return !CellUtil.matchingRows(cell, this.getLastCell()); } return true; } }
/** * @param previousCell * @param cell * @return True if we have crossed over onto a new row or type */ private boolean isNewRowOrType(final Cell previousCell, final Cell cell) { return previousCell == null || previousCell.getTypeByte() != cell.getTypeByte() || !CellUtil.matchingRows(previousCell, cell); }
@Override protected void checkScanOrder(Cell prevKV, Cell kv, CellComparator comparator) throws IOException { // Check that the heap gives us KVs in an increasing order for same row and // decreasing order for different rows. assert prevKV == null || comparator == null || comparator.compareRows(kv, prevKV) < 0 || (CellUtil.matchingRows(kv, prevKV) && comparator.compare(kv, prevKV) >= 0) : "Key " + prevKV + " followed by a " + "error order key " + kv + " in cf " + store + " in reversed scan"; }
@Override protected void seekScanners(List<? extends KeyValueScanner> scanners, Cell seekKey, boolean isLazy, boolean isParallelSeek) throws IOException { // Seek all scanners to the start of the Row (or if the exact matching row // key does not exist, then to the start of the previous matching Row). if (CellUtil.matchingRows(seekKey, HConstants.EMPTY_START_ROW)) { for (KeyValueScanner scanner : scanners) { scanner.seekToLastRow(); } } else { for (KeyValueScanner scanner : scanners) { scanner.backwardSeek(seekKey); } } }
/** * @param currentRowCell * @return true when the joined heap may have data for the current row * @throws IOException */ private boolean joinedHeapMayHaveData(Cell currentRowCell) throws IOException { Cell nextJoinedKv = joinedHeap.peek(); boolean matchCurrentRow = nextJoinedKv != null && CellUtil.matchingRows(nextJoinedKv, currentRowCell); boolean matchAfterSeek = false; // If the next value in the joined heap does not match the current row, try to seek to the // correct row if (!matchCurrentRow) { Cell firstOnCurrentRow = PrivateCellUtil.createFirstOnRow(currentRowCell); boolean seekSuccessful = this.joinedHeap.requestSeek(firstOnCurrentRow, true, true); matchAfterSeek = seekSuccessful && joinedHeap.peek() != null && CellUtil.matchingRows(joinedHeap.peek(), currentRowCell); } return matchCurrentRow || matchAfterSeek; }
/**************** equals ****************************/ public static boolean equals(Cell a, Cell b) { return matchingRows(a, b) && matchingFamily(a, b) && matchingQualifier(a, b) && matchingTimestamp(a, b) && PrivateCellUtil.matchingType(a, b); }
@Override public boolean backwardSeek(Cell seekKey) throws IOException { if (current == null) { return false; } heap.add(current); current = null; KeyValueScanner scanner; while ((scanner = heap.poll()) != null) { Cell topKey = scanner.peek(); if ((CellUtil.matchingRows(seekKey, topKey) && comparator .getComparator().compare(seekKey, topKey) <= 0) || comparator.getComparator().compareRows(seekKey, topKey) > 0) { heap.add(scanner); current = pollRealKV(); return current != null; } if (!scanner.backwardSeek(seekKey)) { this.scannersForDelayedClose.add(scanner); } else { heap.add(scanner); } } return false; }
private void resetQueryMatcher(Cell lastTopKey) { // Reset the state of the Query Matcher and set to top row. // Only reset and call setRow if the row changes; avoids confusing the // query matcher if scanning intra-row. Cell cell = heap.peek(); if (cell == null) { cell = lastTopKey; } if ((matcher.currentRow() == null) || !CellUtil.matchingRows(cell, matcher.currentRow())) { this.countPerRow = 0; // The setToNewRow will call reset internally matcher.setToNewRow(cell); } }
/** * special case for Cell.equals */ public static boolean equalsIgnoreMvccVersion(Cell a, Cell b) { // row boolean res = CellUtil.matchingRows(a, b); if (!res) return res; // family res = CellUtil.matchingColumn(a, b); if (!res) return res; // timestamp: later sorts first if (!CellUtil.matchingTimestamp(a, b)) return false; // type int c = (0xff & b.getTypeByte()) - (0xff & a.getTypeByte()); if (c != 0) return false; else return true; }
private static void verifyData(Cell kv, String expectedRow, String expectedCol, long expectedVersion) { assertTrue("RowCheck", CellUtil.matchingRows(kv, Bytes.toBytes(expectedRow))); assertTrue("ColumnCheck", CellUtil.matchingQualifier(kv, Bytes.toBytes(expectedCol))); assertEquals("TSCheck", expectedVersion, kv.getTimestamp()); assertTrue("ValueCheck", CellUtil.matchingValue(kv, genValue(expectedRow, expectedCol, expectedVersion))); }
protected boolean nextRow(ScannerContext scannerContext, Cell curRowCell) throws IOException { assert this.joinedContinuationRow == null: "Trying to go to next row during joinedHeap read."; Cell next; while ((next = this.storeHeap.peek()) != null && CellUtil.matchingRows(next, curRowCell)) { this.storeHeap.next(MOCKED_LIST); } resetFilters(); // Calling the hook in CP which allows it to do a fast forward return this.region.getCoprocessorHost() == null || this.region.getCoprocessorHost() .postScannerFilterRow(this, curRowCell); }
/** * Do a small get/scan against one store. This is required because store * has no actual methods of querying itself, and relies on StoreScanner. */ public static List<Cell> getFromStoreFile(HStore store, Get get) throws IOException { Scan scan = new Scan(get); InternalScanner scanner = (InternalScanner) store.getScanner(scan, scan.getFamilyMap().get(store.getColumnFamilyDescriptor().getName()), // originally MultiVersionConcurrencyControl.resetThreadReadPoint() was called to set // readpoint 0. 0); List<Cell> result = new ArrayList<>(); scanner.next(result); if (!result.isEmpty()) { // verify that we are on the row we want: Cell kv = result.get(0); if (!CellUtil.matchingRows(kv, get.getRow())) { result.clear(); } } scanner.close(); return result; }
/** * Compares the row and column of two keyvalues for equality * @param left * @param right * @return True if same row and column. */ public static boolean matchingRowColumn(final Cell left, final Cell right) { if ((left.getRowLength() + left.getFamilyLength() + left.getQualifierLength()) != (right.getRowLength() + right.getFamilyLength() + right.getQualifierLength())) { return false; } if (!matchingRows(left, right)) { return false; } return matchingColumn(left, right); }
private Predicate<Cell> checkVersion(Cell firstCell, int version) { if (version == 0) { return c -> true; } else { if (row == null || !CellUtil.matchingRows(firstCell, row)) { row = CellUtil.cloneRow(firstCell); // reset qualifier as there is a row change qualifier = null; } return c -> { if (qualifier != null && CellUtil.matchingQualifier(c, qualifier)) { if (count >= version) { return true; } count++; return false; } else { // qualifier switch qualifier = CellUtil.cloneQualifier(c); count = 1; return false; } }; } }
private void verifyData( final HRegion newReg, final int startRow, final int numRows, final byte[]... families) throws IOException { for (int i = startRow; i < startRow + numRows; i++) { byte[] row = Bytes.toBytes("" + i); Get get = new Get(row); Result result = newReg.get(get); Cell[] raw = result.rawCells(); assertEquals(families.length, result.size()); for (int j = 0; j < families.length; j++) { assertTrue(CellUtil.matchingRows(raw[j], row)); assertTrue(CellUtil.matchingFamily(raw[j], families[j])); } } }
static void verifyData(HRegion newReg, int startRow, int numRows, byte[] qf, byte[]... families) throws IOException { for (int i = startRow; i < startRow + numRows; i++) { byte[] row = Bytes.toBytes("" + i); Get get = new Get(row); for (byte[] family : families) { get.addColumn(family, qf); } Result result = newReg.get(get); Cell[] raw = result.rawCells(); assertEquals(families.length, result.size()); for (int j = 0; j < families.length; j++) { assertTrue(CellUtil.matchingRows(raw[j], row)); assertTrue(CellUtil.matchingFamily(raw[j], families[j])); assertTrue(CellUtil.matchingQualifier(raw[j], qf)); } } }
private void verifyData(Region newReg, int startRow, int numRows, byte[] qf, byte[]... families) throws IOException { for (int i = startRow; i < startRow + numRows; i++) { byte[] row = Bytes.toBytes("" + i); Get get = new Get(row); for (byte[] family : families) { get.addColumn(family, qf); } Result result = newReg.get(get); Cell[] raw = result.rawCells(); assertEquals(families.length, result.size()); for (int j = 0; j < families.length; j++) { assertTrue(CellUtil.matchingRows(raw[j], row)); assertTrue(CellUtil.matchingFamily(raw[j], families[j])); assertTrue(CellUtil.matchingQualifier(raw[j], qf)); } } }