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; }
private Map<String, Map<String, List<ExtendedDataMutation>>> mapExtendedDatasByTableByRow(Iterable<ExtendedDataMutation> extendedData) { Map<String, Map<String, List<ExtendedDataMutation>>> results = new HashMap<>(); for (ExtendedDataMutation ed : extendedData) { Map<String, List<ExtendedDataMutation>> byRow = results.computeIfAbsent(ed.getTableName(), k -> new HashMap<>()); List<ExtendedDataMutation> items = byRow.computeIfAbsent(ed.getRow(), k -> new ArrayList<>()); items.add(ed); } return results; }
protected String addVisibilityToExtendedDataColumnName(Graph graph, ExtendedDataMutation extendedDataMutation) { String columnName = extendedDataMutation.getColumnName(); Visibility propertyVisibility = extendedDataMutation.getVisibility(); return addVisibilityToPropertyName(graph, columnName, propertyVisibility); }
public static Set<TableNameVisibilityPair> getUniquePairs(Iterable<ExtendedDataMutation> extendedDatas) { Set<TableNameVisibilityPair> results = new HashSet<>(); for (ExtendedDataMutation extendedData : extendedDatas) { results.add(new TableNameVisibilityPair(extendedData.getVisibility(), extendedData.getTableName())); } return results; }
void saveExtendedData(AccumuloGraph graph, String elementId, ElementType elementType, Iterable<ExtendedDataMutation> extendedData) { Map<String, List<ExtendedDataMutation>> extendedDatasByTableName = stream(extendedData) .collect(Collectors.groupingBy(edm -> edm.getTableName() + edm.getRow())); for (Map.Entry<String, List<ExtendedDataMutation>> entry : extendedDatasByTableName.entrySet()) { List<ExtendedDataMutation> mutationsForTableAndRow = entry.getValue(); String tableName = mutationsForTableAndRow.get(0).getTableName(); String row = mutationsForTableAndRow.get(0).getRow(); Mutation m = new Mutation(KeyHelper.createExtendedDataRowKey(elementType, elementId, tableName, row)); for (ExtendedDataMutation edm : mutationsForTableAndRow) { Object value = transformValue(edm.getValue(), null, null); // graph can be null if this is running in Map Reduce. We can just assume the property is already defined. if (graph != null) { graph.ensurePropertyDefined(edm.getColumnName(), value); } m.put( AccumuloElement.CF_EXTENDED_DATA, KeyHelper.createExtendedDataColumnQualifier(edm), visibilityToAccumuloVisibility(edm.getVisibility()), new Value(vertexiumSerializer.objectToBytes(value)) ); } saveExtendedDataMutation(elementType, m); } }
private IndexInfo addExtendedDataColumnsToIndex(Graph graph, Element element, String tableName, String rowId, List<ExtendedDataMutation> columns) { try { String indexName = getExtendedDataIndexName(element, tableName, rowId); IndexInfo indexInfo = ensureIndexCreatedAndInitialized(indexName); for (ExtendedDataMutation column : columns) { addPropertyToIndex(graph, indexInfo, column.getColumnName(), column.getValue(), column.getVisibility()); } return indexInfo; } catch (IOException e) { throw new VertexiumException("Could not add properties to index", e); } }
public void extendedData( Element element, ExtendedDataRowId rowId, ExtendedDataMutation extendedData, Authorizations authorizations ) { extendedDataTable.addData(rowId, extendedData.getColumnName(), extendedData.getKey(), extendedData.getValue(), extendedData.getTimestamp(), extendedData.getVisibility()); getSearchIndex().addElementExtendedData(this, element, Collections.singleton(extendedData), authorizations); if (hasEventListeners()) { fireGraphEvent(new AddExtendedDataEvent( this, element, rowId.getTableName(), rowId.getRowId(), extendedData.getColumnName(), extendedData.getKey(), extendedData.getValue(), extendedData.getVisibility() )); } }
public void addPropertyToIndexInner(Graph graph, IndexInfo indexInfo, ExtendedDataMutation extendedDataMutation) throws IOException { String deflatedPropertyName = addVisibilityToExtendedDataColumnName(graph, extendedDataMutation); Object propertyValue = extendedDataMutation.getValue(); Visibility propertyVisibility = extendedDataMutation.getVisibility(); addPropertyToIndexInner(graph, indexInfo, deflatedPropertyName, propertyValue, propertyVisibility); }
private void addStreamingExtendedDataColumnsValuesToMap(Graph graph, List<ExtendedDataMutation> columns, Map<String, Object> fieldsMap) { List<StreamingPropertyValue> streamingPropertyValues = columns.stream() .map((column) -> { if (!(column.getValue() instanceof StreamingPropertyValue)) { throw new VertexiumException("column with a value that is not a StreamingPropertyValue passed to addStreamingPropertyValuesToFieldMap"); } return (StreamingPropertyValue) column.getValue(); }) .collect(Collectors.toList()); List<InputStream> inputStreams = graph.getStreamingPropertyValueInputStreams(streamingPropertyValues); for (int i = 0; i < columns.size(); i++) { try { String propertyValue = IOUtils.toString(inputStreams.get(i)); addExtendedDataColumnToFieldMap(graph, columns.get(i), new StreamingPropertyString(propertyValue), fieldsMap); } catch (IOException ex) { throw new VertexiumException("could not convert streaming property to string", ex); } } }
@Override public ExistingElementMutation<T> addExtendedData(String tableName, String row, String column, String key, Object value, Long timestamp, Visibility visibility) { this.extendedDatas.add(new ExtendedDataMutation(tableName, row, column, key, value, timestamp, visibility)); return this; }
void saveExtendedData(AccumuloGraph graph, String elementId, ElementType elementType, Iterable<ExtendedDataMutation> extendedData) { Map<String, List<ExtendedDataMutation>> extendedDatasByTableName = stream(extendedData) .collect(Collectors.groupingBy(edm -> edm.getTableName() + edm.getRow())); for (Map.Entry<String, List<ExtendedDataMutation>> entry : extendedDatasByTableName.entrySet()) { List<ExtendedDataMutation> mutationsForTableAndRow = entry.getValue(); String tableName = mutationsForTableAndRow.get(0).getTableName(); String row = mutationsForTableAndRow.get(0).getRow(); Mutation m = new Mutation(KeyHelper.createExtendedDataRowKey(elementType, elementId, tableName, row)); for (ExtendedDataMutation edm : mutationsForTableAndRow) { Object value = transformValue(edm.getValue(), null, null); // graph can be null if this is running in Map Reduce. We can just assume the property is already defined. if (graph != null) { graph.ensurePropertyDefined(edm.getColumnName(), value); } m.put( AccumuloElement.CF_EXTENDED_DATA, KeyHelper.createExtendedDataColumnQualifier(edm), visibilityToAccumuloVisibility(edm.getVisibility()), new Value(vertexiumSerializer.objectToBytes(value)) ); } saveExtendedDataMutation(elementType, m); } }
private IndexInfo addExtendedDataColumnsToIndex(Graph graph, Element element, String tableName, String rowId, List<ExtendedDataMutation> columns) { try { String indexName = getExtendedDataIndexName(element, tableName, rowId); IndexInfo indexInfo = ensureIndexCreatedAndInitialized(indexName); for (ExtendedDataMutation column : columns) { addPropertyToIndex(graph, indexInfo, column.getColumnName(), column.getValue(), column.getVisibility()); } return indexInfo; } catch (IOException e) { throw new VertexiumException("Could not add properties to index", e); } }
public static Set<TableNameVisibilityPair> getUniquePairs(Iterable<ExtendedDataMutation> extendedDatas) { Set<TableNameVisibilityPair> results = new HashSet<>(); for (ExtendedDataMutation extendedData : extendedDatas) { results.add(new TableNameVisibilityPair(extendedData.getVisibility(), extendedData.getTableName())); } return results; }
public void addPropertyToIndexInner(Graph graph, IndexInfo indexInfo, ExtendedDataMutation extendedDataMutation) throws IOException { String deflatedPropertyName = deflateExtendedDataColumnName(graph, extendedDataMutation); Object propertyValue = extendedDataMutation.getValue(); Visibility propertyVisibility = extendedDataMutation.getVisibility(); addPropertyToIndexInner(graph, indexInfo, deflatedPropertyName, propertyValue, propertyVisibility); }
private void addStreamingExtendedDataColumnsValuesToMap(Graph graph, List<ExtendedDataMutation> columns, Map<String, Object> fieldsMap) { List<StreamingPropertyValue> streamingPropertyValues = columns.stream() .map((column) -> { if (!(column.getValue() instanceof StreamingPropertyValue)) { throw new VertexiumException("column with a value that is not a StreamingPropertyValue passed to addStreamingPropertyValuesToFieldMap"); } return (StreamingPropertyValue) column.getValue(); }) .collect(Collectors.toList()); List<InputStream> inputStreams = graph.getStreamingPropertyValueInputStreams(streamingPropertyValues); for (int i = 0; i < columns.size(); i++) { try { String propertyValue = IOUtils.toString(inputStreams.get(i)); addExtendedDataColumnToFieldMap(graph, columns.get(i), new StreamingPropertyString(propertyValue), fieldsMap); } catch (IOException ex) { throw new VertexiumException("could not convert streaming property to string", ex); } } }
@Override public ElementBuilder<T> addExtendedData(String tableName, String row, String column, String key, Object value, Long timestamp, Visibility visibility) { this.extendedDatas.add(new ExtendedDataMutation(tableName, row, column, key, value, timestamp, visibility)); return this; }
this, element, extendedDataMutation.getTableName(), extendedDataMutation.getRow(), extendedDataMutation.getColumnName(), extendedDataMutation.getKey(), extendedDataMutation.getValue(), extendedDataMutation.getVisibility() ));
private void addExtendedDataToIndex(Graph graph, IndexInfo indexInfo, ExtendedDataMutation column) throws IOException { // unlike the super class we need to lookup column definitions based on the column name without // the hash and define the column that way. Object columnValue = column.getValue(); PropertyDefinition propertyDefinition = getPropertyDefinition(graph, column.getColumnName()); if (propertyDefinition != null) { String deflatedColumnName = addVisibilityToExtendedDataColumnName(graph, column); addPropertyDefinitionToIndex(graph, indexInfo, deflatedColumnName, column.getVisibility(), propertyDefinition); } else { addPropertyToIndexInner(graph, indexInfo, column); } propertyDefinition = getPropertyDefinition(graph, column.getColumnName() + EXACT_MATCH_PROPERTY_NAME_SUFFIX); if (propertyDefinition != null) { String deflatedColumnName = addVisibilityToExtendedDataColumnName(graph, column); addPropertyDefinitionToIndex(graph, indexInfo, deflatedColumnName, column.getVisibility(), propertyDefinition); } if (columnValue instanceof GeoShape) { propertyDefinition = getPropertyDefinition(graph, column.getColumnName() + GEO_PROPERTY_NAME_SUFFIX); if (propertyDefinition != null) { String deflatedPropertyName = addVisibilityToExtendedDataColumnName(graph, column); addPropertyDefinitionToIndex(graph, indexInfo, deflatedPropertyName, column.getVisibility(), propertyDefinition); } } }
private Map<String, Map<String, List<ExtendedDataMutation>>> mapExtendedDatasByTableByRow(Iterable<ExtendedDataMutation> extendedData) { Map<String, Map<String, List<ExtendedDataMutation>>> results = new HashMap<>(); for (ExtendedDataMutation ed : extendedData) { Map<String, List<ExtendedDataMutation>> byRow = results.computeIfAbsent(ed.getTableName(), k -> new HashMap<>()); List<ExtendedDataMutation> items = byRow.computeIfAbsent(ed.getRow(), k -> new ArrayList<>()); items.add(ed); } return results; }
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; }