use of org.apache.atlas.repository.graphdb.AtlasGraphIndex in project atlas by apache.
the class GraphBackedSearchIndexer method getVertexIndexKeys.
public Set<String> getVertexIndexKeys() {
if (recomputeIndexedKeys) {
AtlasGraphManagement management = null;
try {
management = provider.get().getManagementSystem();
if (management != null) {
AtlasGraphIndex vertexIndex = management.getGraphIndex(VERTEX_INDEX);
if (vertexIndex != null) {
recomputeIndexedKeys = false;
Set<String> indexKeys = new HashSet<>();
for (AtlasPropertyKey fieldKey : vertexIndex.getFieldKeys()) {
indexKeys.add(fieldKey.getName());
}
vertexIndexKeys = indexKeys;
}
management.commit();
}
} catch (Exception excp) {
LOG.error("getVertexIndexKeys(): failed to get indexedKeys from graph", excp);
if (management != null) {
try {
management.rollback();
} catch (Exception e) {
LOG.error("getVertexIndexKeys(): rollback failed", e);
}
}
}
}
return vertexIndexKeys;
}
use of org.apache.atlas.repository.graphdb.AtlasGraphIndex in project atlas by apache.
the class GraphBackedSearchIndexer method createVertexCompositeIndex.
private void createVertexCompositeIndex(AtlasGraphManagement management, Class propertyClass, AtlasPropertyKey propertyKey, boolean enforceUniqueness) {
String propertyName = propertyKey.getName();
if (LOG.isDebugEnabled()) {
LOG.debug("Creating composite index for property {} of type {}; isUnique={} ", propertyName, propertyClass.getName(), enforceUniqueness);
}
AtlasGraphIndex existingIndex = management.getGraphIndex(propertyName);
if (existingIndex == null) {
management.createVertexCompositeIndex(propertyName, enforceUniqueness, Collections.singletonList(propertyKey));
LOG.info("Created composite index for property {} of type {}; isUnique={} ", propertyName, propertyClass.getName(), enforceUniqueness);
}
}
use of org.apache.atlas.repository.graphdb.AtlasGraphIndex in project atlas by apache.
the class GraphBackedSearchIndexer method createVertexCompositeIndexWithSystemProperty.
private void createVertexCompositeIndexWithSystemProperty(AtlasGraphManagement management, Class propertyClass, AtlasPropertyKey propertyKey, final String systemPropertyKey, AtlasCardinality cardinality) {
if (LOG.isDebugEnabled()) {
LOG.debug("Creating composite index for property {} of type {} and {}", propertyKey.getName(), propertyClass.getName(), systemPropertyKey);
}
AtlasPropertyKey typePropertyKey = management.getPropertyKey(systemPropertyKey);
if (typePropertyKey == null) {
typePropertyKey = management.makePropertyKey(systemPropertyKey, String.class, cardinality);
}
final String indexName = propertyKey.getName() + systemPropertyKey;
AtlasGraphIndex existingIndex = management.getGraphIndex(indexName);
if (existingIndex == null) {
List<AtlasPropertyKey> keys = new ArrayList<>(2);
keys.add(propertyKey);
keys.add(typePropertyKey);
management.createVertexCompositeIndex(indexName, false, keys);
LOG.info("Created composite index for property {} of type {} and {}", propertyKey.getName(), propertyClass.getName(), systemPropertyKey);
}
}
use of org.apache.atlas.repository.graphdb.AtlasGraphIndex 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();
}
}
use of org.apache.atlas.repository.graphdb.AtlasGraphIndex in project incubator-atlas by apache.
the class GraphBackedSearchIndexer method createExactMatchIndexWithSystemProperty.
private void createExactMatchIndexWithSystemProperty(AtlasGraphManagement management, Class propertyClass, AtlasPropertyKey propertyKey, final String systemPropertyKey, AtlasCardinality cardinality) {
if (LOG.isDebugEnabled()) {
LOG.debug("Creating composite index for property {} of type {} and {}", propertyKey.getName(), propertyClass.getName(), systemPropertyKey);
}
AtlasPropertyKey typePropertyKey = management.getPropertyKey(systemPropertyKey);
if (typePropertyKey == null) {
typePropertyKey = management.makePropertyKey(systemPropertyKey, String.class, cardinality);
}
final String indexName = propertyKey.getName() + systemPropertyKey;
AtlasGraphIndex existingIndex = management.getGraphIndex(indexName);
if (existingIndex == null) {
List<AtlasPropertyKey> keys = new ArrayList<>(2);
keys.add(propertyKey);
keys.add(typePropertyKey);
management.createExactMatchIndex(indexName, false, keys);
LOG.info("Created composite index for property {} of type {} and {}", propertyKey.getName(), propertyClass.getName(), systemPropertyKey);
}
}
Aggregations