Search in sources :

Example 16 with AtlasGraph

use of org.apache.atlas.repository.graphdb.AtlasGraph in project incubator-atlas by apache.

the class AtlasDeleteHandlerV1Test method getVertices.

protected List<AtlasVertex> getVertices(String propertyName, Object value) {
    AtlasGraph graph = TestUtils.getGraph();
    Iterable<AtlasVertex> vertices = graph.getVertices(propertyName, value);
    List<AtlasVertex> list = new ArrayList<>();
    for (AtlasVertex vertex : vertices) {
        list.add(vertex);
    }
    return list;
}
Also used : AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) ArrayList(java.util.ArrayList) AtlasGraph(org.apache.atlas.repository.graphdb.AtlasGraph)

Example 17 with AtlasGraph

use of org.apache.atlas.repository.graphdb.AtlasGraph in project incubator-atlas by apache.

the class GraphRepoMapperScaleTest method searchWithIndex.

private void searchWithIndex(String key, String value) {
    AtlasGraph graph = TestUtils.getGraph();
    long start = System.currentTimeMillis();
    int count = 0;
    try {
        String queryString = "v.\"" + key + "\":(" + value + ")";
        AtlasIndexQuery query = graph.indexQuery(Constants.VERTEX_INDEX, queryString);
        Iterator<AtlasIndexQuery.Result> result = query.vertices();
        while (result.hasNext()) {
            result.next();
            count++;
        }
    } finally {
        System.out.println("Search on [" + key + "=" + value + "] returned results: " + count + ", took " + (System.currentTimeMillis() - start) + " ms");
    }
}
Also used : AtlasIndexQuery(org.apache.atlas.repository.graphdb.AtlasIndexQuery) AtlasGraph(org.apache.atlas.repository.graphdb.AtlasGraph) CreateUpdateEntitiesResult(org.apache.atlas.CreateUpdateEntitiesResult)

Example 18 with AtlasGraph

use of org.apache.atlas.repository.graphdb.AtlasGraph in project incubator-atlas by apache.

the class GraphBackedMetadataRepositoryTest method getTableEntityVertex.

@GraphTransaction
AtlasVertex getTableEntityVertex() {
    AtlasGraph graph = TestUtils.getGraph();
    AtlasGraphQuery query = graph.query().has(Constants.ENTITY_TYPE_PROPERTY_KEY, ComparisionOperator.EQUAL, TestUtils.TABLE_TYPE);
    Iterator<AtlasVertex> results = query.vertices().iterator();
    // returning one since guid should be unique
    AtlasVertex tableVertex = results.hasNext() ? results.next() : null;
    if (tableVertex == null) {
        Assert.fail();
    }
    return tableVertex;
}
Also used : AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasGraphQuery(org.apache.atlas.repository.graphdb.AtlasGraphQuery) AtlasGraph(org.apache.atlas.repository.graphdb.AtlasGraph) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Example 19 with AtlasGraph

use of org.apache.atlas.repository.graphdb.AtlasGraph in project incubator-atlas by apache.

the class GraphBackedSearchIndexerTest method verifySystemCompositeIndexes.

@Test
public void verifySystemCompositeIndexes() {
    AtlasGraph graph = TestUtils.getGraph();
    AtlasGraphManagement managementSystem = graph.getManagementSystem();
    try {
        verifySystemCompositeIndex(managementSystem, Constants.GUID_PROPERTY_KEY, true);
        verifyVertexIndexContains(managementSystem, Constants.GUID_PROPERTY_KEY);
        verifySystemCompositeIndex(managementSystem, Constants.ENTITY_TYPE_PROPERTY_KEY, false);
        verifyVertexIndexContains(managementSystem, Constants.ENTITY_TYPE_PROPERTY_KEY);
        verifySystemCompositeIndex(managementSystem, Constants.SUPER_TYPES_PROPERTY_KEY, false);
        verifyVertexIndexContains(managementSystem, Constants.SUPER_TYPES_PROPERTY_KEY);
        verifySystemCompositeIndex(managementSystem, Constants.TRAIT_NAMES_PROPERTY_KEY, false);
        verifyVertexIndexContains(managementSystem, Constants.TRAIT_NAMES_PROPERTY_KEY);
    } finally {
        managementSystem.rollback();
    }
}
Also used : AtlasGraphManagement(org.apache.atlas.repository.graphdb.AtlasGraphManagement) AtlasGraph(org.apache.atlas.repository.graphdb.AtlasGraph) Test(org.testng.annotations.Test)

Example 20 with AtlasGraph

use of org.apache.atlas.repository.graphdb.AtlasGraph in project incubator-atlas by apache.

the class GraphBackedSearchIndexerTest method verifyFullTextIndex.

@Test
public void verifyFullTextIndex() {
    AtlasGraph graph = TestUtils.getGraph();
    AtlasGraphManagement managementSystem = graph.getManagementSystem();
    try {
        AtlasGraphIndex fullTextIndex = managementSystem.getGraphIndex(Constants.FULLTEXT_INDEX);
        assertTrue(fullTextIndex.isMixedIndex());
        Arrays.asList(fullTextIndex.getFieldKeys()).contains(managementSystem.getPropertyKey(Constants.ENTITY_TEXT_PROPERTY_KEY));
    } finally {
        managementSystem.rollback();
    }
}
Also used : AtlasGraphManagement(org.apache.atlas.repository.graphdb.AtlasGraphManagement) AtlasGraphIndex(org.apache.atlas.repository.graphdb.AtlasGraphIndex) AtlasGraph(org.apache.atlas.repository.graphdb.AtlasGraph) Test(org.testng.annotations.Test)

Aggregations

AtlasGraph (org.apache.atlas.repository.graphdb.AtlasGraph)20 Test (org.testng.annotations.Test)9 AtlasGraphManagement (org.apache.atlas.repository.graphdb.AtlasGraphManagement)7 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)7 GremlinPipeline (com.tinkerpop.gremlin.java.GremlinPipeline)3 Pipe (com.tinkerpop.pipes.Pipe)3 Request (org.apache.atlas.catalog.Request)3 ResourceDefinition (org.apache.atlas.catalog.definition.ResourceDefinition)3 AtlasGraphQuery (org.apache.atlas.repository.graphdb.AtlasGraphQuery)3 Vertex (com.tinkerpop.blueprints.Vertex)2 ArrayList (java.util.ArrayList)2 VertexWrapper (org.apache.atlas.catalog.VertexWrapper)2 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)2 AtlasGraphIndex (org.apache.atlas.repository.graphdb.AtlasGraphIndex)2 AtlasPropertyKey (org.apache.atlas.repository.graphdb.AtlasPropertyKey)2 IDataType (org.apache.atlas.typesystem.types.IDataType)2 CreateUpdateEntitiesResult (org.apache.atlas.CreateUpdateEntitiesResult)1 GraphTransaction (org.apache.atlas.annotation.GraphTransaction)1 ClosureExpression (org.apache.atlas.groovy.ClosureExpression)1 FunctionCallExpression (org.apache.atlas.groovy.FunctionCallExpression)1