Java Code Examples for org.apache.accumulo.core.data.Key#getColumnQualifierData()
The following examples show how to use
org.apache.accumulo.core.data.Key#getColumnQualifierData() .
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: ValueToAttribute.java From datawave with Apache License 2.0 | 5 votes |
public Attribute<?> getFieldValue(String fieldName, Key k) { ByteSequence sequence = k.getColumnQualifierData(); int index = -1; for (int i = 0; i < sequence.length(); i++) { if (sequence.byteAt(i) == 0x00) { index = i; break; } } if (0 > index) { throw new IllegalArgumentException("Could not find null-byte contained in columnqualifier for key: " + k); } try { String data = Text.decode(sequence.getBackingArray(), index + 1, (sequence.length() - (index + 1))).intern(); Attribute<?> attr = this.attrFactory.create(fieldName, data, k, attrFilter == null || attrFilter.keep(k)); if (attrFilter != null) { attr.setToKeep(attrFilter.keep(k)); } return attr; } catch (CharacterCodingException e) { throw new IllegalArgumentException(e); } }
Example 2
Source File: DiscoveryIterator.java From datawave with Apache License 2.0 | 5 votes |
private static boolean datesMatch(Key reference, Key test) { ByteSequence a = reference.getColumnQualifierData(), b = test.getColumnQualifierData(); for (int i = 0; i < 8; i++) { if (a.byteAt(i) != b.byteAt(i)) { return false; } } return true; }
Example 3
Source File: KeyToFieldName.java From datawave with Apache License 2.0 | 5 votes |
public String getFieldName(Key k) { int index = -1; ByteSequence sequence = k.getColumnQualifierData(); byte[] arrayReference = sequence.getBackingArray(); for (int i = 0; i < sequence.length(); i++) { if (!includeGroupingContext && arrayReference[i] == '.') { index = i; break; } if (arrayReference[i] == 0x00) { index = i; break; } } if (0 > index) { throw new IllegalArgumentException("Could not find null-byte contained in columnqualifier for key: " + k); } try { return Text.decode(arrayReference, 0, index); } catch (CharacterCodingException e) { throw new IllegalArgumentException(e); } }
Example 4
Source File: CreateUidsIterator.java From datawave with Apache License 2.0 | 5 votes |
public static boolean sameShard(Key ref, Key test) { ByteSequence refCq = ref.getColumnQualifierData(); ByteSequence testCq = test.getColumnQualifierData(); if (testCq.length() < refCq.length()) { return false; } for (int i = 0; i < refCq.length(); ++i) { if (refCq.byteAt(i) != testCq.byteAt(i)) { return false; } } return testCq.byteAt(refCq.length()) == 0x00; }
Example 5
Source File: DataTypeFilter.java From datawave with Apache License 2.0 | 5 votes |
public static ByteSequence parseDataType(Key k) { ByteSequence cq = k.getColumnQualifierData(); int i = cq.length(); while (cq.byteAt(--i) != 0x00) ; return cq.subSequence(++i, cq.length()); }
Example 6
Source File: FinalDocumentTrackingIterator.java From datawave with Apache License 2.0 | 5 votes |
public static boolean isFinalDocumentKey(Key k) { if (k != null && k.getColumnQualifierData() != null) { ByteSequence bytes = k.getColumnQualifierData(); if (bytes.length() >= MARKER_TEXT.getLength()) { return (bytes.subSequence(bytes.length() - MARKER_TEXT.getLength(), bytes.length()).compareTo(MARKER_SEQUENCE) == 0); } } return false; }
Example 7
Source File: FieldIndexDocumentFilter.java From datawave with Apache License 2.0 | 5 votes |
@Override public boolean accept(Key key, Value value) { ByteSequence cq = key.getColumnQualifierData(); if (cq.length() < cqSuffix.length) { return false; } int pos = cq.length() - 1; for (int i = cqSuffix.length - 1; i >= 0; i--) { if (cq.byteAt(pos--) != cqSuffix[i]) { return false; } } return true; }
Example 8
Source File: UniqueColumns.java From accumulo-examples with Apache License 2.0 | 5 votes |
@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 9
Source File: MergeToolMapper.java From rya with Apache License 2.0 | 5 votes |
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 10
Source File: AccumuloRyaUtils.java From rya with Apache License 2.0 | 5 votes |
/** * 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 11
Source File: CreateUidsIterator.java From datawave with Apache License 2.0 | 4 votes |
public static String parseDataType(Key k) { ByteSequence colq = k.getColumnQualifierData(); return new String(colq.subSequence(lastNull(colq) + 1, colq.length()).toArray()); }
Example 12
Source File: KeyValue.java From vertexium with Apache License 2.0 | 4 votes |
public void set(Key key, Value value) { this.key = key; this.value = value; this.columnFamilyData = key.getColumnFamilyData(); this.columnQualifierData = key.getColumnQualifierData(); }
Example 13
Source File: CreateUidsIterator.java From datawave with Apache License 2.0 | 3 votes |
/** * 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()); }