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); } } }
PropertyColumn propertyColumn = propertyColumnEntry.getValue(); if (propertyNames.contains(propertyColumn.getName())) { for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { StringBuilder sql = new StringBuilder(); sql.append("UPDATE ");
PropertyColumn propertyColumn = propertyColumnEntry.getValue(); if (propertyNames.contains(propertyColumn.getName())) { for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { StringBuilder sql = new StringBuilder(); sql.append("UPDATE ");
private void removeGlobalUniqueIndex() { Map<String, PropertyColumn> properties = this.sqlgGraph.getTopology().getPropertiesWithGlobalUniqueIndexFor(this.getSchemaTablePrefixed()); for (PropertyColumn propertyColumn : properties.values()) { for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { StringBuilder sql = new StringBuilder("DELETE FROM "); sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(Schema.GLOBAL_UNIQUE_INDEX_SCHEMA)); sql.append("."); sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(VERTEX_PREFIX + globalUniqueIndex.getName())); sql.append(" WHERE "); sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes("recordId")); sql.append(" = ? AND "); sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes("property")); sql.append(" = ?"); if (this.sqlgGraph.getSqlDialect().needsSemicolon()) { sql.append(";"); } if (logger.isDebugEnabled()) { logger.debug(sql.toString()); } Connection conn = this.sqlgGraph.tx().getConnection(); try (PreparedStatement preparedStatement = conn.prepareStatement(sql.toString())) { preparedStatement.setString(1, this.id().toString()); preparedStatement.setString(2, propertyColumn.getName()); preparedStatement.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } } } }
private void removeGlobalUniqueIndex() { Map<String, PropertyColumn> properties = this.sqlgGraph.getTopology().getPropertiesWithGlobalUniqueIndexFor(this.getSchemaTablePrefixed()); for (PropertyColumn propertyColumn : properties.values()) { for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { StringBuilder sql = new StringBuilder("DELETE FROM "); sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(Schema.GLOBAL_UNIQUE_INDEX_SCHEMA)); sql.append("."); sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(VERTEX_PREFIX + globalUniqueIndex.getName())); sql.append(" WHERE "); sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes("recordId")); sql.append(" = ? AND "); sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes("property")); sql.append(" = ?"); if (this.sqlgGraph.getSqlDialect().needsSemicolon()) { sql.append(";"); } if (logger.isDebugEnabled()) { logger.debug(sql.toString()); } Connection conn = this.sqlgGraph.tx().getConnection(); try (PreparedStatement preparedStatement = conn.prepareStatement(sql.toString())) { preparedStatement.setString(1, this.id().toString()); preparedStatement.setString(2, propertyColumn.getName()); preparedStatement.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } } } }
Map<String, PropertyColumn> propertyColumns = sqlgGraph.getTopology().getPropertiesWithGlobalUniqueIndexFor(schemaTable.withPrefix(VERTEX_PREFIX)); for (PropertyColumn propertyColumn : propertyColumns.values()) { for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { List<SqlgVertex> vertices = schemaVertices.getValue();
Map<String, PropertyColumn> propertyColumns = sqlgGraph.getTopology().getPropertiesWithGlobalUniqueIndexFor(schemaTable.withPrefix(VERTEX_PREFIX)); for (PropertyColumn propertyColumn : propertyColumns.values()) { for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { List<SqlgVertex> vertices = schemaVertices.getValue();
for (Map.Entry<String, PropertyColumn> propertyColumnEntry : propertyColumnMap.entrySet()) { PropertyColumn propertyColumn = propertyColumnEntry.getValue(); for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { Map<SqlgVertex, Map<String, Object>> rows = vertices.getRight(); StringBuilder sql = new StringBuilder();
for (Map.Entry<String, PropertyColumn> propertyColumnEntry : propertyColumnMap.entrySet()) { PropertyColumn propertyColumn = propertyColumnEntry.getValue(); for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { Map<SqlgVertex, Map<String, Object>> rows = vertices.getRight(); StringBuilder sql = new StringBuilder();
for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) {
for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) {
@Override public void flushVertexGlobalUniqueIndexes(SqlgGraph sqlgGraph, Map<SchemaTable, Pair<SortedSet<String>, Map<SqlgVertex, Map<String, Object>>>> vertexCache) { for (SchemaTable schemaTable : vertexCache.keySet()) { Pair<SortedSet<String>, Map<SqlgVertex, Map<String, Object>>> vertices = vertexCache.get(schemaTable); Map<String, PropertyColumn> propertyColumnMap = sqlgGraph.getTopology().getPropertiesFor(schemaTable.withPrefix(VERTEX_PREFIX)); for (Map.Entry<String, PropertyColumn> propertyColumnEntry : propertyColumnMap.entrySet()) { PropertyColumn propertyColumn = propertyColumnEntry.getValue(); for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { try { Connection connection = sqlgGraph.tx().getConnection(); SQLServerConnection sqlServerConnection = connection.unwrap(SQLServerConnection.class); try (SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(sqlServerConnection)) { bulkCopy.setDestinationTableName(sqlgGraph.getSqlDialect().maybeWrapInQoutes(Schema.GLOBAL_UNIQUE_INDEX_SCHEMA) + "." + sqlgGraph.getSqlDialect().maybeWrapInQoutes(VERTEX_PREFIX + globalUniqueIndex.getName()) ); bulkCopy.writeToServer(new SQLServerVertexGlobalUniqueIndexBulkRecord(bulkCopy, sqlgGraph, vertices, propertyColumn)); } } catch (SQLException e) { throw new RuntimeException(e); } } } } }
@Override public void flushEdgeGlobalUniqueIndexes(SqlgGraph sqlgGraph, Map<MetaEdge, Pair<SortedSet<String>, Map<SqlgEdge, Triple<SqlgVertex, SqlgVertex, Map<String, Object>>>>> edgeCache) { for (MetaEdge metaEdge : edgeCache.keySet()) { Pair<SortedSet<String>, Map<SqlgEdge, Triple<SqlgVertex, SqlgVertex, Map<String, Object>>>> triples = edgeCache.get(metaEdge); Map<SqlgEdge, Triple<SqlgVertex, SqlgVertex, Map<String, Object>>> edgeMap = triples.getRight(); Map<String, PropertyColumn> propertyColumnMap = sqlgGraph.getTopology().getPropertiesFor(metaEdge.getSchemaTable().withPrefix(EDGE_PREFIX)); for (Map.Entry<String, PropertyColumn> propertyColumnEntry : propertyColumnMap.entrySet()) { PropertyColumn propertyColumn = propertyColumnEntry.getValue(); for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { try { Connection connection = sqlgGraph.tx().getConnection(); SQLServerConnection sqlServerConnection = connection.unwrap(SQLServerConnection.class); try (SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(sqlServerConnection)) { bulkCopy.setDestinationTableName(sqlgGraph.getSqlDialect().maybeWrapInQoutes(Schema.GLOBAL_UNIQUE_INDEX_SCHEMA) + "." + sqlgGraph.getSqlDialect().maybeWrapInQoutes(VERTEX_PREFIX + globalUniqueIndex.getName()) ); bulkCopy.writeToServer(new SQLServerEdgeGlobalUniqueIndexBulkRecord(bulkCopy, sqlgGraph, edgeMap, propertyColumn)); } } catch (SQLException e) { throw new RuntimeException(e); } } } } }
for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { SqlgElement.updateGlobalUniqueIndex(this.sqlgGraph, globalUniqueIndex, this.recordId, propertyColumnObjectPair);
for (GlobalUniqueIndex globalUniqueIndex : propertyColumn.getGlobalUniqueIndices()) { SqlgElement.updateGlobalUniqueIndex(this.sqlgGraph, globalUniqueIndex, this.recordId, propertyColumnObjectPair);