Search in sources :

Example 1 with DataTableRowKey

use of org.vertexium.accumulo.keys.DataTableRowKey in project vertexium by visallo.

the class DataInDataTableStreamingPropertyValueStorageStrategy method saveStreamingPropertyValue.

@Override
public StreamingPropertyValueRef saveStreamingPropertyValue(ElementMutationBuilder elementMutationBuilder, String rowKey, Property property, StreamingPropertyValue streamingPropertyValue) {
    try {
        String dataTableRowKey = new DataTableRowKey(rowKey, property).getRowKey();
        InputStream in = streamingPropertyValue.getInputStream();
        byte[] buffer = new byte[dataInDataTablePartSize];
        long offset = 0;
        while (true) {
            int read = in.read(buffer);
            if (read <= 0) {
                break;
            }
            Mutation dataMutation = new Mutation(dataTableRowKey);
            Text columnQualifier = new Text(String.format("%08x", offset));
            dataMutation.put(DATA_COLUMN_FAMILY, columnQualifier, property.getTimestamp(), new Value(buffer, 0, read));
            elementMutationBuilder.saveDataMutation(dataMutation);
            offset += read;
        }
        Mutation dataMutation = new Mutation(dataTableRowKey);
        dataMutation.put(METADATA_COLUMN_FAMILY, METADATA_LENGTH_COLUMN_QUALIFIER, property.getTimestamp(), new Value(Longs.toByteArray(offset)));
        elementMutationBuilder.saveDataMutation(dataMutation);
        return new StreamingPropertyValueTableDataRef(dataTableRowKey, streamingPropertyValue, offset);
    } catch (Exception ex) {
        throw new VertexiumException("Could not store streaming property value", ex);
    }
}
Also used : InputStream(java.io.InputStream) Value(org.apache.accumulo.core.data.Value) StreamingPropertyValue(org.vertexium.property.StreamingPropertyValue) Text(org.apache.hadoop.io.Text) Mutation(org.apache.accumulo.core.data.Mutation) StreamingPropertyValueTableDataRef(org.vertexium.accumulo.StreamingPropertyValueTableDataRef) VertexiumException(org.vertexium.VertexiumException) VertexiumException(org.vertexium.VertexiumException) DataTableRowKey(org.vertexium.accumulo.keys.DataTableRowKey)

Example 2 with DataTableRowKey

use of org.vertexium.accumulo.keys.DataTableRowKey in project vertexium by visallo.

the class OverflowIntoHdfsStreamingPropertyValueStorageStrategy method saveStreamingPropertyValueSmall.

private StreamingPropertyValueRef saveStreamingPropertyValueSmall(ElementMutationBuilder elementMutationBuilder, String rowKey, Property property, byte[] data, StreamingPropertyValue propertyValue) {
    String dataTableRowKey = new DataTableRowKey(rowKey, property).getRowKey();
    Mutation dataMutation = new Mutation(dataTableRowKey);
    dataMutation.put(EMPTY_TEXT, EMPTY_TEXT, property.getTimestamp(), new Value(data));
    elementMutationBuilder.saveDataMutation(dataMutation);
    return new StreamingPropertyValueTableRef(dataTableRowKey, propertyValue, data);
}
Also used : Value(org.apache.accumulo.core.data.Value) StreamingPropertyValue(org.vertexium.property.StreamingPropertyValue) Mutation(org.apache.accumulo.core.data.Mutation) DataTableRowKey(org.vertexium.accumulo.keys.DataTableRowKey)

Example 3 with DataTableRowKey

use of org.vertexium.accumulo.keys.DataTableRowKey in project vertexium by visallo.

the class AccumuloGraphTestBase method addLegacySPVData.

// need to add it manually because the key format changed
private void addLegacySPVData(String vertexId, long timestamp, String propertyKey, String propertyName, String propertyValue) throws MutationsRejectedException {
    String dataRowKey = new DataTableRowKey(vertexId, propertyKey, propertyName).getRowKey() + VALUE_SEPARATOR + timestamp;
    Mutation addPropertyMutation = new Mutation(vertexId);
    byte[] data = propertyValue.getBytes();
    StreamingPropertyValue spv = StreamingPropertyValue.create(propertyValue);
    StreamingPropertyValueTableRef spvValue = new StreamingPropertyValueTableRef(dataRowKey, spv, data);
    Metadata metadata = new Metadata();
    Property property = new MutablePropertyImpl(propertyKey, propertyName, spvValue, metadata, timestamp, new HashSet<>(), new Visibility(""), FetchHints.ALL);
    Text columnQualifier = KeyHelper.getColumnQualifierFromPropertyColumnQualifier(property, getGraph().getNameSubstitutionStrategy());
    addPropertyMutation.put(AccumuloElement.CF_PROPERTY, columnQualifier, new Value(getGraph().getVertexiumSerializer().objectToBytes(spvValue)));
    getGraph().getVerticesWriter().addMutation(addPropertyMutation);
    Mutation addDataMutation = new Mutation(dataRowKey);
    addDataMutation.put(EMPTY_TEXT, EMPTY_TEXT, timestamp - 1000, new Value(data));
    getGraph().getDataWriter().addMutation(addDataMutation);
    getGraph().flush();
}
Also used : StreamingPropertyValue(org.vertexium.property.StreamingPropertyValue) Text(org.apache.hadoop.io.Text) DataTableRowKey(org.vertexium.accumulo.keys.DataTableRowKey) MutablePropertyImpl(org.vertexium.property.MutablePropertyImpl) Value(org.apache.accumulo.core.data.Value) StreamingPropertyValue(org.vertexium.property.StreamingPropertyValue) Mutation(org.apache.accumulo.core.data.Mutation)

Aggregations

Mutation (org.apache.accumulo.core.data.Mutation)3 Value (org.apache.accumulo.core.data.Value)3 DataTableRowKey (org.vertexium.accumulo.keys.DataTableRowKey)3 StreamingPropertyValue (org.vertexium.property.StreamingPropertyValue)3 Text (org.apache.hadoop.io.Text)2 InputStream (java.io.InputStream)1 VertexiumException (org.vertexium.VertexiumException)1 StreamingPropertyValueTableDataRef (org.vertexium.accumulo.StreamingPropertyValueTableDataRef)1 MutablePropertyImpl (org.vertexium.property.MutablePropertyImpl)1