Java Code Examples for org.apache.accumulo.core.data.KeyValue#getKey()

The following examples show how to use org.apache.accumulo.core.data.KeyValue#getKey() . 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: ShardUidMappingIterator.java    From datawave with Apache License 2.0 6 votes vote down vote up
/**
 * Map the uid in the supplied key and value. The formats expected are for the shard table only.
 * 
 * @param keyValue
 * @return the key with the uid mapped appropriately. The original UID if any is placed in the value.
 */
@Override
protected KeyValue mapUid(KeyValue keyValue, boolean startKey, boolean startKeyInclusive, boolean endKey, boolean endKeyInclusive) {
    if (keyValue == null || keyValue.getKey() == null) {
        return keyValue;
    }
    // pull the column family
    String cf = keyValue.getKey().getColumnFamily().toString();
    int index = cf.indexOf('\0');
    if (index > 0) {
        if (cf.startsWith("fi\0")) {
            keyValue = replaceEventUidInCQ(keyValue, 2, startKey, startKeyInclusive, endKey, endKeyInclusive);
        } else { // assume DataType\0UID column family
            keyValue = replaceEventUidInCF(keyValue, 1, startKey, startKeyInclusive, endKey, endKeyInclusive);
        }
    } else if (cf.equals("d")) {
        keyValue = replaceEventUidInCQ(keyValue, 1, startKey, startKeyInclusive, endKey, endKeyInclusive);
    } else if (cf.equals("tf")) {
        keyValue = replaceEventUidInCQ(keyValue, 1, startKey, startKeyInclusive, endKey, endKeyInclusive);
    }
    return keyValue;
}
 
Example 2
Source File: DateIndexDataTypeHandler.java    From datawave with Apache License 2.0 5 votes vote down vote up
/**
 * Get the date index ingest keys and merge them into the provided key multimap
 * 
 * @param event
 * @param eventFields
 * @param index
 */
private void getBulkIngestKeys(RawRecordContainer event, Multimap<String,NormalizedContentInterface> eventFields, Multimap<BulkIngestKey,Value> index) {
    if (dataTypeToTypeToFields.containsKey(event.getDataType().typeName()) && null != eventFields && !eventFields.isEmpty()) {
        // date index Table Structure
        // Row: date
        // Colf: type
        // Colq: date\0datatype\0field
        // Value: shard bit set
        
        for (Map.Entry<String,String> entry : dataTypeToTypeToFields.get(event.getDataType().typeName()).entries()) {
            String type = entry.getKey();
            String field = entry.getValue();
            for (NormalizedContentInterface nci : eventFields.get(field)) {
                KeyValue keyValue = getDateIndexEntry(getShardId(event), event.getDataType().outputName(), type, field, nci.getIndexedFieldValue(),
                                event.getVisibility());
                
                if (keyValue != null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Outputting " + keyValue + " to " + getDateIndexTableName());
                    }
                    
                    BulkIngestKey bulkIngestKey = new BulkIngestKey(getDateIndexTableName(), keyValue.getKey());
                    if (index.containsKey(bulkIngestKey)) {
                        index.put(bulkIngestKey, keyValue.getValue());
                        DateIndexDateAggregator aggregator = new DateIndexDateAggregator();
                        Value value = aggregator.reduce(bulkIngestKey.getKey(), index.get(bulkIngestKey).iterator());
                        index.removeAll(bulkIngestKey);
                        index.put(bulkIngestKey, value);
                    } else {
                        index.put(bulkIngestKey, keyValue.getValue());
                    }
                }
            }
        }
    }
}
 
Example 3
Source File: EventErrorSummary.java    From datawave with Apache License 2.0 5 votes vote down vote up
/**
 * A method used to purge this error summary from the error processing table
 * 
 * @throws InterruptedException
 * @throws IOException
 */
@SuppressWarnings({"rawtypes", "unchecked"})
public void purge(ContextWriter writer, TaskInputOutputContext context, RawRecordContainer event, Map typeMap) throws IOException, InterruptedException {
    for (KeyValue keyValue : this.keyValues.values()) {
        keyValue.getKey().setDeleted(true);
        BulkIngestKey key = new BulkIngestKey(tableName, keyValue.getKey());
        writer.write(key, keyValue.getValue(), context);
    }
}
 
Example 4
Source File: UidMappingIterator.java    From datawave with Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
protected void findTop() throws IOException {
    if (this.source.hasTop()) {
        KeyValue keyValue = mapUid(new KeyValue(this.source.getTopKey(), this.source.getTopValue().get()), false, false, false, false);
        this.topKey = keyValue.getKey();
        this.topValue = keyValue.getValue();
    } else {
        this.topKey = null;
        this.topValue = null;
    }
}
 
Example 5
Source File: ShardUidMappingIterator.java    From datawave with Apache License 2.0 5 votes vote down vote up
/********************** Helper methods ***********************/
private KeyValue replaceEventUidInCQ(KeyValue keyValue, int partIndex, boolean startKey, boolean startKeyInclusive, boolean endKey, boolean endKeyInclusive) {
    Key key = keyValue.getKey();
    String[] replacement = replaceUid(key.getColumnQualifier().toString(), partIndex, startKey, startKeyInclusive, endKey, endKeyInclusive);
    // if no change in the uid, then return the original key
    if (replacement == null) {
        return keyValue;
    }
    
    Key newKey = new Key(key.getRow(), key.getColumnFamily(), new Text(replacement[CQ_INDEX]), key.getColumnVisibility(), key.getTimestamp());
    return new KeyValue(newKey, replacement[ORG_UID_INDEX].getBytes());
}
 
Example 6
Source File: ShardUidMappingIterator.java    From datawave with Apache License 2.0 5 votes vote down vote up
private KeyValue replaceEventUidInCF(KeyValue keyValue, int partIndex, boolean startKey, boolean startKeyInclusive, boolean endKey, boolean endKeyInclusive) {
    Key key = keyValue.getKey();
    String[] replacement = replaceUid(key.getColumnFamily().toString(), partIndex, startKey, startKeyInclusive, endKey, endKeyInclusive);
    // if no change in the uid, then return the original key
    if (replacement == null) {
        return keyValue;
    }
    
    Key newKey = new Key(key.getRow(), new Text(replacement[CQ_INDEX]), key.getColumnQualifier(), key.getColumnVisibility(), key.getTimestamp());
    return new KeyValue(newKey, replacement[ORG_UID_INDEX].getBytes());
}