Search in sources :

Example 16 with AtlasGraphManagement

use of org.apache.atlas.repository.graphdb.AtlasGraphManagement in project 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.createVertexCompositeIndex(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)

Example 17 with AtlasGraphManagement

use of org.apache.atlas.repository.graphdb.AtlasGraphManagement 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)

Example 18 with AtlasGraphManagement

use of org.apache.atlas.repository.graphdb.AtlasGraphManagement 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 19 with AtlasGraphManagement

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

the class AbstractGraphDatabaseTest method createIndices.

@BeforeClass
public static void createIndices() {
    GraphSandboxUtil.create();
    Titan1GraphDatabase db = new Titan1GraphDatabase();
    AtlasGraphManagement mgmt = db.getGraph().getManagementSystem();
    if (mgmt.getGraphIndex(BACKING_INDEX_NAME) == null) {
        mgmt.createVertexIndex(BACKING_INDEX_NAME, Constants.BACKING_INDEX, Collections.<AtlasPropertyKey>emptyList());
    }
    mgmt.makePropertyKey("age13", Integer.class, AtlasCardinality.SINGLE);
    createIndices(mgmt, "name", String.class, false, AtlasCardinality.SINGLE);
    createIndices(mgmt, WEIGHT_PROPERTY, Integer.class, false, AtlasCardinality.SINGLE);
    createIndices(mgmt, "size15", String.class, false, AtlasCardinality.SINGLE);
    createIndices(mgmt, "typeName", String.class, false, AtlasCardinality.SINGLE);
    createIndices(mgmt, "__type", String.class, false, AtlasCardinality.SINGLE);
    createIndices(mgmt, Constants.GUID_PROPERTY_KEY, String.class, true, AtlasCardinality.SINGLE);
    createIndices(mgmt, Constants.TRAIT_NAMES_PROPERTY_KEY, String.class, false, AtlasCardinality.SET);
    createIndices(mgmt, Constants.SUPER_TYPES_PROPERTY_KEY, String.class, false, AtlasCardinality.SET);
    mgmt.commit();
}
Also used : AtlasGraphManagement(org.apache.atlas.repository.graphdb.AtlasGraphManagement) BeforeClass(org.testng.annotations.BeforeClass)

Example 20 with AtlasGraphManagement

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

the class AbstractGraphDatabaseTest method createIndices.

@BeforeClass
public static void createIndices() {
    GraphSandboxUtil.create();
    Titan0GraphDatabase db = new Titan0GraphDatabase();
    AtlasGraphManagement mgmt = db.getGraph().getManagementSystem();
    if (mgmt.getGraphIndex(BACKING_INDEX_NAME) == null) {
        mgmt.createVertexIndex(BACKING_INDEX_NAME, Constants.BACKING_INDEX, Collections.<AtlasPropertyKey>emptyList());
    }
    mgmt.makePropertyKey("age13", Integer.class, AtlasCardinality.SINGLE);
    createIndices(mgmt, "name", String.class, false, AtlasCardinality.SINGLE);
    createIndices(mgmt, WEIGHT_PROPERTY, Integer.class, false, AtlasCardinality.SINGLE);
    createIndices(mgmt, "size15", String.class, false, AtlasCardinality.SINGLE);
    createIndices(mgmt, "typeName", String.class, false, AtlasCardinality.SINGLE);
    createIndices(mgmt, "__type", String.class, false, AtlasCardinality.SINGLE);
    createIndices(mgmt, Constants.GUID_PROPERTY_KEY, String.class, true, AtlasCardinality.SINGLE);
    createIndices(mgmt, Constants.TRAIT_NAMES_PROPERTY_KEY, String.class, false, AtlasCardinality.SET);
    createIndices(mgmt, Constants.SUPER_TYPES_PROPERTY_KEY, String.class, false, AtlasCardinality.SET);
    mgmt.commit();
}
Also used : AtlasGraphManagement(org.apache.atlas.repository.graphdb.AtlasGraphManagement) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

AtlasGraphManagement (org.apache.atlas.repository.graphdb.AtlasGraphManagement)20 AtlasGraph (org.apache.atlas.repository.graphdb.AtlasGraph)9 RepositoryException (org.apache.atlas.repository.RepositoryException)6 AtlasPropertyKey (org.apache.atlas.repository.graphdb.AtlasPropertyKey)6 Test (org.testng.annotations.Test)5 AtlasGraphIndex (org.apache.atlas.repository.graphdb.AtlasGraphIndex)4 BeforeClass (org.testng.annotations.BeforeClass)4 IndexException (org.apache.atlas.repository.IndexException)3 HashSet (java.util.HashSet)2 AtlasBaseTypeDef (org.apache.atlas.model.typedef.AtlasBaseTypeDef)2 AtlasException (org.apache.atlas.AtlasException)1 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)1 IndexCreationException (org.apache.atlas.repository.IndexCreationException)1 ClassType (org.apache.atlas.typesystem.types.ClassType)1 EnumType (org.apache.atlas.typesystem.types.EnumType)1 EnumValue (org.apache.atlas.typesystem.types.EnumValue)1 IDataType (org.apache.atlas.typesystem.types.IDataType)1 TypeSystem (org.apache.atlas.typesystem.types.TypeSystem)1