/** * Returns true if the given cell is a serialized {@link CompactionDescriptor} * * @see #getCompaction(Cell) */ public static boolean isCompactionMarker(Cell cell) { return CellUtil.matchingColumn(cell, METAFAMILY, COMPACTION); }
@Override public void filterRowCells(List<Cell> kvs) { Iterator<? extends Cell> it = kvs.iterator(); while (it.hasNext()) { // If the current column is actually the tested column, // we will skip it instead. if (CellUtil.matchingColumn(it.next(), this.columnFamily, this.columnQualifier)) { it.remove(); } } }
@Override public ReturnCode filterCell(final Cell c) { // System.out.println("REMOVE KEY=" + keyValue.toString() + ", value=" + Bytes.toString(keyValue.getValue())); if (this.matchedColumn) { // We already found and matched the single column, all keys now pass return ReturnCode.INCLUDE; } else if (this.latestVersionOnly && this.foundColumn) { // We found but did not match the single column, skip to next row return ReturnCode.NEXT_ROW; } if (!CellUtil.matchingColumn(c, this.columnFamily, this.columnQualifier)) { return ReturnCode.INCLUDE; } foundColumn = true; if (filterColumnValue(c)) { return this.latestVersionOnly? ReturnCode.NEXT_ROW: ReturnCode.INCLUDE; } this.matchedColumn = true; return ReturnCode.INCLUDE; }
/** * Deserialized and returns a BulkLoadDescriptor from the passed in Cell * @param cell the key value * @return deserialized BulkLoadDescriptor or null. */ public static WALProtos.BulkLoadDescriptor getBulkLoadDescriptor(Cell cell) throws IOException { if (CellUtil.matchingColumn(cell, METAFAMILY, BULK_LOAD)) { return WALProtos.BulkLoadDescriptor.parseFrom(CellUtil.cloneValue(cell)); } return null; }
public static FlushDescriptor getFlushDescriptor(Cell cell) throws IOException { if (CellUtil.matchingColumn(cell, METAFAMILY, FLUSH)) { return FlushDescriptor.parseFrom(CellUtil.cloneValue(cell)); } return null; }
public static RegionEventDescriptor getRegionEventDescriptor(Cell cell) throws IOException { if (CellUtil.matchingColumn(cell, METAFAMILY, REGION_EVENT)) { return RegionEventDescriptor.parseFrom(CellUtil.cloneValue(cell)); } return null; }
if (CellUtil.matchingColumn(kvs[i], family,qualifier)) { result.add(kvs[i]); } else {
/** * The Cell for the most recent timestamp for a given column. * * @param family * @param qualifier * * @return the Cell for the column, or null if no value exists in the row or none have been * selected in the query (Get/Scan) */ public Cell getColumnLatestCell(byte [] family, byte [] qualifier) { Cell [] kvs = rawCells(); // side effect possibly. if (kvs == null || kvs.length == 0) { return null; } int pos = binarySearch(kvs, family, qualifier); if (pos == -1) { return null; } if (CellUtil.matchingColumn(kvs[pos], family, qualifier)) { return kvs[pos]; } return null; }
@Override public ReturnCode filterCell(final Cell c) { // Check if the column and qualifier match if (!CellUtil.matchingColumn(c, this.columnFamily, this.columnQualifier)) { // include non-matches for the time being, they'll be discarded afterwards return ReturnCode.INCLUDE; } // If it doesn't pass the op, skip it if (comparator != null && compareValue(getCompareOperator(), comparator, c)) return ReturnCode.SKIP; stampSet.add(c.getTimestamp()); if(dropDependentColumn) { return ReturnCode.SKIP; } return ReturnCode.INCLUDE; }
@Override public ReturnCode filterCell(Cell c) throws IOException { // 1. Check column match if (!CellUtil.matchingColumn(c, this.family, this.qualifier)) { return columnFound ? ReturnCode.NEXT_ROW : ReturnCode.NEXT_COL; } // Column found columnFound = true; // 2. Check value match: // True means filter out, just skip this cell, else include it. return compareValue(getCompareOperator(), getComparator(), c) ? ReturnCode.SKIP : ReturnCode.INCLUDE; }
/** * Test a corner case when the family qualifier is a prefix of the * column qualifier. */ @Test public void testColumnCompare_prefix() throws Exception { final byte [] a = Bytes.toBytes("aaa"); byte [] family1 = Bytes.toBytes("abc"); byte [] qualifier1 = Bytes.toBytes("def"); byte [] family2 = Bytes.toBytes("ab"); byte [] qualifier2 = Bytes.toBytes("def"); KeyValue aaa = new KeyValue(a, family1, qualifier1, 0L, KeyValue.Type.Put, a); assertFalse(CellUtil.matchingColumn(aaa, family2, qualifier2)); }
@Override public Cell filterCell(Entry entry, Cell cell) { NavigableMap<byte[], Integer> scopes = entry.getKey().getReplicationScopes(); if (scopes == null || scopes.isEmpty()) { return null; } byte[] family = CellUtil.cloneFamily(cell); if (CellUtil.matchingColumn(cell, WALEdit.METAFAMILY, WALEdit.BULK_LOAD)) { return bulkLoadFilter.filterCell(cell, new Predicate<byte[]>() { @Override public boolean apply(byte[] family) { return !hasGlobalScope(scopes, family); } }); } return hasGlobalScope(scopes, family) ? cell : null; } }
return CellUtil.matchingColumn(prevCell, currentCell) ? ReturnCode.NEXT_COL : null; case NEXT_ROW: case INCLUDE_AND_SEEK_NEXT_ROW:
@Test public void testColumnCompare() throws Exception { final byte [] a = Bytes.toBytes("aaa"); byte [] family1 = Bytes.toBytes("abc"); byte [] qualifier1 = Bytes.toBytes("def"); byte [] family2 = Bytes.toBytes("abcd"); byte [] qualifier2 = Bytes.toBytes("ef"); KeyValue aaa = new KeyValue(a, family1, qualifier1, 0L, KeyValue.Type.Put, a); assertFalse(CellUtil.matchingColumn(aaa, family2, qualifier2)); assertTrue(CellUtil.matchingColumn(aaa, family1, qualifier1)); aaa = new KeyValue(a, family2, qualifier2, 0L, KeyValue.Type.Put, a); assertFalse(CellUtil.matchingColumn(aaa, family1, qualifier1)); assertTrue(CellUtil.matchingColumn(aaa, family2,qualifier2)); byte [] nullQualifier = new byte[0]; aaa = new KeyValue(a, family1, nullQualifier, 0L, KeyValue.Type.Put, a); assertTrue(CellUtil.matchingColumn(aaa, family1,null)); assertFalse(CellUtil.matchingColumn(aaa, family2,qualifier2)); }
/** * 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; }
/** * 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); }
assertTrue(CellUtil.matchingColumn(results.get(0), CELL_WITH_VERSIONS[0])); assertTrue(CellUtil.matchingColumn(results.get(1), CELL_WITH_VERSIONS[2])); assertTrue("Optimize should do some optimizations", scannerNoOptimize.optimization.get() == 0); assertTrue(CellUtil.matchingColumn(results.get(0), CELL_WITH_VERSIONS[0])); assertTrue(CellUtil.matchingColumn(results.get(1), CELL_WITH_VERSIONS[2])); assertTrue("Optimize should do some optimizations", scanner.optimization.get() > 0);
if (CellUtil.matchingColumn(cell, WALEdit.METAFAMILY, WALEdit.BULK_LOAD)) { cell = bulkLoadFilter.filterCell(cell, fam -> filterByExcludeTableCfs(entry.getKey().getTableName(), Bytes.toString(fam), if (CellUtil.matchingColumn(cell, WALEdit.METAFAMILY, WALEdit.BULK_LOAD)) { cell = bulkLoadFilter.filterCell(cell, fam -> filterByTableCfs(entry.getKey().getTableName(), Bytes.toString(fam), tableCfs));
private void check(final byte [] row, final byte [] family, byte [] qualifier, final long timestamp, final byte [] value) { KeyValue kv = new KeyValue(row, family, qualifier, timestamp, value); assertTrue(Bytes.compareTo(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(), row, 0, row.length) == 0); assertTrue(CellUtil.matchingColumn(kv, family, qualifier)); // Call toString to make sure it works. LOG.info(kv.toString()); }
assertTrue(CellUtil.matchingValue(kv, bbCell2)); assertTrue(CellUtil.matchingValue(bbCell1, v)); assertFalse(CellUtil.matchingColumn(bbCell1, bbCell2)); assertTrue(CellUtil.matchingColumn(kv, bbCell2)); assertTrue(CellUtil.matchingColumn(bbCell1, f, q1)); assertTrue(CellUtil.matchingColumn(bbCell2, f, q2));