use of org.vertexium.property.StreamingPropertyValue in project vertexium by visallo.
the class AccumuloGraphTestBase method testLegacyStreamingPropertyValuesWithTimestampInRowKey.
@Test
public void testLegacyStreamingPropertyValuesWithTimestampInRowKey() throws Exception {
String vertexId = "v1";
graph.prepareVertex(vertexId, VISIBILITY_EMPTY).save(AUTHORIZATIONS_EMPTY);
graph.flush();
long timestamp = new Date().getTime();
String propertyKey = "k1";
String propertyName = "prop1";
String propertyValue = "Hello";
addLegacySPVData(vertexId, timestamp, propertyKey, propertyName, propertyValue);
getGraph().flush();
// verify we can still retrieve it
Vertex v1 = graph.getVertex(vertexId, AUTHORIZATIONS_EMPTY);
StreamingPropertyValue spv = (StreamingPropertyValue) v1.getPropertyValue(propertyKey, propertyName);
assertNotNull("spv should not be null", spv);
assertEquals(propertyValue, IOUtils.toString(spv.getInputStream()));
}
use of org.vertexium.property.StreamingPropertyValue in project vertexium by visallo.
the class AccumuloGraphTestBase method testDeleteHistoricalLegacyStreamingPropertyValueData_mixOfOldAndNew.
@Test
public void testDeleteHistoricalLegacyStreamingPropertyValueData_mixOfOldAndNew() throws Exception {
String vertexId = "v1";
graph.prepareVertex(vertexId, VISIBILITY_EMPTY).save(AUTHORIZATIONS_EMPTY);
graph.flush();
long timestamp = new Date().getTime();
String propertyKey = "prefix";
String propertyName = "prop1";
String propertyValue1 = "Hello1";
String propertyValue2 = "Hello2";
addLegacySPVData(vertexId, timestamp - 100, propertyKey, propertyName, propertyValue1);
StreamingPropertyValue newSpv = StreamingPropertyValue.create(propertyValue2);
getGraph().getVertex("v1", AUTHORIZATIONS_EMPTY).addPropertyValue(propertyKey, propertyName, newSpv, VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
getGraph().flush();
new DeleteHistoricalLegacyStreamingPropertyValueData(getGraph()).execute(new DeleteHistoricalLegacyStreamingPropertyValueData.Options().setDryRun(false).setVersionsToKeep(1), AUTHORIZATIONS_EMPTY);
// verify we can still retrieve it
Vertex v1 = graph.getVertex(vertexId, AUTHORIZATIONS_EMPTY);
StreamingPropertyValue spv = (StreamingPropertyValue) v1.getPropertyValue(propertyKey, propertyName);
assertNotNull("spv should not be null", spv);
assertEquals(propertyValue2, IOUtils.toString(spv.getInputStream()));
}
use of org.vertexium.property.StreamingPropertyValue 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);
}
}
use of org.vertexium.property.StreamingPropertyValue in project vertexium by visallo.
the class Elasticsearch5SearchIndex method getExtendedDataColumnsAsFields.
private Map<String, Object> getExtendedDataColumnsAsFields(Graph graph, List<ExtendedDataMutation> columns) {
Map<String, Object> fieldsMap = new HashMap<>();
List<ExtendedDataMutation> streamingColumns = new ArrayList<>();
for (ExtendedDataMutation column : columns) {
if (column.getValue() != null && shouldIgnoreType(column.getValue().getClass())) {
continue;
}
if (column.getValue() instanceof StreamingPropertyValue) {
StreamingPropertyValue spv = (StreamingPropertyValue) column.getValue();
if (isStreamingPropertyValueIndexable(graph, column.getColumnName(), spv)) {
streamingColumns.add(column);
}
} else {
addExtendedDataColumnToFieldMap(graph, column, column.getValue(), fieldsMap);
}
}
addStreamingExtendedDataColumnsValuesToMap(graph, streamingColumns, fieldsMap);
return fieldsMap;
}
use of org.vertexium.property.StreamingPropertyValue in project vertexium by visallo.
the class Elasticsearch5SearchIndex method getPropertiesAsFields.
private Map<String, Object> getPropertiesAsFields(Graph graph, Iterable<Property> properties) {
Map<String, Object> fieldsMap = new HashMap<>();
List<Property> streamingProperties = new ArrayList<>();
for (Property property : properties) {
if (property.getValue() != null && shouldIgnoreType(property.getValue().getClass())) {
continue;
}
if (property.getValue() instanceof StreamingPropertyValue) {
StreamingPropertyValue spv = (StreamingPropertyValue) property.getValue();
if (isStreamingPropertyValueIndexable(graph, property.getName(), spv)) {
streamingProperties.add(property);
}
} else {
addPropertyToFieldMap(graph, property, property.getValue(), fieldsMap);
}
}
addStreamingPropertyValuesToFieldMap(graph, streamingProperties, fieldsMap);
return fieldsMap;
}
Aggregations