Java Code Examples for org.apache.accumulo.core.data.Key#getColumnFamilyData()

The following examples show how to use org.apache.accumulo.core.data.Key#getColumnFamilyData() . 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: UniqueColumns.java    From accumulo-examples with Apache License 2.0 5 votes vote down vote up
@Override
public void map(Key key, Value value, Context context)
    throws IOException, InterruptedException {
  temp.set(CF);
  ByteSequence cf = key.getColumnFamilyData();
  temp.append(cf.getBackingArray(), cf.offset(), cf.length());
  context.write(temp, EMPTY);

  temp.set(CQ);
  ByteSequence cq = key.getColumnQualifierData();
  temp.append(cq.getBackingArray(), cq.offset(), cq.length());
  context.write(temp, EMPTY);
}
 
Example 2
Source File: MergeToolMapper.java    From rya with Apache License 2.0 5 votes vote down vote up
private static RyaStatement createRyaStatement(final Key key, final Value value, final RyaTripleContext ryaTripleContext) throws TripleRowResolverException {
    final byte[] row = key.getRowData() != null  && key.getRowData().toArray().length > 0 ? key.getRowData().toArray() : null;
    final byte[] columnFamily = key.getColumnFamilyData() != null  && key.getColumnFamilyData().toArray().length > 0 ? key.getColumnFamilyData().toArray() : null;
    final byte[] columnQualifier = key.getColumnQualifierData() != null  && key.getColumnQualifierData().toArray().length > 0 ? key.getColumnQualifierData().toArray() : null;
    final Long timestamp = key.getTimestamp();
    final byte[] columnVisibility = key.getColumnVisibilityData() != null && key.getColumnVisibilityData().toArray().length > 0 ? key.getColumnVisibilityData().toArray() : null;
    final byte[] valueBytes = value != null && value.get().length > 0 ? value.get() : null;
    final TripleRow tripleRow = new TripleRow(row, columnFamily, columnQualifier, timestamp, columnVisibility, valueBytes);
    final RyaStatement ryaStatement = ryaTripleContext.deserializeTriple(TABLE_LAYOUT.SPO, tripleRow);

    return ryaStatement;
}
 
Example 3
Source File: AccumuloRyaUtils.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link RyaStatement} from a {@link Key}/{@link Value} pair.
 * @param key the {@link Key}.
 * @param value the {@link Value}.
 * @param ryaTripleContext the {@link RyaTripleContext}.
 * @return the converted {@link RyaStatement}.
 * @throws TripleRowResolverException
 */
public static RyaStatement createRyaStatement(final Key key, final Value value, final RyaTripleContext ryaTripleContext) throws TripleRowResolverException {
    final byte[] row = key.getRowData() != null  && key.getRowData().toArray().length > 0 ? key.getRowData().toArray() : null;
    final byte[] columnFamily = key.getColumnFamilyData() != null  && key.getColumnFamilyData().toArray().length > 0 ? key.getColumnFamilyData().toArray() : null;
    final byte[] columnQualifier = key.getColumnQualifierData() != null  && key.getColumnQualifierData().toArray().length > 0 ? key.getColumnQualifierData().toArray() : null;
    final Long timestamp = key.getTimestamp();
    final byte[] columnVisibility = key.getColumnVisibilityData() != null && key.getColumnVisibilityData().toArray().length > 0 ? key.getColumnVisibilityData().toArray() : null;
    final byte[] valueBytes = value != null && value.get().length > 0 ? value.get() : null;
    final TripleRow tripleRow = new TripleRow(row, columnFamily, columnQualifier, timestamp, columnVisibility, valueBytes);
    final RyaStatement ryaStatement = ryaTripleContext.deserializeTriple(TABLE_LAYOUT.SPO, tripleRow);

    return ryaStatement;
}
 
Example 4
Source File: TLDEventDataFilter.java    From datawave with Apache License 2.0 4 votes vote down vote up
private boolean isEventKey(Key k) {
    ByteSequence cf = k.getColumnFamilyData();
    return !(WritableComparator.compareBytes(cf.getBackingArray(), 0, 2, FI_CF, 0, 2) == 0)
                    && !(WritableComparator.compareBytes(cf.getBackingArray(), 0, 2, TF_CF, 0, 2) == 00);
}
 
Example 5
Source File: KeyToDocumentData.java    From datawave with Apache License 2.0 4 votes vote down vote up
public static Key getDocKey(Key key) {
    final ByteSequence row = key.getRowData(), cf = key.getColumnFamilyData(), cv = key.getColumnVisibilityData();
    return new Key(row.getBackingArray(), row.offset(), row.length(), cf.getBackingArray(), cf.offset(), cf.length(),
                    EMPTY_BYTE_SEQUENCE.getBackingArray(), EMPTY_BYTE_SEQUENCE.offset(), EMPTY_BYTE_SEQUENCE.length(), cv.getBackingArray(), cv.offset(),
                    cv.length(), key.getTimestamp());
}
 
Example 6
Source File: KeyValue.java    From vertexium with Apache License 2.0 4 votes vote down vote up
public void set(Key key, Value value) {
    this.key = key;
    this.value = value;
    this.columnFamilyData = key.getColumnFamilyData();
    this.columnQualifierData = key.getColumnQualifierData();
}
 
Example 7
Source File: CreateUidsIterator.java    From datawave with Apache License 2.0 3 votes vote down vote up
/**
 * When skipKey is false, we produce the key based upon k, removing any data type
 * 
 * When skipKey is true, we will produce a key producing a skipkey from the root key. This will be helpful when we are being torn down.
 * 
 * @param k
 * @return
 */
public static Key makeRootKey(Key k) {
    ByteSequence cq = k.getColumnQualifierData();
    ByteSequence strippedCq = cq.subSequence(0, lastNull(cq));
    final ByteSequence row = k.getRowData(), cf = k.getColumnFamilyData(), cv = k.getColumnVisibilityData();
    return new Key(row.getBackingArray(), row.offset(), row.length(), cf.getBackingArray(), cf.offset(), cf.length(), strippedCq.getBackingArray(),
                    strippedCq.offset(), strippedCq.length(), cv.getBackingArray(), cv.offset(), cv.length(), k.getTimestamp());
}