com.tinkerpop.blueprints.IndexableGraph Java Examples

The following examples show how to use com.tinkerpop.blueprints.IndexableGraph. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IdGraph.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
public <T extends Element> Index<T> createIndex(final String indexName,
                                                final Class<T> indexClass,
                                                final Parameter... indexParameters) {
    verifyBaseGraphIsIndexableGraph();

    return isVertexClass(indexClass)
            ? (Index<T>) new IdVertexIndex((Index<Vertex>) ((IndexableGraph) baseGraph).createIndex(indexName, indexClass, indexParameters), this)
            : (Index<T>) new IdEdgeIndex((Index<Edge>) ((IndexableGraph) baseGraph).createIndex(indexName, indexClass, indexParameters), this);
}
 
Example #2
Source File: ReadOnlyKeyIndexableGraph.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
public ReadOnlyKeyIndexableGraph(final T baseKIGraph) {
    super((IndexableGraph) baseKIGraph);
}
 
Example #3
Source File: IdGraph.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
public void dropIndex(final String indexName) {
    verifyBaseGraphIsIndexableGraph();

    ((IndexableGraph) baseGraph).dropIndex(indexName);
}
 
Example #4
Source File: IdGraph.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
private void verifyBaseGraphIsIndexableGraph() {
    if (!(baseGraph instanceof IndexableGraph)) {
        throw new IllegalStateException("base graph is not an indexable graph");
    }
}
 
Example #5
Source File: IndexableGraphHelper.java    From org.openntf.domino with Apache License 2.0 3 votes vote down vote up
/**
 * Add a vertex to a graph only if no other vertex in the provided Index is indexed by the property key/value pair.
 * If a vertex already exists with that key/value pair, return the pre-existing vertex.
 *
 * @param graph       the graph to add the vertex to
 * @param id          the id of the vertex to create (can be null)
 * @param index       the index to determine if another vertex with the same key/value exists
 * @param uniqueKey   the key to check on for uniqueness of the vertex
 * @param uniqueValue the value to check on for uniqueness of the vertex
 * @return the newly created vertex or the vertex that satisfies the uniqueness criteria
 */
public static Vertex addUniqueVertex(final IndexableGraph graph, final Object id, final Index<Vertex> index, final String uniqueKey, final Object uniqueValue) {
    final Iterator<Vertex> results = index.get(uniqueKey, uniqueValue).iterator();
    if (results.hasNext()) {
        return results.next();
    } else {
        final Vertex vertex = graph.addVertex(id);
        vertex.setProperty(uniqueKey, uniqueValue);
        return vertex;
    }
}