private <T extends Element> void createKeyIndex(final KeyIndexableGraph kig, final String key, Class<T> elementClass, final Parameter... indexParameters) { LOGGER.log(Level.INFO, "creating {0} index on property key {1}", new Object[]{elementClass.getSimpleName(), key}); kig.createKeyIndex(key, elementClass, indexParameters); LOGGER.log(Level.FINEST, "created {0} index on property key {1}", new Object[]{elementClass.getSimpleName(), key}); }
private void createIndices() { if (supportVertexIds && !baseGraph.getIndexedKeys(Vertex.class).contains(ID)) { baseGraph.createKeyIndex(ID, Vertex.class); } if (supportEdgeIds && !baseGraph.getIndexedKeys(Edge.class).contains(ID)) { baseGraph.createKeyIndex(ID, Edge.class); } }
@Override @SuppressWarnings("rawtypes") // indexParameters public <E extends Element> void createKeyIndex(String key, Class<E> elementClass, Parameter... indexParameters) { checkIndexableKey(key, elementClass); baseGraph.createKeyIndex(key, elementClass, indexParameters); }
@Override public <T extends Element> void createKeyIndex(final String key, final Class<T> elementClass, final Parameter... indexParameters) { if (key.equals(VEProps.NATURAL_VERTEX_ID_PROP_KEY) || key.equals(VEProps.NATURAL_EDGE_ID_PROP_KEY)) { throw new IllegalArgumentException(String.format("Index key [%s] is reserved and cannot be created", VEProps.NATURAL_VERTEX_ID_PROP_KEY)); } getEventableGraph().getBaseGraph().createKeyIndex(key, elementClass, indexParameters); }
public <T extends Element> void createKeyIndex(final String key, final Class<T> elementClass, final Parameter... indexParameters) { if (elementClass == null) throw ExceptionFactory.classForElementCannotBeNull(); boolean v = isVertexClass(elementClass); boolean supported = ((v && supportVertexIds) || (!v && supportEdgeIds)); if (supported && key.equals(ID)) { throw new IllegalArgumentException("index key " + ID + " is reserved by IdGraph"); } else { baseGraph.createKeyIndex(key, elementClass, indexParameters); } }
/** * Adds custom ID functionality to the given graph, supporting either custom vertex IDs, custom edge IDs, or both. * * @param baseGraph the base graph which does not necessarily support custom IDs * @param supportVertexIds whether to support custom vertex IDs * @param supportEdgeIds whether to support custom edge IDs */ public IdGraph(KeyIndexableGraph baseGraph, boolean supportVertexIds, boolean supportEdgeIds) { this.baseGraph = checkNotNull(baseGraph, "baseGraph"); this.supportVertexIds = supportVertexIds; this.supportEdgeIds = supportEdgeIds; checkArgument(supportVertexIds || supportEdgeIds, "If neither custom vertex IDs nor custom edge IDs are supported, IdGraph can't help you!"); // Create indices if (supportVertexIds && !baseGraph.getIndexedKeys(Vertex.class).contains(ID)) { baseGraph.createKeyIndex(ID, Vertex.class); } if (supportEdgeIds && !baseGraph.getIndexedKeys(Edge.class).contains(ID)) { baseGraph.createKeyIndex(ID, Edge.class); } features = baseGraph.getFeatures().copyFeatures(); features.isWrapper = true; features.ignoresSuppliedIds = false; }
((KeyIndexableGraph) graph).createKeyIndex("name", Vertex.class);
keyIndexedGraph.createKeyIndex(VEProps.NATURAL_VERTEX_ID_PROP_KEY, Vertex.class); keyIndexedGraph.createKeyIndex(VEProps.NATURAL_EDGE_ID_PROP_KEY, Edge.class);