@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); } } } } }
try { SQLServerConnection sqlServerConnection = connection.unwrap(SQLServerConnection.class); try (SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(sqlServerConnection)) { SQLServerBulkCopyOptions options = new SQLServerBulkCopyOptions();
try (SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(sqlServerConnection)) { SQLServerBulkCopyOptions options = new SQLServerBulkCopyOptions();