Search in sources :

Example 1 with AtlasGraph

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

the class GraphHelperTest method testGetOutgoingEdgesByLabel.

@Test
public void testGetOutgoingEdgesByLabel() throws Exception {
    AtlasGraph graph = TestUtils.getGraph();
    AtlasVertex v1 = graph.addVertex();
    AtlasVertex v2 = graph.addVertex();
    graph.addEdge(v1, v2, "l1");
    graph.addEdge(v1, v2, "l2");
    Iterator<AtlasEdge> iterator = GraphHelper.getInstance().getOutGoingEdgesByLabel(v1, "l1");
    assertTrue(iterator.hasNext());
    assertTrue(iterator.hasNext());
    assertNotNull(iterator.next());
    assertNull(iterator.next());
    assertFalse(iterator.hasNext());
    assertFalse(iterator.hasNext());
}
Also used : AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasGraph(org.apache.atlas.repository.graphdb.AtlasGraph) AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge) Test(org.testng.annotations.Test)

Example 2 with AtlasGraph

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

the class GraphBackedSearchIndexerTest method verifyUserDefinedTypeIndex.

@Test
public void verifyUserDefinedTypeIndex() throws AtlasException {
    AtlasGraph graph = TestUtils.getGraph();
    AtlasGraphManagement managementSystem = graph.getManagementSystem();
    try {
        TypeSystem typeSystem = TypeSystem.getInstance();
        String enumName = "randomEnum" + RandomStringUtils.randomAlphanumeric(10);
        EnumType managedType = typeSystem.defineEnumType(enumName, new EnumValue("randomEnumValue", 0));
        HierarchicalTypeDefinition<ClassType> databaseTypeDefinition = createClassTypeDef("Database", "Database type description", null, TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef("managedType", managedType));
        ClassType databaseType = typeSystem.defineClassType(databaseTypeDefinition);
        graphBackedSearchIndexer.onAdd(Arrays.asList(databaseType));
        verifySystemCompositeIndex(managementSystem, "Database.name" + Constants.ENTITY_TYPE_PROPERTY_KEY, false);
        verifyVertexIndexContains(managementSystem, "Database.name" + Constants.ENTITY_TYPE_PROPERTY_KEY);
        verifySystemCompositeIndex(managementSystem, "Database.name" + Constants.SUPER_TYPES_PROPERTY_KEY, false);
        verifyVertexIndexContains(managementSystem, "Database.managedType");
    } finally {
        //search indexer uses its own titan management transaction
        managementSystem.rollback();
    }
}
Also used : AtlasGraphManagement(org.apache.atlas.repository.graphdb.AtlasGraphManagement) TypeSystem(org.apache.atlas.typesystem.types.TypeSystem) EnumType(org.apache.atlas.typesystem.types.EnumType) EnumValue(org.apache.atlas.typesystem.types.EnumValue) ClassType(org.apache.atlas.typesystem.types.ClassType) AtlasGraph(org.apache.atlas.repository.graphdb.AtlasGraph) Test(org.testng.annotations.Test)

Example 3 with AtlasGraph

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

the class GraphBackedSearchIndexerTest method verifySystemMixedIndexes.

@Test
public void verifySystemMixedIndexes() {
    AtlasGraph graph = TestUtils.getGraph();
    AtlasGraphManagement managementSystem = graph.getManagementSystem();
    try {
        AtlasGraphIndex vertexIndex = managementSystem.getGraphIndex(Constants.VERTEX_INDEX);
        assertNotNull(vertexIndex);
        assertTrue(vertexIndex.isMixedIndex());
        assertFalse(vertexIndex.isEdgeIndex());
        assertTrue(vertexIndex.isVertexIndex());
        AtlasGraphIndex edgeIndex = managementSystem.getGraphIndex(Constants.EDGE_INDEX);
        assertNotNull(edgeIndex);
        assertTrue(edgeIndex.isMixedIndex());
        assertTrue(edgeIndex.isEdgeIndex());
        assertFalse(edgeIndex.isVertexIndex());
        verifyVertexIndexContains(managementSystem, Constants.STATE_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)

Example 4 with AtlasGraph

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

the class GraphBackedSearchIndexerTest method verifyTypeStoreIndexes.

@Test
public void verifyTypeStoreIndexes() {
    AtlasGraph graph = TestUtils.getGraph();
    AtlasGraphManagement managementSystem = graph.getManagementSystem();
    try {
        verifySystemCompositeIndex(managementSystem, Constants.TYPENAME_PROPERTY_KEY, true);
        verifyVertexIndexContains(managementSystem, Constants.TYPENAME_PROPERTY_KEY);
        verifySystemCompositeIndex(managementSystem, Constants.VERTEX_TYPE_PROPERTY_KEY, false);
        verifyVertexIndexContains(managementSystem, Constants.VERTEX_TYPE_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 5 with AtlasGraph

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

the class Titan0DatabaseTest method getGraph.

private <V, E> AtlasGraph<V, E> getGraph() {
    GraphSandboxUtil.create();
    if (atlasGraph == null) {
        Titan0GraphDatabase db = new Titan0GraphDatabase();
        atlasGraph = db.getGraph();
        AtlasGraphManagement mgmt = atlasGraph.getManagementSystem();
        // many)
        for (String propertyName : new String[] { "__superTypeNames", "__traitNames" }) {
            AtlasPropertyKey propertyKey = mgmt.getPropertyKey(propertyName);
            if (propertyKey == null) {
                propertyKey = mgmt.makePropertyKey(propertyName, String.class, AtlasCardinality.SET);
                mgmt.createExactMatchIndex(propertyName, false, Collections.singletonList(propertyKey));
            }
        }
        mgmt.commit();
    }
    return (AtlasGraph<V, E>) atlasGraph;
}
Also used : AtlasGraphManagement(org.apache.atlas.repository.graphdb.AtlasGraphManagement) AtlasPropertyKey(org.apache.atlas.repository.graphdb.AtlasPropertyKey) AtlasGraph(org.apache.atlas.repository.graphdb.AtlasGraph)

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