@Override protected void hash(DataOutput hasher, Key k) throws IOException { ByteSequence row = k.getRowData(); hasher.write(row.getBackingArray(), row.offset(), row.length()); } }
/** * Make a new key with a column family, column qualifier, and column visibility. Copy the rest of * the parts of the key (including delete flag) from {@code originalKey}. */ protected Key replaceKeyParts(Key originalKey, Text newColFam, Text newColQual, Text newColVis) { byte[] row = originalKey.getRowData().toArray(); byte[] cf = newColFam.getBytes(); byte[] cq = newColQual.getBytes(); byte[] cv = newColVis.getBytes(); long timestamp = originalKey.getTimestamp(); Key newKey = new Key(row, 0, row.length, cf, 0, newColFam.getLength(), cq, 0, newColQual.getLength(), cv, 0, newColVis.getLength(), timestamp); newKey.setDeleted(originalKey.isDeleted()); return newKey; }
@Override public Key transform(org.apache.accumulo.core.data.Key acuKey) { byte keyData[]; ByteSequence row = acuKey.getRowData(); keyData = new byte[row.length()]; System.arraycopy(row.getBackingArray(), 0, keyData, 0, row.length()); return new Key(keyData, 1.0); }
@Override public String next() { Entry<Key,Value> entry = iter.next(); StringBuilder sb = new StringBuilder(); toHex(sb, entry.getKey().getRowData().toArray()); sb.append(" "); toHex(sb, entry.getKey().getColumnFamilyData().toArray()); sb.append(" "); toHex(sb, entry.getKey().getColumnQualifierData().toArray()); sb.append(" ["); sb.append(entry.getKey().getColumnVisibilityData()); sb.append("] "); if (config.willPrintTimestamps()) { sb.append(Long.toString(entry.getKey().getTimestamp())); sb.append(" "); } toHex(sb, entry.getValue().get()); return sb.toString(); }
private static Text removeTrailingZeroFromRow(Key k) { if (k != null) { Text t = new Text(); ByteSequence row = k.getRowData(); Preconditions.checkArgument(row.length() >= 1 && row.byteAt(row.length() - 1) == 0); t.set(row.getBackingArray(), row.offset(), row.length() - 1); return t; } else { return null; } }
public static final SortedMap<Key,Value> decodeRow(Key rowKey, Value rowValue) throws IOException { SortedMap<Key,Value> map = new TreeMap<>(); ByteArrayInputStream in = new ByteArrayInputStream(rowValue.get()); DataInputStream din = new DataInputStream(in); int numKeys = din.readInt(); for (int i = 0; i < numKeys; i++) { byte[] cf = readField(din); // read the col fam byte[] cq = readField(din); // read the col qual byte[] cv = readField(din); // read the col visibility long timestamp = din.readLong(); // read the timestamp byte[] valBytes = readField(din); // read the value map.put(new Key(rowKey.getRowData().toArray(), cf, cq, cv, timestamp, false, false), new Value(valBytes, false)); } return map; }
/** * Make a new key with a column qualifier, and column visibility. Copy the rest of the parts of * the key (including delete flag) from {@code originalKey}. */ protected Key replaceKeyParts(Key originalKey, Text newColQual, Text newColVis) { byte[] row = originalKey.getRowData().toArray(); byte[] cf = originalKey.getColumnFamilyData().toArray(); byte[] cq = newColQual.getBytes(); byte[] cv = newColVis.getBytes(); long timestamp = originalKey.getTimestamp(); Key newKey = new Key(row, 0, row.length, cf, 0, cf.length, cq, 0, newColQual.getLength(), cv, 0, newColVis.getLength(), timestamp); newKey.setDeleted(originalKey.isDeleted()); return newKey; }
private void consumeRow(ByteSequence row) throws IOException { // try reading a few and if still not to next row, then seek int count = 0; while (source.hasTop() && source.getTopKey().getRowData().equals(row)) { source.next(); count++; if (count >= 10) { Key nextRowStart = new Key(new Text(row.toArray())).followingKey(PartialKey.ROW); reseek(nextRowStart); count = 0; } } }
@VisibleForTesting public void put(Key key, Value value) { wlock.lock(); try { if (nmPointer == 0) { throw new IllegalStateException("Native Map Deleted"); } modCount++; singleUpdate(nmPointer, key.getRowData().toArray(), key.getColumnFamilyData().toArray(), key.getColumnQualifierData().toArray(), key.getColumnVisibilityData().toArray(), key.getTimestamp(), key.isDeleted(), value.get(), 0); } finally { wlock.unlock(); } }
/** * Make a new key with all parts (including delete flag) coming from {@code originalKey} but use * {@code newColFam} as the column family. */ protected Key replaceColumnFamily(Key originalKey, Text newColFam) { byte[] row = originalKey.getRowData().toArray(); byte[] cf = newColFam.getBytes(); byte[] cq = originalKey.getColumnQualifierData().toArray(); byte[] cv = originalKey.getColumnVisibilityData().toArray(); long timestamp = originalKey.getTimestamp(); Key newKey = new Key(row, 0, row.length, cf, 0, newColFam.getLength(), cq, 0, cq.length, cv, 0, cv.length, timestamp); newKey.setDeleted(originalKey.isDeleted()); return newKey; }
/** * Make a new key with all parts (including delete flag) coming from {@code originalKey} but use * {@code newColQual} as the column qualifier. */ protected Key replaceColumnQualifier(Key originalKey, Text newColQual) { byte[] row = originalKey.getRowData().toArray(); byte[] cf = originalKey.getColumnFamilyData().toArray(); byte[] cq = newColQual.getBytes(); byte[] cv = originalKey.getColumnVisibilityData().toArray(); long timestamp = originalKey.getTimestamp(); Key newKey = new Key(row, 0, row.length, cf, 0, cf.length, cq, 0, newColQual.getLength(), cv, 0, cv.length, timestamp); newKey.setDeleted(originalKey.isDeleted()); return newKey; }
/** * Make a new key with all parts (including delete flag) coming from {@code originalKey} but use * {@code newColVis} as the column visibility. */ protected Key replaceColumnVisibility(Key originalKey, Text newColVis) { byte[] row = originalKey.getRowData().toArray(); byte[] cf = originalKey.getColumnFamilyData().toArray(); byte[] cq = originalKey.getColumnQualifierData().toArray(); byte[] cv = newColVis.getBytes(); long timestamp = originalKey.getTimestamp(); Key newKey = new Key(row, 0, row.length, cf, 0, cf.length, cq, 0, cq.length, cv, 0, newColVis.getLength(), timestamp); newKey.setDeleted(originalKey.isDeleted()); return newKey; }
@Override public Key transform(org.apache.accumulo.core.data.Key acuKey) { byte keyData[]; ByteSequence row = acuKey.getRowData(); ByteSequence cf = acuKey.getColumnFamilyData(); keyData = new byte[row.length() + cf.length()]; System.arraycopy(row.getBackingArray(), row.offset(), keyData, 0, row.length()); System.arraycopy(cf.getBackingArray(), cf.offset(), keyData, row.length(), cf.length()); return new Key(keyData, 1.0); }
NMIterator(Key key) { if (nmPointer == 0) { throw new IllegalStateException(); } expectedModCount = modCount; nmiPointer = createNMI(nmPointer, key.getRowData().toArray(), key.getColumnFamilyData().toArray(), key.getColumnQualifierData().toArray(), key.getColumnVisibilityData().toArray(), key.getTimestamp(), key.isDeleted(), fieldsLens); hasNext = nmiPointer != 0; }
@Override public boolean accept(Key k, Value v) { return match(v.get()) || match(k.getRowData()) || match(k.getColumnFamilyData()) || match(k.getColumnQualifierData()); }
@Override public boolean accept(Key key, Value value) { if (orFields) return ((matches(rowMatcher, rowMatcher == null ? null : key.getRowData())) || (matches(colfMatcher, colfMatcher == null ? null : key.getColumnFamilyData())) || (matches(colqMatcher, colqMatcher == null ? null : key.getColumnQualifierData())) || (matches(valueMatcher, value.get(), 0, value.get().length))); return ((matches(rowMatcher, rowMatcher == null ? null : key.getRowData())) && (matches(colfMatcher, colfMatcher == null ? null : key.getColumnFamilyData())) && (matches(colqMatcher, colqMatcher == null ? null : key.getColumnQualifierData())) && (matches(valueMatcher, value.get(), 0, value.get().length))); }
@Override protected void hash(DataOutput hasher, Key k) throws IOException { if (row) { putByteSquence(k.getRowData(), hasher); } if (family) { putByteSquence(k.getColumnFamilyData(), hasher); } if (qualifier) { putByteSquence(k.getColumnQualifierData(), hasher); } if (visibility) { putByteSquence(k.getColumnVisibilityData(), hasher); } } }
@Override public org.apache.hadoop.util.bloom.Key transform(org.apache.accumulo.core.data.Key acuKey) { byte keyData[]; ByteSequence row = acuKey.getRowData(); ByteSequence cf = acuKey.getColumnFamilyData(); ByteSequence cq = acuKey.getColumnQualifierData(); keyData = new byte[row.length() + cf.length() + cq.length()]; System.arraycopy(row.getBackingArray(), row.offset(), keyData, 0, row.length()); System.arraycopy(cf.getBackingArray(), cf.offset(), keyData, row.length(), cf.length()); System.arraycopy(cq.getBackingArray(), cq.offset(), keyData, row.length() + cf.length(), cq.length()); return new org.apache.hadoop.util.bloom.Key(keyData, 1.0); }
@Override public void next() throws IOException { if (source.hasTop()) { ByteSequence currentRow = source.getTopKey().getRowData(); ByteSequence currentColf = source.getTopKey().getColumnFamilyData(); long ts = source.getTopKey().getTimestamp(); source.next(); int count = 1; while (source.hasTop() && source.getTopKey().getRowData().equals(currentRow) && source.getTopKey().getColumnFamilyData().equals(currentColf)) { count++; source.next(); } this.key = new Key(currentRow.toArray(), currentColf.toArray(), new byte[0], new byte[0], ts); this.value = new Value(Integer.toString(count).getBytes(UTF_8)); } else { this.key = null; this.value = null; } }
@Override public void accept(Key k, Value v) { keyStats.accept(k.getLength()); rowStats.accept(k.getRowData().length()); familyStats.accept(k.getColumnFamilyData().length()); qualifierStats.accept(k.getColumnQualifierData().length()); visibilityStats.accept(k.getColumnVisibilityData().length()); valueStats.accept(v.getSize()); total++; }