@Override public int getRowOffset() { return this.kv.getRowOffset(); }
protected static String getRowString(final KeyValue kv) { return Bytes.toStringBinary(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength()); }
/** * Produces a string map for this key/value pair. Useful for programmatic use * and manipulation of the data stored in an WALKey, for example, printing * as JSON. Values are left out due to their tendency to be large. If needed, * they can be added manually. * * @return the Map<String,?> containing data from this key */ public Map<String, Object> toStringMap() { Map<String, Object> stringMap = new HashMap<>(); stringMap.put("row", Bytes.toStringBinary(getRowArray(), getRowOffset(), getRowLength())); stringMap.put("family", Bytes.toStringBinary(getFamilyArray(), getFamilyOffset(), getFamilyLength())); stringMap.put("qualifier", Bytes.toStringBinary(getQualifierArray(), getQualifierOffset(), getQualifierLength())); stringMap.put("timestamp", getTimestamp()); stringMap.put("vlen", getValueLength()); Iterator<Tag> tags = getTags(); if (tags != null) { List<String> tagsString = new ArrayList<String>(); while (tags.hasNext()) { tagsString.add(tags.next().toString()); } stringMap.put("tag", tagsString); } return stringMap; }
List<KeyValue> nkvs = new ArrayList<KeyValue>(tmp.size()); for (KeyValue kv : tmp) { if (filter.filterRowKey(kv.getBuffer(), kv.getRowOffset(), kv.getRowLength())) { filteredOnRowKey = true; break;
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()); }
private static void assertNext(boolean reverse, byte[] fuzzyRow, byte[] mask, byte[] current, byte[] expected) { KeyValue kv = KeyValueUtil.createFirstOnRow(current); byte[] nextForFuzzyRule = FuzzyRowFilter.getNextForFuzzyRule(reverse, kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(), fuzzyRow, mask); Assert.assertEquals(Bytes.toStringBinary(expected), Bytes.toStringBinary(nextForFuzzyRule)); } }
@Test public void testCreateKey() { byte[] row = "myRow".getBytes(); byte[] qualifier = "myQualifier".getBytes(); // Mimic what Storefile.createBloomKeyValue() does byte[] rowKey = KeyValueUtil.createFirstOnRow(row, 0, row.length, new byte[0], 0, 0, row, 0, 0).getKey(); byte[] rowColKey = KeyValueUtil.createFirstOnRow(row, 0, row.length, new byte[0], 0, 0, qualifier, 0, qualifier.length).getKey(); KeyValue rowKV = KeyValueUtil.createKeyValueFromKey(rowKey); KeyValue rowColKV = KeyValueUtil.createKeyValueFromKey(rowColKey); assertEquals(rowKV.getTimestamp(), rowColKV.getTimestamp()); assertEquals(Bytes.toStringBinary(rowKV.getRowArray(), rowKV.getRowOffset(), rowKV.getRowLength()), Bytes.toStringBinary(rowColKV.getRowArray(), rowColKV.getRowOffset(), rowColKV.getRowLength())); assertEquals(0, rowKV.getQualifierLength()); } }
private void testAdvancetHasSameRow(CellScanner scanner, final KeyValue kv) throws IOException { scanner.advance(); assertTrue(Bytes.equals(scanner.current().getRowArray(), scanner.current().getRowOffset(), scanner.current().getRowLength(), kv.getRowArray(), kv.getRowOffset(), kv.getRowLength())); } }
LOG.info("First top when key < bottom: " + keyKV); String tmp = Bytes.toString(keyKV.getRowArray(), keyKV.getRowOffset(), keyKV.getRowLength()); for (int i = 0; i < tmp.length(); i++) { assertTrue(tmp.charAt(i) == 'a'); String tmp = Bytes.toString(keyKV.getRowArray(), keyKV.getRowOffset(), keyKV.getRowLength()); for (int i = 0; i < tmp.length(); i++) { assertTrue(tmp.charAt(i) == 'z'); keyKV = KeyValueUtil.createKeyValueFromKey(key); LOG.info("First bottom when key > top: " + keyKV); tmp = Bytes.toString(keyKV.getRowArray(), keyKV.getRowOffset(), keyKV.getRowLength()); for (int i = 0; i < tmp.length(); i++) { assertTrue(tmp.charAt(i) == 'a'); LOG.info("Last bottom when key > top: " + keyKV); for (int i = 0; i < tmp.length(); i++) { assertTrue(Bytes.toString(keyKV.getRowArray(), keyKV.getRowOffset(), keyKV.getRowLength()) .charAt(i) == 'z');
new ArrayBackedTag((byte) 1, metaValue1), new ArrayBackedTag((byte) 2, metaValue2) }); assertTrue(kv.getTagsLength() > 0); assertTrue(Bytes.equals(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(), row, 0, row.length)); assertTrue(Bytes.equals(kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength(), cf, 0,
@Override public void getKey(ImmutableBytesWritable ptr) { KeyValue value = values.get(0); ptr.set(value.getBuffer(), value.getRowOffset(), value.getRowLength()); }
public void setKey(KeyValue keyValue) { if (keyValue == null) { throw new IllegalArgumentException(); } keyPtr.set(keyValue.getBuffer(), keyValue.getRowOffset(), keyValue.getRowLength()); }
@Override public ReturnCode filterKeyValue(KeyValue kv) { return navigate(kv.getBuffer(), kv.getRowOffset(),kv.getRowLength(),Terminate.AFTER); }
public static void getKey(KeyValue value, ImmutableBytesWritable key) { key.set(value.getBuffer(), value.getRowOffset(), value.getRowLength()); }
public ProjectedValueTuple projectResults(Tuple tuple) { byte[] bytesValue = schema.toBytes(tuple, expressions, valueSet, ptr); KeyValue base = tuple.getValue(0); return new ProjectedValueTuple(base.getBuffer(), base.getRowOffset(), base.getRowLength(), base.getTimestamp(), bytesValue, valueSet.getEstimatedLength()); }
@Override public KeyValue getHint(KeyValue kv) { return KeyValue.createLastOnRow(kv.getBuffer(), kv.getRowOffset(), kv.getRowLength(), kv.getBuffer(), kv.getFamilyOffset(), kv.getFamilyLength(), kv.getBuffer(), kv.getQualifierOffset(), kv.getQualifierLength()); } }
@SuppressWarnings("deprecation") @Override public void examine(SkipScanFilter skipper) throws IOException { KeyValue kv = KeyValueUtil.createFirstOnRow(rowkey); skipper.reset(); assertFalse(skipper.filterAllRemaining()); assertFalse(skipper.filterRowKey(kv.getBuffer(), kv.getRowOffset(), kv.getRowLength())); assertEquals(ReturnCode.SEEK_NEXT_USING_HINT, skipper.filterKeyValue(kv)); assertEquals(KeyValueUtil.createFirstOnRow(hint), skipper.getNextCellHint(kv)); }
@Override public void examine(SkipScanFilter skipper) { KeyValue kv = KeyValue.createFirstOnRow(rowkey); skipper.reset(); assertFalse(skipper.filterAllRemaining()); assertFalse(skipper.filterRowKey(kv.getBuffer(), kv.getRowOffset(), kv.getRowLength())); assertEquals(ReturnCode.SEEK_NEXT_USING_HINT, skipper.filterKeyValue(kv)); assertEquals(KeyValue.createFirstOnRow(hint), skipper.getNextKeyHint(kv)); }
@SuppressWarnings("deprecation") @Override public void examine(SkipScanFilter skipper) throws IOException { KeyValue kv = KeyValueUtil.createFirstOnRow(rowkey); skipper.reset(); assertFalse(skipper.filterAllRemaining()); assertFalse(skipper.filterRowKey(kv.getBuffer(), kv.getRowOffset(), kv.getRowLength())); assertEquals(kv.toString(), ReturnCode.INCLUDE_AND_NEXT_COL, skipper.filterKeyValue(kv)); }
@Override public void examine(SkipScanFilter skipper) { KeyValue kv = KeyValue.createFirstOnRow(rowkey); skipper.reset(); assertFalse(skipper.filterAllRemaining()); assertFalse(skipper.filterRowKey(kv.getBuffer(), kv.getRowOffset(), kv.getRowLength())); assertEquals(kv.toString(), ReturnCode.INCLUDE, skipper.filterKeyValue(kv)); }