void addGlobalUniqueIndexToUncommittedProperties(PropertyColumn propertyColumn) { this.uncommittedGlobalUniqueIndexProperties.put(propertyColumn.getName(), propertyColumn); }
void addGlobalUniqueIndexToProperties(PropertyColumn propertyColumn) { this.globalUniqueIndexProperties.put(propertyColumn.getName(), propertyColumn); }
void addGlobalUniqueIndexToProperties(PropertyColumn propertyColumn) { this.globalUniqueIndexProperties.put(propertyColumn.getName(), propertyColumn); }
@Override public Object[] getRowData() { List<Object> values = new ArrayList<>(); Object value = this.currentRow.get(this.propertyColumn.getName()); if (value == null) { value = "dummy_" + UUID.randomUUID().toString(); } values.add(value); values.add(this.currentVertex.id().toString()); values.add(this.propertyColumn.getName()); return values.toArray(); }
@Override public Object[] getRowData() { List<Object> values = new ArrayList<>(); Object value = this.currentRow.getRight().get(this.propertyColumn.getName()); if (value == null) { value = "dummy_" + UUID.randomUUID().toString(); } values.add(value); values.add(this.currentEdge.id().toString()); values.add(this.propertyColumn.getName()); return values.toArray(); }
void insertGlobalUniqueIndex(Map<String, Object> keyValueMap, Map<String, PropertyColumn> propertyColumns) { for (PropertyColumn propertyColumn : propertyColumns.values()) { for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { Object value = keyValueMap.get(propertyColumn.getName()); Pair<PropertyColumn, Object> propertyColumnObjectPair = Pair.of(propertyColumn, value); this.insertGlobalUniqueIndex(this.sqlgGraph, globalUniqueIndex, propertyColumnObjectPair); } } }
void insertGlobalUniqueIndex(Map<String, Object> keyValueMap, Map<String, PropertyColumn> propertyColumns) { for (PropertyColumn propertyColumn : propertyColumns.values()) { for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { Object value = keyValueMap.get(propertyColumn.getName()); Pair<PropertyColumn, Object> propertyColumnObjectPair = Pair.of(propertyColumn, value); this.insertGlobalUniqueIndex(this.sqlgGraph, globalUniqueIndex, propertyColumnObjectPair); } } }
@SuppressWarnings("OptionalGetWithoutIsPresent") static String globalUniqueIndexName(Topology topology, Set<PropertyColumn> properties) { List<PropertyColumn> propertyColumns = new ArrayList<>(properties); propertyColumns.sort(Comparator.comparing(PropertyColumn::getName)); String name = propertyColumns.stream().map(p -> p.getParentLabel().getLabel() + "_" + p.getName()).reduce((a, b) -> a + "_" + b).get(); if (("gui_schema_V_A" + name).length() > 50) { name = "globalUniqueIndex_" + topology.getGlobalUniqueIndexes().size(); } return name; }
@SuppressWarnings("OptionalGetWithoutIsPresent") static String globalUniqueIndexName(Topology topology, Set<PropertyColumn> properties) { List<PropertyColumn> propertyColumns = new ArrayList<>(properties); propertyColumns.sort(Comparator.comparing(PropertyColumn::getName)); String name = propertyColumns.stream().map(p -> p.getParentLabel().getLabel() + "_" + p.getName()).reduce((a, b) -> a + "_" + b).get(); if (("gui_schema_V_A" + name).length() > 50) { name = "globalUniqueIndex_" + topology.getGlobalUniqueIndexes().size(); } return name; }
private void buildQuestionMark(StringBuilder sql, VertexLabel vertexLabel) { if (vertexLabel.getIdentifiers().isEmpty()) { sql.append("?"); } else { for (String identifier : vertexLabel.getIdentifiers()) { if (!vertexLabel.isDistributed() || !vertexLabel.getDistributionPropertyColumn().getName().equals(identifier)) { sql.append("?, "); } } //remove the extra comma sql.delete(sql.length() - 2, sql.length()); } }
private void buildQuestionMark(StringBuilder sql, VertexLabel vertexLabel) { if (vertexLabel.getIdentifiers().isEmpty()) { sql.append("?"); } else { for (String identifier : vertexLabel.getIdentifiers()) { if (!vertexLabel.isDistributed() || !vertexLabel.getDistributionPropertyColumn().getName().equals(identifier)) { sql.append("?, "); } } //remove the extra comma sql.delete(sql.length() - 2, sql.length()); } }
private void distribute(int shard_count, PropertyColumn distributionPropertyColumn, AbstractLabel colocate) { Preconditions.checkArgument(getIdentifiers().contains(distributionPropertyColumn.getName()), "The distribution column must be part of the primary key"); Connection conn = sqlgGraph.tx().getConnection(); if (shard_count > -1) { try (Statement stmt = conn.createStatement()) { String sql = "SET citus.shard_count = " + shard_count + ";"; logger.debug(sql); stmt.execute(sql); } catch (SQLException e) { throw new RuntimeException(e); } } distribute(conn, distributionPropertyColumn, colocate); }
@Override public int hashCode() { return (this.abstractLabel.getSchema().getName() + this.abstractLabel.getLabel() + this.getName()).hashCode(); }
@Override public int hashCode() { return (this.abstractLabel.getSchema().getName() + this.abstractLabel.getLabel() + this.getName()).hashCode(); }
@Override void removeProperty(PropertyColumn propertyColumn, boolean preserveData) { this.getSchema().getTopology().lock(); if (!uncommittedRemovedProperties.contains(propertyColumn.getName())) { uncommittedRemovedProperties.add(propertyColumn.getName()); TopologyManager.removeVertexColumn(this.sqlgGraph, this.schema.getName(), VERTEX_PREFIX + getLabel(), propertyColumn.getName()); if (!preserveData) { removeColumn(this.schema.getName(), VERTEX_PREFIX + getLabel(), propertyColumn.getName()); } this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.DELETE); } }
@Override void removeProperty(PropertyColumn propertyColumn, boolean preserveData) { this.getSchema().getTopology().lock(); if (!uncommittedRemovedProperties.contains(propertyColumn.getName())) { uncommittedRemovedProperties.add(propertyColumn.getName()); TopologyManager.removeVertexColumn(this.sqlgGraph, this.schema.getName(), VERTEX_PREFIX + getLabel(), propertyColumn.getName()); if (!preserveData) { removeColumn(this.schema.getName(), VERTEX_PREFIX + getLabel(), propertyColumn.getName()); } this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.DELETE); } }
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)); } } } }
@Override void removeProperty(PropertyColumn propertyColumn, boolean preserveData) { this.getSchema().getTopology().lock(); if (!uncommittedRemovedProperties.contains(propertyColumn.getName())) { uncommittedRemovedProperties.add(propertyColumn.getName()); TopologyManager.removeEdgeColumn(this.sqlgGraph, this.getSchema().getName(), EDGE_PREFIX + getLabel(), propertyColumn.getName()); if (!preserveData) { removeColumn(this.getSchema().getName(), EDGE_PREFIX + getLabel(), propertyColumn.getName()); } this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.DELETE); } }
@Override void removeProperty(PropertyColumn propertyColumn, boolean preserveData) { this.getSchema().getTopology().lock(); if (!uncommittedRemovedProperties.contains(propertyColumn.getName())) { uncommittedRemovedProperties.add(propertyColumn.getName()); TopologyManager.removeEdgeColumn(this.sqlgGraph, this.getSchema().getName(), EDGE_PREFIX + getLabel(), propertyColumn.getName()); if (!preserveData) { removeColumn(this.getSchema().getName(), EDGE_PREFIX + getLabel(), propertyColumn.getName()); } this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.DELETE); } }