/** * Sets the key to be used when setting the vertex id as a property on the respective vertex. * If the key is null, then no property will be set. * If the loaded baseGraph should later be wrapped with {@link IdGraph} use IdGraph.ID. * * @param key Key to be used. */ public void setVertexIdKey(final String key) { if (!loadingFromScratch && key == null && baseGraph.getFeatures().ignoresSuppliedIds) throw new IllegalStateException("Cannot set vertex id key to null when not loading from scratch while ids are ignored."); this.vertexIdKey = key; }
/** * Sets whether the graph loaded through this instance of {@link BatchGraph} is loaded from scratch * (i.e. the wrapped graph is initially empty) or whether graph is loaded incrementally into an * existing graph. * * In the former case, BatchGraph does not need to check for the existence of vertices with the wrapped * graph but only needs to consult its own cache which can be significantly faster. In the latter case, * the cache is checked first but an additional check against the wrapped graph may be necessary if * the vertex does not exist. * * By default, BatchGraph assumes that the data is loaded from scratch. * * When setting loading from scratch to false, a vertex id key must be specified first using * {@link #setVertexIdKey(String)} - otherwise an exception is thrown. * * @param fromScratch */ public void setLoadingFromScratch(boolean fromScratch) { if (fromScratch == false && vertexIdKey == null && baseGraph.getFeatures().ignoresSuppliedIds) throw new IllegalStateException("Vertex id key is required to query existing vertices in wrapped graph."); loadingFromScratch = fromScratch; }
@Override public Features getFeatures() { Features features = baseGraph.getFeatures().copyFeatures(); features.ignoresSuppliedIds = false; features.isWrapper = true; features.supportsEdgeIteration = false; features.supportsThreadedTransactions = false; features.supportsVertexIteration = false; return features; }
if (loadingFromScratch) return null; else { if (baseGraph.getFeatures().ignoresSuppliedIds) { assert vertexIdKey != null; Iterator<Vertex> iter = baseGraph.getVertices(vertexIdKey, id).iterator();