@SuppressWarnings("OptionalGetWithoutIsPresent") static GlobalUniqueIndex createGlobalUniqueIndex(SqlgGraph sqlgGraph, Topology topology, String globalUniqueIndexName, Set<PropertyColumn> properties) { //all PropertyColumns must be for the same PropertyType PropertyType propertyType = properties.iterator().next().getPropertyType(); Map<String, PropertyType> valueColumn = new HashMap<>(); valueColumn.put(GLOBAL_UNIQUE_INDEX_RECORD_ID, PropertyType.STRING); valueColumn.put(GLOBAL_UNIQUE_INDEX_PROPERTY_NAME, PropertyType.STRING); valueColumn.put(GLOBAL_UNIQUE_INDEX_VALUE, propertyType); VertexLabel vertexLabel = topology.getGlobalUniqueIndexSchema().ensureVertexLabelExist(globalUniqueIndexName, valueColumn); PropertyColumn valuePropertyColumn = vertexLabel.getProperty(GLOBAL_UNIQUE_INDEX_VALUE).get(); PropertyColumn recordIdColumn = vertexLabel.getProperty(GLOBAL_UNIQUE_INDEX_RECORD_ID).get(); PropertyColumn propertyColumn = vertexLabel.getProperty(GLOBAL_UNIQUE_INDEX_PROPERTY_NAME).get(); vertexLabel.ensureIndexExists(IndexType.UNIQUE, Collections.singletonList(valuePropertyColumn)); vertexLabel.ensureIndexExists(IndexType.UNIQUE, Arrays.asList(recordIdColumn, propertyColumn)); GlobalUniqueIndex globalUniqueIndex = new GlobalUniqueIndex(topology, globalUniqueIndexName, properties); topology.getGlobalUniqueIndexSchema().globalUniqueIndexes.put(globalUniqueIndex.getName(),globalUniqueIndex); TopologyManager.addGlobalUniqueIndex(sqlgGraph, globalUniqueIndexName, properties); globalUniqueIndex.committed = false; return globalUniqueIndex; }
@SuppressWarnings("OptionalGetWithoutIsPresent") static GlobalUniqueIndex createGlobalUniqueIndex(SqlgGraph sqlgGraph, Topology topology, String globalUniqueIndexName, Set<PropertyColumn> properties) { //all PropertyColumns must be for the same PropertyType PropertyType propertyType = properties.iterator().next().getPropertyType(); Map<String, PropertyType> valueColumn = new HashMap<>(); valueColumn.put(GLOBAL_UNIQUE_INDEX_RECORD_ID, PropertyType.STRING); valueColumn.put(GLOBAL_UNIQUE_INDEX_PROPERTY_NAME, PropertyType.STRING); valueColumn.put(GLOBAL_UNIQUE_INDEX_VALUE, propertyType); VertexLabel vertexLabel = topology.getGlobalUniqueIndexSchema().ensureVertexLabelExist(globalUniqueIndexName, valueColumn); PropertyColumn valuePropertyColumn = vertexLabel.getProperty(GLOBAL_UNIQUE_INDEX_VALUE).get(); PropertyColumn recordIdColumn = vertexLabel.getProperty(GLOBAL_UNIQUE_INDEX_RECORD_ID).get(); PropertyColumn propertyColumn = vertexLabel.getProperty(GLOBAL_UNIQUE_INDEX_PROPERTY_NAME).get(); vertexLabel.ensureIndexExists(IndexType.UNIQUE, Collections.singletonList(valuePropertyColumn)); vertexLabel.ensureIndexExists(IndexType.UNIQUE, Arrays.asList(recordIdColumn, propertyColumn)); GlobalUniqueIndex globalUniqueIndex = new GlobalUniqueIndex(topology, globalUniqueIndexName, properties); topology.getGlobalUniqueIndexSchema().globalUniqueIndexes.put(globalUniqueIndex.getName(),globalUniqueIndex); TopologyManager.addGlobalUniqueIndex(sqlgGraph, globalUniqueIndexName, properties); globalUniqueIndex.committed = false; return globalUniqueIndex; }
public void ensurePropertiesExist(Map<String, PropertyType> columns) { for (Map.Entry<String, PropertyType> column : columns.entrySet()) { if (!this.properties.containsKey(column.getKey())) { Preconditions.checkState(!this.schema.isSqlgSchema(), "schema may not be %s", SQLG_SCHEMA); if (!this.uncommittedProperties.containsKey(column.getKey())) { this.schema.getTopology().lock(); if (!getProperty(column.getKey()).isPresent()) { TopologyManager.addVertexColumn(this.sqlgGraph, this.schema.getName(), VERTEX_PREFIX + getLabel(), column); addColumn(this.schema.getName(), VERTEX_PREFIX + getLabel(), ImmutablePair.of(column.getKey(), column.getValue())); PropertyColumn propertyColumn = new PropertyColumn(this, column.getKey(), column.getValue()); propertyColumn.setCommitted(false); this.uncommittedProperties.put(column.getKey(), propertyColumn); this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.CREATE); } } } } }
public void ensurePropertiesExist(Map<String, PropertyType> columns) { for (Map.Entry<String, PropertyType> column : columns.entrySet()) { if (!this.properties.containsKey(column.getKey())) { Preconditions.checkState(!this.schema.isSqlgSchema(), "schema may not be %s", SQLG_SCHEMA); if (!this.uncommittedProperties.containsKey(column.getKey())) { this.schema.getTopology().lock(); if (!getProperty(column.getKey()).isPresent()) { TopologyManager.addVertexColumn(this.sqlgGraph, this.schema.getName(), VERTEX_PREFIX + getLabel(), column); addColumn(this.schema.getName(), VERTEX_PREFIX + getLabel(), ImmutablePair.of(column.getKey(), column.getValue())); PropertyColumn propertyColumn = new PropertyColumn(this, column.getKey(), column.getValue()); propertyColumn.setCommitted(false); this.uncommittedProperties.put(column.getKey(), propertyColumn); this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.CREATE); } } } } }
/** * @deprecated Please use {@link Topology#ensureVertexLabelExist(String, Map)} and {@link VertexLabel#ensureIndexExists(IndexType, List)}. */ @Deprecated public void createVertexLabeledIndex(String label, Object... dummykeyValues) { Map<String, PropertyType> columns = SqlgUtil.transformToColumnDefinitionMap(dummykeyValues); SchemaTable schemaTablePair = SchemaTable.from(this, label); VertexLabel vertexLabel = this.getTopology().ensureVertexLabelExist(schemaTablePair.getSchema(), schemaTablePair.getTable(), columns); List<PropertyColumn> properties = new ArrayList<>(); List<String> keys = SqlgUtil.transformToKeyList(dummykeyValues); for (String key : keys) { properties.add(vertexLabel.getProperty(key).get()); } vertexLabel.ensureIndexExists(IndexType.NON_UNIQUE, properties); }
/** * @deprecated Please use {@link Topology#ensureVertexLabelExist(String, Map)} and {@link VertexLabel#ensureIndexExists(IndexType, List)}. */ @Deprecated public void createVertexLabeledIndex(String label, Object... dummykeyValues) { Map<String, PropertyType> columns = SqlgUtil.transformToColumnDefinitionMap(dummykeyValues); SchemaTable schemaTablePair = SchemaTable.from(this, label); VertexLabel vertexLabel = this.getTopology().ensureVertexLabelExist(schemaTablePair.getSchema(), schemaTablePair.getTable(), columns); List<PropertyColumn> properties = new ArrayList<>(); List<String> keys = SqlgUtil.transformToKeyList(dummykeyValues); for (String key : keys) { properties.add(vertexLabel.getProperty(key).get()); } vertexLabel.ensureIndexExists(IndexType.NON_UNIQUE, properties); }
i, preparedStatement, ImmutablePair.of(inVertexLabel.getProperty(identifier).orElseThrow(() -> new IllegalStateException(String.format("identifier %s not a property.", identifier))).getPropertyType(), inVertex.value(identifier))); i, preparedStatement, ImmutablePair.of(outVertexLabel.getProperty(identifier).orElseThrow(() -> new IllegalStateException(String.format("identifier %s not a property.", identifier))).getPropertyType(), outVertex.value(identifier)));
i, preparedStatement, ImmutablePair.of(inVertexLabel.getProperty(identifier).orElseThrow(() -> new IllegalStateException(String.format("identifier %s not a property.", identifier))).getPropertyType(), inVertex.value(identifier))); i, preparedStatement, ImmutablePair.of(outVertexLabel.getProperty(identifier).orElseThrow(() -> new IllegalStateException(String.format("identifier %s not a property.", identifier))).getPropertyType(), outVertex.value(identifier)));
Schema guiPropertySchema = getSchema(schemaVertex.<String>property("name").value()).get(); VertexLabel guiPropertyVertexLabel = guiPropertySchema.getVertexLabel(vertexVertex.<String>property("name").value()).get(); PropertyColumn propertyColumn = guiPropertyVertexLabel.getProperty(globalUniqueIndexPropertyVertex.<String>property("name").value()).get(); guiPropertyColumns.add(propertyColumn); } else {
Schema guiPropertySchema = getSchema(schemaVertex.<String>property("name").value()).get(); VertexLabel guiPropertyVertexLabel = guiPropertySchema.getVertexLabel(vertexVertex.<String>property("name").value()).get(); PropertyColumn propertyColumn = guiPropertyVertexLabel.getProperty(globalUniqueIndexPropertyVertex.<String>property("name").value()).get(); guiPropertyColumns.add(propertyColumn); } else {
for (String identifier : inVertexLabel.getIdentifiers()) { bulkCopy.addColumnMapping(i, metaEdge.getInLabel() + "." + identifier + Topology.IN_VERTEX_COLUMN_END); PropertyType propertyType = inVertexLabel.getProperty(identifier).orElseThrow(() -> new IllegalStateException(String.format("BUG: Did not find the identifier property %s.", identifier))).getPropertyType(); this.columnMetadata.put(i++, new ColumnMetadata( metaEdge.getInLabel() + "." + identifier + Topology.IN_VERTEX_COLUMN_END, } else { for (String identifier : outVertexLabel.getIdentifiers()) { PropertyType propertyType = outVertexLabel.getProperty(identifier).orElseThrow(() -> new IllegalStateException(String.format("BUG: Did not find the identifier property %s.", identifier))).getPropertyType(); bulkCopy.addColumnMapping(i, metaEdge.getOutLabel() + "." + identifier + Topology.OUT_VERTEX_COLUMN_END); this.columnMetadata.put(i++, new ColumnMetadata(
i, preparedStatement, ImmutablePair.of(outVertexLabel.getProperty(identifier).orElseThrow( () -> new IllegalStateException(String.format("Property for identifier %s not found", identifier)) ).getPropertyType(), parameterValueMap.getLeft().value(identifier))); i, preparedStatement, ImmutablePair.of(inVertexLabel.getProperty(identifier).orElseThrow( () -> new IllegalStateException(String.format("Property for identifier %s not found", identifier)) ).getPropertyType(), parameterValueMap.getMiddle().value(identifier)));
i, preparedStatement, ImmutablePair.of(outVertexLabel.getProperty(identifier).orElseThrow( () -> new IllegalStateException(String.format("Property for identifier %s not found", identifier)) ).getPropertyType(), parameterValueMap.getLeft().value(identifier))); i, preparedStatement, ImmutablePair.of(inVertexLabel.getProperty(identifier).orElseThrow( () -> new IllegalStateException(String.format("Property for identifier %s not found", identifier)) ).getPropertyType(), parameterValueMap.getMiddle().value(identifier)));
int i = 1; for (String identifier : inVertexLabel.getIdentifiers()) { PropertyColumn propertyColumn = inVertexLabel.getProperty(identifier).orElseThrow( () -> new IllegalStateException(String.format("identifier %s column must be a property", identifier)) ); PropertyColumn propertyColumn = outVertexLabel.getProperty(identifier).orElseThrow( () -> new IllegalStateException(String.format("identifier %s column must be a property", identifier)) );
int i = 1; for (String identifier : inVertexLabel.getIdentifiers()) { PropertyColumn propertyColumn = inVertexLabel.getProperty(identifier).orElseThrow( () -> new IllegalStateException(String.format("identifier %s column must be a property", identifier)) ); PropertyColumn propertyColumn = outVertexLabel.getProperty(identifier).orElseThrow( () -> new IllegalStateException(String.format("identifier %s column must be a property", identifier)) );
vertexLabel.getProperty(propertyName).ifPresent((PropertyColumn pc) -> idx.addProperty(pc));
vertexLabel.getProperty(propertyName).ifPresent((PropertyColumn pc) -> idx.addProperty(pc));