@SuppressWarnings("WeakerAccess") public boolean isInBatchMode() { return supportsBatchMode() && isInNormalBatchMode() || isInStreamingBatchMode() || isInStreamingWithLockBatchMode(); }
@SuppressWarnings("WeakerAccess") public boolean isInBatchMode() { return supportsBatchMode() && isInNormalBatchMode() || isInStreamingBatchMode() || isInStreamingWithLockBatchMode(); }
public void streamVertex(String label, LinkedHashMap<String, Object> keyValues) { if (!this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(TRANSACTION_MUST_BE_IN + this.tx().getBatchModeType().toString() + MODE_FOR_STREAM_VERTEX); } Map<Object, Object> tmp = new LinkedHashMap<>(keyValues); tmp.put(T.label, label); Object[] keyValues1 = SqlgUtil.mapTokeyValues(tmp); streamVertex(keyValues1); }
public void streamTemporaryVertex(String label, LinkedHashMap<String, Object> keyValues) { if (!this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(TRANSACTION_MUST_BE_IN + this.tx().getBatchModeType().toString() + MODE_FOR_STREAM_VERTEX); } Map<Object, Object> tmp = new LinkedHashMap<>(keyValues); tmp.put(T.label, label); Object[] keyValues1 = SqlgUtil.mapTokeyValues(tmp); streamTemporaryVertex(keyValues1); }
public void streamVertex(String label, LinkedHashMap<String, Object> keyValues) { if (!this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(TRANSACTION_MUST_BE_IN + this.tx().getBatchModeType().toString() + MODE_FOR_STREAM_VERTEX); } Map<Object, Object> tmp = new LinkedHashMap<>(keyValues); tmp.put(T.label, label); Object[] keyValues1 = SqlgUtil.mapTokeyValues(tmp); streamVertex(keyValues1); }
public void streamTemporaryVertex(String label, LinkedHashMap<String, Object> keyValues) { if (!this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(TRANSACTION_MUST_BE_IN + this.tx().getBatchModeType().toString() + MODE_FOR_STREAM_VERTEX); } Map<Object, Object> tmp = new LinkedHashMap<>(keyValues); tmp.put(T.label, label); Object[] keyValues1 = SqlgUtil.mapTokeyValues(tmp); streamTemporaryVertex(keyValues1); }
@Override public Edge addEdge(String label, Vertex inVertex, Object... keyValues) { this.sqlgGraph.tx().readWrite(); boolean streaming = this.sqlgGraph.getSqlDialect().supportsBatchMode() && (this.sqlgGraph.tx().isInStreamingBatchMode() || this.sqlgGraph.tx().isInStreamingWithLockBatchMode()); if (streaming) { SchemaTable streamingBatchModeEdgeLabel = this.sqlgGraph.tx().getBatchManager().getStreamingBatchModeEdgeSchemaTable(); if (streamingBatchModeEdgeLabel != null && !streamingBatchModeEdgeLabel.getTable().substring(EDGE_PREFIX.length()).equals(label)) { throw new IllegalStateException("Streaming batch mode must occur for one label at a time. Expected \"" + streamingBatchModeEdgeLabel + "\" found \"" + label + "\". First commit the transaction or call SqlgGraph.flush() before streaming a different label"); } } return addEdgeInternal(streaming, label, inVertex, keyValues); }
@Override public Edge addEdge(String label, Vertex inVertex, Object... keyValues) { this.sqlgGraph.tx().readWrite(); boolean streaming = this.sqlgGraph.getSqlDialect().supportsBatchMode() && (this.sqlgGraph.tx().isInStreamingBatchMode() || this.sqlgGraph.tx().isInStreamingWithLockBatchMode()); if (streaming) { SchemaTable streamingBatchModeEdgeLabel = this.sqlgGraph.tx().getBatchManager().getStreamingBatchModeEdgeSchemaTable(); if (streamingBatchModeEdgeLabel != null && !streamingBatchModeEdgeLabel.getTable().substring(EDGE_PREFIX.length()).equals(label)) { throw new IllegalStateException("Streaming batch mode must occur for one label at a time. Expected \"" + streamingBatchModeEdgeLabel + "\" found \"" + label + "\". First commit the transaction or call SqlgGraph.flush() before streaming a different label"); } } return addEdgeInternal(streaming, label, inVertex, keyValues); }
public void streamVertex(Object... keyValues) { if (!this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(TRANSACTION_MUST_BE_IN + this.tx().getBatchModeType().toString() + MODE_FOR_STREAM_VERTEX); } internalStreamVertex(keyValues); }
public <L, R> void bulkAddEdges(String outVertexLabel, String inVertexLabel, String edgeLabel, Pair<String, String> idFields, Collection<Pair<L, R>> uids, Object... keyValues) { if (!(this.sqlDialect instanceof SqlBulkDialect)) { throw new UnsupportedOperationException(String.format("Bulk mode is not supported for %s", this.sqlDialect.dialectName())); } SqlBulkDialect sqlBulkDialect = (SqlBulkDialect) this.sqlDialect; if (!this.tx().isInStreamingBatchMode() && !this.tx().isInStreamingWithLockBatchMode()) { throw SqlgExceptions.invalidMode(TRANSACTION_MUST_BE_IN + BatchManager.BatchModeType.STREAMING + " or " + BatchManager.BatchModeType.STREAMING_WITH_LOCK + " mode for bulkAddEdges"); } if (!uids.isEmpty()) { SchemaTable outSchemaTable = SchemaTable.from(this, outVertexLabel); SchemaTable inSchemaTable = SchemaTable.from(this, inVertexLabel); Triple<Map<String, PropertyType>, Map<String, Object>, Map<String, Object>> keyValueMapTriple = SqlgUtil.validateVertexKeysValues(this.sqlDialect, keyValues); sqlBulkDialect.bulkAddEdges(this, outSchemaTable, inSchemaTable, edgeLabel, idFields, uids, keyValueMapTriple.getLeft(), keyValueMapTriple.getRight()); } }
public void streamEdge(String label, Vertex inVertex, LinkedHashMap<String, Object> keyValues) { if (!sqlgGraph.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode("Transaction must be in " + BatchManager.BatchModeType.STREAMING + " mode for streamEdge"); } if (this.sqlgGraph.tx().isOpen() && this.sqlgGraph.tx().getBatchManager().getStreamingBatchModeVertexSchemaTable() != null) { throw new IllegalStateException("Streaming vertex for label " + this.sqlgGraph.tx().getBatchManager().getStreamingBatchModeVertexSchemaTable().getTable() + " is in progress. Commit the transaction or call SqlgGraph.flush()"); } SchemaTable streamingBatchModeEdgeLabel = this.sqlgGraph.tx().getBatchManager().getStreamingBatchModeEdgeSchemaTable(); if (streamingBatchModeEdgeLabel != null && !streamingBatchModeEdgeLabel.getTable().substring(EDGE_PREFIX.length()).equals(label)) { throw new IllegalStateException("Streaming batch mode must occur for one label at a time. Expected \"" + streamingBatchModeEdgeLabel + "\" found \"" + label + "\". First commit the transaction or call SqlgGraph.flush() before streaming a different label"); } Map<Object, Object> tmp = new LinkedHashMap<>(keyValues); Object[] keyValues1 = SqlgUtil.mapTokeyValues(tmp); addEdgeInternal(true, label, inVertex, keyValues1); }
public <L, R> void bulkAddEdges(String outVertexLabel, String inVertexLabel, String edgeLabel, Pair<String, String> idFields, Collection<Pair<L, R>> uids, Object... keyValues) { if (!(this.sqlDialect instanceof SqlBulkDialect)) { throw new UnsupportedOperationException(String.format("Bulk mode is not supported for %s", this.sqlDialect.dialectName())); } SqlBulkDialect sqlBulkDialect = (SqlBulkDialect) this.sqlDialect; if (!this.tx().isInStreamingBatchMode() && !this.tx().isInStreamingWithLockBatchMode()) { throw SqlgExceptions.invalidMode(TRANSACTION_MUST_BE_IN + BatchManager.BatchModeType.STREAMING + " or " + BatchManager.BatchModeType.STREAMING_WITH_LOCK + " mode for bulkAddEdges"); } if (!uids.isEmpty()) { SchemaTable outSchemaTable = SchemaTable.from(this, outVertexLabel); SchemaTable inSchemaTable = SchemaTable.from(this, inVertexLabel); Triple<Map<String, PropertyType>, Map<String, Object>, Map<String, Object>> keyValueMapTriple = SqlgUtil.validateVertexKeysValues(this.sqlDialect, keyValues); sqlBulkDialect.bulkAddEdges(this, outSchemaTable, inSchemaTable, edgeLabel, idFields, uids, keyValueMapTriple.getLeft(), keyValueMapTriple.getRight()); } }
public void streamEdge(String label, Vertex inVertex, LinkedHashMap<String, Object> keyValues) { if (!sqlgGraph.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode("Transaction must be in " + BatchManager.BatchModeType.STREAMING + " mode for streamEdge"); } if (this.sqlgGraph.tx().isOpen() && this.sqlgGraph.tx().getBatchManager().getStreamingBatchModeVertexSchemaTable() != null) { throw new IllegalStateException("Streaming vertex for label " + this.sqlgGraph.tx().getBatchManager().getStreamingBatchModeVertexSchemaTable().getTable() + " is in progress. Commit the transaction or call SqlgGraph.flush()"); } SchemaTable streamingBatchModeEdgeLabel = this.sqlgGraph.tx().getBatchManager().getStreamingBatchModeEdgeSchemaTable(); if (streamingBatchModeEdgeLabel != null && !streamingBatchModeEdgeLabel.getTable().substring(EDGE_PREFIX.length()).equals(label)) { throw new IllegalStateException("Streaming batch mode must occur for one label at a time. Expected \"" + streamingBatchModeEdgeLabel + "\" found \"" + label + "\". First commit the transaction or call SqlgGraph.flush() before streaming a different label"); } Map<Object, Object> tmp = new LinkedHashMap<>(keyValues); Object[] keyValues1 = SqlgUtil.mapTokeyValues(tmp); addEdgeInternal(true, label, inVertex, keyValues1); }
private void streamTemporaryVertex(Object... keyValues) { if (!this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(TRANSACTION_MUST_BE_IN + this.tx().getBatchModeType().toString() + MODE_FOR_STREAM_VERTEX); } internalStreamTemporaryVertex(keyValues); }
private void streamTemporaryVertex(Object... keyValues) { if (!this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(TRANSACTION_MUST_BE_IN + this.tx().getBatchModeType().toString() + MODE_FOR_STREAM_VERTEX); } internalStreamTemporaryVertex(keyValues); }
public void streamVertex(Object... keyValues) { if (!this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(TRANSACTION_MUST_BE_IN + this.tx().getBatchModeType().toString() + MODE_FOR_STREAM_VERTEX); } internalStreamVertex(keyValues); }
public void addTemporaryVertex(Object... keyValues) { if (this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(String.format("Transaction is in %s, use streamVertex(Object ... keyValues)", this.tx().getBatchModeType().toString())); } Triple<Map<String, PropertyType>, Map<String, Object>, Map<String, Object>> keyValueMapTriple = SqlgUtil.validateVertexKeysValues(this.sqlDialect, keyValues); final String label = ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL); SchemaTable schemaTablePair = SchemaTable.from(this, label, true); final Map<String, PropertyType> columns = keyValueMapTriple.getLeft(); this.getTopology().ensureTemporaryVertexTableExist(schemaTablePair.getSchema(), schemaTablePair.getTable(), columns); final Pair<Map<String, Object>, Map<String, Object>> keyValueMapPair = Pair.of(keyValueMapTriple.getMiddle(), keyValueMapTriple.getRight()); new SqlgVertex(this, true, false, schemaTablePair.getSchema(), schemaTablePair.getTable(), keyValueMapPair); }
public void addTemporaryVertex(Object... keyValues) { if (this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(String.format("Transaction is in %s, use streamVertex(Object ... keyValues)", this.tx().getBatchModeType().toString())); } Triple<Map<String, PropertyType>, Map<String, Object>, Map<String, Object>> keyValueMapTriple = SqlgUtil.validateVertexKeysValues(this.sqlDialect, keyValues); final String label = ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL); SchemaTable schemaTablePair = SchemaTable.from(this, label, true); final Map<String, PropertyType> columns = keyValueMapTriple.getLeft(); this.getTopology().ensureTemporaryVertexTableExist(schemaTablePair.getSchema(), schemaTablePair.getTable(), columns); final Pair<Map<String, Object>, Map<String, Object>> keyValueMapPair = Pair.of(keyValueMapTriple.getMiddle(), keyValueMapTriple.getRight()); new SqlgVertex(this, true, false, schemaTablePair.getSchema(), schemaTablePair.getTable(), keyValueMapPair); }
@Override public Vertex addVertex(Object... keyValues) { if (this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(String.format("Transaction is in %s, use streamVertex(Object ... keyValues)", this.tx().getBatchModeType().toString())); } if (this.tx().isInStreamingWithLockBatchMode()) { return internalStreamVertex(keyValues); } else { Triple<Map<String, PropertyType>, Map<String, Object>, Map<String, Object>> keyValueMapTriple = SqlgUtil.validateVertexKeysValues(this.sqlDialect, keyValues); final Pair<Map<String, Object>, Map<String, Object>> keyValueMapPair = Pair.of(keyValueMapTriple.getMiddle(), keyValueMapTriple.getRight()); final Map<String, PropertyType> columns = keyValueMapTriple.getLeft(); final String label = ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL); SchemaTable schemaTablePair = SchemaTable.from(this, label); this.tx().readWrite(); VertexLabel vertexLabel = this.getTopology().ensureVertexLabelExist(schemaTablePair.getSchema(), schemaTablePair.getTable(), columns); if (!vertexLabel.hasIDPrimaryKey()) { Preconditions.checkArgument(columns.keySet().containsAll(vertexLabel.getIdentifiers()), "identifiers must be present %s", vertexLabel.getIdentifiers()); } return new SqlgVertex(this, false, false, schemaTablePair.getSchema(), schemaTablePair.getTable(), keyValueMapPair); } }
@Override public Vertex addVertex(Object... keyValues) { if (this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(String.format("Transaction is in %s, use streamVertex(Object ... keyValues)", this.tx().getBatchModeType().toString())); } if (this.tx().isInStreamingWithLockBatchMode()) { return internalStreamVertex(keyValues); } else { Triple<Map<String, PropertyType>, Map<String, Object>, Map<String, Object>> keyValueMapTriple = SqlgUtil.validateVertexKeysValues(this.sqlDialect, keyValues); final Pair<Map<String, Object>, Map<String, Object>> keyValueMapPair = Pair.of(keyValueMapTriple.getMiddle(), keyValueMapTriple.getRight()); final Map<String, PropertyType> columns = keyValueMapTriple.getLeft(); final String label = ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL); SchemaTable schemaTablePair = SchemaTable.from(this, label); this.tx().readWrite(); VertexLabel vertexLabel = this.getTopology().ensureVertexLabelExist(schemaTablePair.getSchema(), schemaTablePair.getTable(), columns); if (!vertexLabel.hasIDPrimaryKey()) { Preconditions.checkArgument(columns.keySet().containsAll(vertexLabel.getIdentifiers()), "identifiers must be present %s", vertexLabel.getIdentifiers()); } return new SqlgVertex(this, false, false, schemaTablePair.getSchema(), schemaTablePair.getTable(), keyValueMapPair); } }