Map<String, PropertyType> getPropertyTypeMap() { Map<String, PropertyType> result = new HashMap<>(); for (Map.Entry<String, PropertyColumn> propertyEntry : this.properties.entrySet()) { result.put(propertyEntry.getKey(), propertyEntry.getValue().getPropertyType()); } if (getSchema().getTopology().isSqlWriteLockHeldByCurrentThread()) { for (Map.Entry<String, PropertyColumn> uncommittedPropertyEntry : this.uncommittedProperties.entrySet()) { result.put(uncommittedPropertyEntry.getKey(), uncommittedPropertyEntry.getValue().getPropertyType()); } for (String s : this.uncommittedRemovedProperties) { result.remove(s); } } return result; }
Map<String, PropertyType> getPropertyTypeMap() { Map<String, PropertyType> result = new HashMap<>(); for (Map.Entry<String, PropertyColumn> propertyEntry : this.properties.entrySet()) { result.put(propertyEntry.getKey(), propertyEntry.getValue().getPropertyType()); } if (getSchema().getTopology().isSqlWriteLockHeldByCurrentThread()) { for (Map.Entry<String, PropertyColumn> uncommittedPropertyEntry : this.uncommittedProperties.entrySet()) { result.put(uncommittedPropertyEntry.getKey(), uncommittedPropertyEntry.getValue().getPropertyType()); } for (String s : this.uncommittedRemovedProperties) { result.remove(s); } } return result; }
void appendProperties(AbstractLabel edgeLabel, StringBuilder sql) { for (PropertyColumn propertyColumn : edgeLabel.getProperties().values()) { sql.append(", "); sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(propertyColumn.getName())); // additional columns for time zone, etc. String[] ps = propertyColumn.getPropertyType().getPostFixes(); if (ps != null) { for (String p : propertyColumn.getPropertyType().getPostFixes()) { sql.append(", "); sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(propertyColumn.getName() + p)); } } } }
void appendProperties(AbstractLabel edgeLabel, StringBuilder sql) { for (PropertyColumn propertyColumn : edgeLabel.getProperties().values()) { sql.append(", "); sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(propertyColumn.getName())); // additional columns for time zone, etc. String[] ps = propertyColumn.getPropertyType().getPostFixes(); if (ps != null) { for (String p : propertyColumn.getPropertyType().getPostFixes()) { sql.append(", "); sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(propertyColumn.getName() + p)); } } } }
@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; }
@Override public boolean equals(Object o) { if (o == null) { return false; } if (!(o instanceof PropertyColumn)) { return false; } PropertyColumn other = (PropertyColumn) o; if (this.abstractLabel.getSchema().getName().equals(other.abstractLabel.getSchema().getName())) { if (this.abstractLabel.getLabel().equals(other.abstractLabel.getLabel())) { return this.getName().equals(other.getName()) && this.getPropertyType() == other.getPropertyType(); } else { return false; } } else { return false; } }
@Override public boolean equals(Object o) { if (o == null) { return false; } if (!(o instanceof PropertyColumn)) { return false; } PropertyColumn other = (PropertyColumn) o; if (this.abstractLabel.getSchema().getName().equals(other.abstractLabel.getSchema().getName())) { if (this.abstractLabel.getLabel().equals(other.abstractLabel.getLabel())) { return this.getName().equals(other.getName()) && this.getPropertyType() == other.getPropertyType(); } else { return false; } } else { return false; } }
for (GlobalUniqueIndex globalUniqueIndex : this.getGlobalUniqueIndexes()) { Map<String, PropertyType> properties = new LinkedHashMap<String, PropertyType>() {{ put(GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_VALUE, globalUniqueIndex.getProperties().stream().findAny().orElseThrow(IllegalStateException::new).getPropertyType()); put(GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_RECORD_ID, PropertyType.STRING); put(GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_PROPERTY_NAME, PropertyType.STRING);
if (value != null) { foundSomething = true; SqlgUtil.setKeyValuesAsParameterUsingPropertyColumn(sqlgGraph, true, 1, preparedStatement, Collections.singleton(Pair.of(propertyColumn.getPropertyType(), value))); preparedStatement.setString(2, t.id().toString()); preparedStatement.setString(3, propertyColumn.getName());
for (GlobalUniqueIndex globalUniqueIndex : this.getGlobalUniqueIndexes()) { Map<String, PropertyType> properties = new LinkedHashMap<String, PropertyType>() {{ put(GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_VALUE, globalUniqueIndex.getProperties().stream().findAny().orElseThrow(IllegalStateException::new).getPropertyType()); put(GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_RECORD_ID, PropertyType.STRING); put(GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_PROPERTY_NAME, PropertyType.STRING);
if (value != null) { foundSomething = true; SqlgUtil.setKeyValuesAsParameterUsingPropertyColumn(sqlgGraph, true, 1, preparedStatement, Collections.singleton(Pair.of(propertyColumn.getPropertyType(), value))); preparedStatement.setString(2, t.id().toString()); preparedStatement.setString(3, propertyColumn.getName());
.flatMap(e -> { Stream.Builder<String> keys = Stream.<String> builder().add(e.getKey()); PropertyType pt = e.getValue().getPropertyType(); String[] postfixes = sqlgGraph.getSqlDialect().propertyTypeToSqlDefinition(pt); for (int i = 1; i < postfixes.length; ++i) {
Optional<PropertyColumn> propertyColumn = abstractLabel.getProperty(identifier); if (propertyColumn.isPresent()) { PropertyType propertyType = propertyColumn.get().getPropertyType(); Comparable value = (Comparable) SqlgUtil.stringValueToType(propertyType, identifiers[count++].trim()); identifierValues.add(value);
sql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(VERTEX_PREFIX + globalUniqueIndex.getName())); sql.append(" ("); PropertyType propertyType = propertyColumn.getPropertyType(); String[] sqlDefinitions = sqlgGraph.getSqlDialect().propertyTypeToSqlDefinition(propertyType); int count = 1; Object value = parameterValueMap.get(propertyColumn.getName()); List<Pair<PropertyType, Object>> typeAndValues = new ArrayList<>(); typeAndValues.add(Pair.of(propertyColumn.getPropertyType(), value)); typeAndValues.add(Pair.of(PropertyType.STRING, sqlgVertex.id().toString())); typeAndValues.add(Pair.of(PropertyType.STRING, propertyColumn.getName()));
sql.append(sqlDialect.maybeWrapInQoutes(property.getName())); if (property.getPropertyType().isString() && sqlgGraph.getSqlDialect().requiresIndexLengthLimit()) {
sql.append(sqlDialect.maybeWrapInQoutes(property.getName())); if (property.getPropertyType().isString() && sqlgGraph.getSqlDialect().requiresIndexLengthLimit()) {
Optional<PropertyColumn> propertyColumn = abstractLabel.getProperty(identifier); if (propertyColumn.isPresent()) { PropertyType propertyType = propertyColumn.get().getPropertyType(); Comparable value = (Comparable) SqlgUtil.stringValueToType(propertyType, identifiers[count++].trim()); identifierValues.add(value);
PropertyType propertyType = propertyColumns.get(keyValueEntry.getKey()).getPropertyType(); Pair<PropertyType, Object> propertyTypeObjectPair = Pair.of(propertyType, keyValueEntry.getValue()); propertyTypeValueMap.put(keyValueEntry.getKey(), propertyTypeObjectPair);
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(