Java Code Examples for com.thinkaurelius.titan.core.schema.SchemaAction

The following are top voted examples for showing how to use com.thinkaurelius.titan.core.schema.SchemaAction. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: titan1withtp3.1   File: ManagementSystem.java   View source code 6 votes vote down vote up
public Consumer<ScanMetrics> getIndexJobFinisher(final TitanGraph graph, final SchemaAction action) {
    Preconditions.checkArgument((graph != null && action != null) || (graph == null && action == null));
    return metrics -> {
        try {
            if (metrics.get(ScanMetrics.Metric.FAILURE) == 0) {
                if (action != null) {
                    ManagementSystem mgmt = (ManagementSystem) graph.openManagement();
                    try {
                        TitanIndex index = retrieve(mgmt);
                        mgmt.updateIndex(index, action);
                    } finally {
                        mgmt.commit();
                    }
                }
                LOGGER.info("Index update job successful for [{}]", IndexIdentifier.this.toString());
            } else {
                LOGGER.error("Index update job unsuccessful for [{}]. Check logs", IndexIdentifier.this.toString());
            }
        } catch (Throwable e) {
            LOGGER.error("Error encountered when updating index after job finished [" + IndexIdentifier.this.toString() + "]: ", e);
        }
    };
}
 
Example 2
Project: titan1.0.1.kafka   File: ManagementSystem.java   View source code 6 votes vote down vote up
public Consumer<ScanMetrics> getIndexJobFinisher(final TitanGraph graph, final SchemaAction action) {
    Preconditions.checkArgument((graph != null && action != null) || (graph == null && action == null));
    return metrics -> {
        try {
            if (metrics.get(ScanMetrics.Metric.FAILURE) == 0) {
                if (action != null) {
                    ManagementSystem mgmt = (ManagementSystem) graph.openManagement();
                    try {
                        TitanIndex index = retrieve(mgmt);
                        mgmt.updateIndex(index, action);
                    } finally {
                        mgmt.commit();
                    }
                }
                LOGGER.info("Index update job successful for [{}]", IndexIdentifier.this.toString());
            } else {
                LOGGER.error("Index update job unsuccessful for [{}]. Check logs", IndexIdentifier.this.toString());
            }
        } catch (Throwable e) {
            LOGGER.error("Error encountered when updating index after job finished [" + IndexIdentifier.this.toString() + "]: ", e);
        }
    };
}
 
Example 3
Project: titan1withtp3.1   File: AbstractIndexManagementIT.java   View source code 5 votes vote down vote up
@Test
public void testRemoveGraphIndex() throws InterruptedException, BackendException, ExecutionException {
    tx.commit();
    mgmt.commit();

    // Load the "Graph of the Gods" sample data
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true);

    // Disable the "name" composite index
    TitanManagement m = graph.openManagement();
    TitanGraphIndex nameIndex = m.getGraphIndex("name");
    m.updateIndex(nameIndex, SchemaAction.DISABLE_INDEX);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to DISABLED
    assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "name")
            .status(SchemaStatus.DISABLED).call().getSucceeded());

    // Remove index
    MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
    m = graph.openManagement();
    TitanGraphIndex index = m.getGraphIndex("name");
    ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REMOVE_INDEX).get();

    assertEquals(12, metrics.getCustom(IndexRemoveJob.DELETED_RECORDS_COUNT));
}
 
Example 4
Project: titan1withtp3.1   File: AbstractIndexManagementIT.java   View source code 5 votes vote down vote up
@Test
public void testRemoveRelationIndex() throws InterruptedException, BackendException, ExecutionException {
    tx.commit();
    mgmt.commit();

    // Load the "Graph of the Gods" sample data
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true);

    // Disable the "battlesByTime" index
    TitanManagement m = graph.openManagement();
    RelationType battled = m.getRelationType("battled");
    RelationTypeIndex battlesByTime = m.getRelationIndex(battled, "battlesByTime");
    m.updateIndex(battlesByTime, SchemaAction.DISABLE_INDEX);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to DISABLED
    assertTrue(ManagementSystem.awaitRelationIndexStatus(graph, "battlesByTime", "battled")
            .status(SchemaStatus.DISABLED).call().getSucceeded());

    // Remove index
    MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
    m = graph.openManagement();
    battled = m.getRelationType("battled");
    battlesByTime = m.getRelationIndex(battled, "battlesByTime");
    ScanMetrics metrics = mri.updateIndex(battlesByTime, SchemaAction.REMOVE_INDEX).get();

    assertEquals(6, metrics.getCustom(IndexRemoveJob.DELETED_RECORDS_COUNT));
}
 
Example 5
Project: titan1withtp3.1   File: AbstractIndexManagementIT.java   View source code 5 votes vote down vote up
@Test
public void testRepairRelationIndex() throws InterruptedException, BackendException, ExecutionException {
    tx.commit();
    mgmt.commit();

    // Load the "Graph of the Gods" sample data (WITHOUT mixed index coverage)
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true);

    // Create and enable a relation index on lives edges by reason
    TitanManagement m = graph.openManagement();
    PropertyKey reason = m.getPropertyKey("reason");
    EdgeLabel lives = m.getEdgeLabel("lives");
    m.buildEdgeIndex(lives, "livesByReason", Direction.BOTH, Order.decr, reason);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to REGISTERED
    assertTrue(ManagementSystem.awaitRelationIndexStatus(graph, "livesByReason", "lives")
            .status(SchemaStatus.REGISTERED).call().getSucceeded());

    m = graph.openManagement();
    RelationTypeIndex index = m.getRelationIndex(m.getRelationType("lives"), "livesByReason");
    m.updateIndex(index, SchemaAction.ENABLE_INDEX);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to ENABLED
    assertTrue(ManagementSystem.awaitRelationIndexStatus(graph, "livesByReason", "lives")
            .status(SchemaStatus.ENABLED).call().getSucceeded());

    // Run a query that hits the index but erroneously returns nothing because we haven't repaired yet
    //assertFalse(graph.query().has("reason", "no fear of death").edges().iterator().hasNext());

    // Repair
    MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
    m = graph.openManagement();
    index = m.getRelationIndex(m.getRelationType("lives"), "livesByReason");
    ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REINDEX).get();
    assertEquals(8, metrics.getCustom(IndexRepairJob.ADDED_RECORDS_COUNT));
}
 
Example 6
Project: titan1withtp3.1   File: ManagementSystem.java   View source code 5 votes vote down vote up
@Override
public void addIndexKey(final TitanGraphIndex index, final PropertyKey key, Parameter... parameters) {
    Preconditions.checkArgument(index != null && key != null && index instanceof TitanGraphIndexWrapper
            && !(key instanceof BaseKey), "Need to provide valid index and key");
    if (parameters == null) parameters = new Parameter[0];
    IndexType indexType = ((TitanGraphIndexWrapper) index).getBaseIndex();
    Preconditions.checkArgument(indexType instanceof MixedIndexType, "Can only add keys to an external index, not %s", index.name());
    Preconditions.checkArgument(indexType instanceof IndexTypeWrapper && key instanceof TitanSchemaVertex
            && ((IndexTypeWrapper) indexType).getSchemaBase() instanceof TitanSchemaVertex);

    TitanSchemaVertex indexVertex = (TitanSchemaVertex) ((IndexTypeWrapper) indexType).getSchemaBase();

    for (IndexField field : indexType.getFieldKeys())
        Preconditions.checkArgument(!field.getFieldKey().equals(key), "Key [%s] has already been added to index %s", key.name(), index.name());

    //Assemble parameters
    boolean addMappingParameter = !ParameterType.MAPPED_NAME.hasParameter(parameters);
    Parameter[] extendedParas = new Parameter[parameters.length + 1 + (addMappingParameter ? 1 : 0)];
    System.arraycopy(parameters, 0, extendedParas, 0, parameters.length);
    int arrPosition = parameters.length;
    if (addMappingParameter) extendedParas[arrPosition++] = ParameterType.MAPPED_NAME.getParameter(
            graph.getIndexSerializer().getDefaultFieldName(key, parameters, indexType.getBackingIndexName()));
    extendedParas[arrPosition++] = ParameterType.STATUS.getParameter(key.isNew() ? SchemaStatus.ENABLED : SchemaStatus.INSTALLED);

    addSchemaEdge(indexVertex, key, TypeDefinitionCategory.INDEX_FIELD, extendedParas);
    updateSchemaVertex(indexVertex);
    indexType.resetCache();
    //Check to see if the index supports this
    if (!graph.getIndexSerializer().supports((MixedIndexType) indexType, ParameterIndexField.of(key, parameters))) {
        throw new TitanException("Could not register new index field '" + key.name() + "' with index backend as the data type, cardinality or parameter combination is not supported.");
    }

    try {
        IndexSerializer.register((MixedIndexType) indexType, key, transaction.getTxHandle());
    } catch (BackendException e) {
        throw new TitanException("Could not register new index field with index backend", e);
    }
    if (!indexVertex.isNew()) updatedTypes.add(indexVertex);
    if (!key.isNew()) updateIndex(index, SchemaAction.REGISTER_INDEX);
}
 
Example 7
Project: titan1withtp3.1   File: ManagementSystem.java   View source code 5 votes vote down vote up
private TitanGraphIndex createCompositeIndex(String indexName, ElementCategory elementCategory, boolean unique, TitanSchemaType constraint, PropertyKey... keys) {
    checkIndexName(indexName);
    Preconditions.checkArgument(keys != null && keys.length > 0, "Need to provide keys to index [%s]", indexName);
    Preconditions.checkArgument(!unique || elementCategory == ElementCategory.VERTEX, "Unique indexes can only be created on vertices [%s]", indexName);
    boolean allSingleKeys = true;
    boolean oneNewKey = false;
    for (PropertyKey key : keys) {
        Preconditions.checkArgument(key != null && key instanceof PropertyKeyVertex, "Need to provide valid keys: %s", key);
        if (key.cardinality() != Cardinality.SINGLE) allSingleKeys = false;
        if (key.isNew()) oneNewKey = true;
        else updatedTypes.add((PropertyKeyVertex) key);
    }

    Cardinality indexCardinality;
    if (unique) indexCardinality = Cardinality.SINGLE;
    else indexCardinality = (allSingleKeys ? Cardinality.SET : Cardinality.LIST);

    TypeDefinitionMap def = new TypeDefinitionMap();
    def.setValue(TypeDefinitionCategory.INTERNAL_INDEX, true);
    def.setValue(TypeDefinitionCategory.ELEMENT_CATEGORY, elementCategory);
    def.setValue(TypeDefinitionCategory.BACKING_INDEX, Token.INTERNAL_INDEX_NAME);
    def.setValue(TypeDefinitionCategory.INDEXSTORE_NAME, indexName);
    def.setValue(TypeDefinitionCategory.INDEX_CARDINALITY, indexCardinality);
    def.setValue(TypeDefinitionCategory.STATUS, oneNewKey ? SchemaStatus.ENABLED : SchemaStatus.INSTALLED);
    TitanSchemaVertex indexVertex = transaction.makeSchemaVertex(TitanSchemaCategory.GRAPHINDEX, indexName, def);
    for (int i = 0; i < keys.length; i++) {
        Parameter[] paras = {ParameterType.INDEX_POSITION.getParameter(i)};
        addSchemaEdge(indexVertex, keys[i], TypeDefinitionCategory.INDEX_FIELD, paras);
    }

    Preconditions.checkArgument(constraint == null || (elementCategory.isValidConstraint(constraint) && constraint instanceof TitanSchemaVertex));
    if (constraint != null) {
        addSchemaEdge(indexVertex, (TitanSchemaVertex) constraint, TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT, null);
    }
    updateSchemaVertex(indexVertex);
    TitanGraphIndexWrapper index = new TitanGraphIndexWrapper(indexVertex.asIndexType());
    if (!oneNewKey) updateIndex(index, SchemaAction.REGISTER_INDEX);
    return index;
}
 
Example 8
Project: titan1.0.1.kafka   File: AbstractIndexManagementIT.java   View source code 5 votes vote down vote up
@Test
public void testRemoveGraphIndex() throws InterruptedException, BackendException, ExecutionException {
    tx.commit();
    mgmt.commit();

    // Load the "Graph of the Gods" sample data
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true);

    // Disable the "name" composite index
    TitanManagement m = graph.openManagement();
    TitanGraphIndex nameIndex = m.getGraphIndex("name");
    m.updateIndex(nameIndex, SchemaAction.DISABLE_INDEX);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to DISABLED
    assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "name")
            .status(SchemaStatus.DISABLED).call().getSucceeded());

    // Remove index
    MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
    m = graph.openManagement();
    TitanGraphIndex index = m.getGraphIndex("name");
    ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REMOVE_INDEX).get();

    assertEquals(12, metrics.getCustom(IndexRemoveJob.DELETED_RECORDS_COUNT));
}
 
Example 9
Project: titan1.0.1.kafka   File: AbstractIndexManagementIT.java   View source code 5 votes vote down vote up
@Test
public void testRemoveRelationIndex() throws InterruptedException, BackendException, ExecutionException {
    tx.commit();
    mgmt.commit();

    // Load the "Graph of the Gods" sample data
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true);

    // Disable the "battlesByTime" index
    TitanManagement m = graph.openManagement();
    RelationType battled = m.getRelationType("battled");
    RelationTypeIndex battlesByTime = m.getRelationIndex(battled, "battlesByTime");
    m.updateIndex(battlesByTime, SchemaAction.DISABLE_INDEX);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to DISABLED
    assertTrue(ManagementSystem.awaitRelationIndexStatus(graph, "battlesByTime", "battled")
            .status(SchemaStatus.DISABLED).call().getSucceeded());

    // Remove index
    MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
    m = graph.openManagement();
    battled = m.getRelationType("battled");
    battlesByTime = m.getRelationIndex(battled, "battlesByTime");
    ScanMetrics metrics = mri.updateIndex(battlesByTime, SchemaAction.REMOVE_INDEX).get();

    assertEquals(6, metrics.getCustom(IndexRemoveJob.DELETED_RECORDS_COUNT));
}
 
Example 10
Project: titan1.0.1.kafka   File: AbstractIndexManagementIT.java   View source code 5 votes vote down vote up
@Test
public void testRepairRelationIndex() throws InterruptedException, BackendException, ExecutionException {
    tx.commit();
    mgmt.commit();

    // Load the "Graph of the Gods" sample data (WITHOUT mixed index coverage)
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true);

    // Create and enable a relation index on lives edges by reason
    TitanManagement m = graph.openManagement();
    PropertyKey reason = m.getPropertyKey("reason");
    EdgeLabel lives = m.getEdgeLabel("lives");
    m.buildEdgeIndex(lives, "livesByReason", Direction.BOTH, Order.decr, reason);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to REGISTERED
    assertTrue(ManagementSystem.awaitRelationIndexStatus(graph, "livesByReason", "lives")
            .status(SchemaStatus.REGISTERED).call().getSucceeded());

    m = graph.openManagement();
    RelationTypeIndex index = m.getRelationIndex(m.getRelationType("lives"), "livesByReason");
    m.updateIndex(index, SchemaAction.ENABLE_INDEX);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to ENABLED
    assertTrue(ManagementSystem.awaitRelationIndexStatus(graph, "livesByReason", "lives")
            .status(SchemaStatus.ENABLED).call().getSucceeded());

    // Run a query that hits the index but erroneously returns nothing because we haven't repaired yet
    //assertFalse(graph.query().has("reason", "no fear of death").edges().iterator().hasNext());

    // Repair
    MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
    m = graph.openManagement();
    index = m.getRelationIndex(m.getRelationType("lives"), "livesByReason");
    ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REINDEX).get();
    assertEquals(8, metrics.getCustom(IndexRepairJob.ADDED_RECORDS_COUNT));
}
 
Example 11
Project: titan1.0.1.kafka   File: ManagementSystem.java   View source code 5 votes vote down vote up
@Override
public void addIndexKey(final TitanGraphIndex index, final PropertyKey key, Parameter... parameters) {
    Preconditions.checkArgument(index != null && key != null && index instanceof TitanGraphIndexWrapper
            && !(key instanceof BaseKey), "Need to provide valid index and key");
    if (parameters == null) parameters = new Parameter[0];
    IndexType indexType = ((TitanGraphIndexWrapper) index).getBaseIndex();
    Preconditions.checkArgument(indexType instanceof MixedIndexType, "Can only add keys to an external index, not %s", index.name());
    Preconditions.checkArgument(indexType instanceof IndexTypeWrapper && key instanceof TitanSchemaVertex
            && ((IndexTypeWrapper) indexType).getSchemaBase() instanceof TitanSchemaVertex);

    TitanSchemaVertex indexVertex = (TitanSchemaVertex) ((IndexTypeWrapper) indexType).getSchemaBase();

    for (IndexField field : indexType.getFieldKeys())
        Preconditions.checkArgument(!field.getFieldKey().equals(key), "Key [%s] has already been added to index %s", key.name(), index.name());

    //Assemble parameters
    boolean addMappingParameter = !ParameterType.MAPPED_NAME.hasParameter(parameters);
    Parameter[] extendedParas = new Parameter[parameters.length + 1 + (addMappingParameter ? 1 : 0)];
    System.arraycopy(parameters, 0, extendedParas, 0, parameters.length);
    int arrPosition = parameters.length;
    if (addMappingParameter) extendedParas[arrPosition++] = ParameterType.MAPPED_NAME.getParameter(
            graph.getIndexSerializer().getDefaultFieldName(key, parameters, indexType.getBackingIndexName()));
    extendedParas[arrPosition++] = ParameterType.STATUS.getParameter(key.isNew() ? SchemaStatus.ENABLED : SchemaStatus.INSTALLED);

    addSchemaEdge(indexVertex, key, TypeDefinitionCategory.INDEX_FIELD, extendedParas);
    updateSchemaVertex(indexVertex);
    indexType.resetCache();
    //Check to see if the index supports this
    if (!graph.getIndexSerializer().supports((MixedIndexType) indexType, ParameterIndexField.of(key, parameters))) {
        throw new TitanException("Could not register new index field '" + key.name() + "' with index backend as the data type, cardinality or parameter combination is not supported.");
    }

    try {
        IndexSerializer.register((MixedIndexType) indexType, key, transaction.getTxHandle());
    } catch (BackendException e) {
        throw new TitanException("Could not register new index field with index backend", e);
    }
    if (!indexVertex.isNew()) updatedTypes.add(indexVertex);
    if (!key.isNew()) updateIndex(index, SchemaAction.REGISTER_INDEX);
}
 
Example 12
Project: titan1.0.1.kafka   File: ManagementSystem.java   View source code 5 votes vote down vote up
private TitanGraphIndex createCompositeIndex(String indexName, ElementCategory elementCategory, boolean unique, TitanSchemaType constraint, PropertyKey... keys) {
    checkIndexName(indexName);
    Preconditions.checkArgument(keys != null && keys.length > 0, "Need to provide keys to index [%s]", indexName);
    Preconditions.checkArgument(!unique || elementCategory == ElementCategory.VERTEX, "Unique indexes can only be created on vertices [%s]", indexName);
    boolean allSingleKeys = true;
    boolean oneNewKey = false;
    for (PropertyKey key : keys) {
        Preconditions.checkArgument(key != null && key instanceof PropertyKeyVertex, "Need to provide valid keys: %s", key);
        if (key.cardinality() != Cardinality.SINGLE) allSingleKeys = false;
        if (key.isNew()) oneNewKey = true;
        else updatedTypes.add((PropertyKeyVertex) key);
    }

    Cardinality indexCardinality;
    if (unique) indexCardinality = Cardinality.SINGLE;
    else indexCardinality = (allSingleKeys ? Cardinality.SET : Cardinality.LIST);

    TypeDefinitionMap def = new TypeDefinitionMap();
    def.setValue(TypeDefinitionCategory.INTERNAL_INDEX, true);
    def.setValue(TypeDefinitionCategory.ELEMENT_CATEGORY, elementCategory);
    def.setValue(TypeDefinitionCategory.BACKING_INDEX, Token.INTERNAL_INDEX_NAME);
    def.setValue(TypeDefinitionCategory.INDEXSTORE_NAME, indexName);
    def.setValue(TypeDefinitionCategory.INDEX_CARDINALITY, indexCardinality);
    def.setValue(TypeDefinitionCategory.STATUS, oneNewKey ? SchemaStatus.ENABLED : SchemaStatus.INSTALLED);
    TitanSchemaVertex indexVertex = transaction.makeSchemaVertex(TitanSchemaCategory.GRAPHINDEX, indexName, def);
    for (int i = 0; i < keys.length; i++) {
        Parameter[] paras = {ParameterType.INDEX_POSITION.getParameter(i)};
        addSchemaEdge(indexVertex, keys[i], TypeDefinitionCategory.INDEX_FIELD, paras);
    }

    Preconditions.checkArgument(constraint == null || (elementCategory.isValidConstraint(constraint) && constraint instanceof TitanSchemaVertex));
    if (constraint != null) {
        addSchemaEdge(indexVertex, (TitanSchemaVertex) constraint, TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT, null);
    }
    updateSchemaVertex(indexVertex);
    TitanGraphIndexWrapper index = new TitanGraphIndexWrapper(indexVertex.asIndexType());
    if (!oneNewKey) updateIndex(index, SchemaAction.REGISTER_INDEX);
    return index;
}
 
Example 13
Project: titan0.5.4-hbase1.1.1-custom   File: ManagementSystem.java   View source code 5 votes vote down vote up
@Override
public void addIndexKey(final TitanGraphIndex index, final PropertyKey key, Parameter... parameters) {
    Preconditions.checkArgument(index!=null && key!=null && index instanceof TitanGraphIndexWrapper
            && !(key instanceof BaseKey),"Need to provide valid index and key");
    if (parameters==null) parameters=new Parameter[0];
    IndexType indexType = ((TitanGraphIndexWrapper)index).getBaseIndex();
    Preconditions.checkArgument(indexType instanceof MixedIndexType,"Can only add keys to an external index, not %s",index.getName());
    Preconditions.checkArgument(indexType instanceof IndexTypeWrapper && key instanceof TitanSchemaVertex
        && ((IndexTypeWrapper)indexType).getSchemaBase() instanceof TitanSchemaVertex);
    Preconditions.checkArgument(key.getCardinality()==Cardinality.SINGLE || indexType.getElement()!=ElementCategory.VERTEX,
            "Can only index single-valued property keys on vertices [%s]",key);
    TitanSchemaVertex indexVertex = (TitanSchemaVertex)((IndexTypeWrapper)indexType).getSchemaBase();

    for (IndexField field : indexType.getFieldKeys())
        Preconditions.checkArgument(!field.getFieldKey().equals(key),"Key [%s] has already been added to index %s",key.getName(),index.getName());

    //Assemble parameters
    boolean addMappingParameter = !ParameterType.MAPPED_NAME.hasParameter(parameters);
    Parameter[] extendedParas = new Parameter[parameters.length+1+(addMappingParameter?1:0)];
    System.arraycopy(parameters,0,extendedParas,0,parameters.length);
    int arrPosition = parameters.length;
    if (addMappingParameter) extendedParas[arrPosition++] = ParameterType.MAPPED_NAME.getParameter(
            graph.getIndexSerializer().getDefaultFieldName(key,parameters,indexType.getBackingIndexName()));
    extendedParas[arrPosition++] = ParameterType.STATUS.getParameter(key.isNew()?SchemaStatus.ENABLED:SchemaStatus.INSTALLED);

    addSchemaEdge(indexVertex, key, TypeDefinitionCategory.INDEX_FIELD, extendedParas);
    updateSchemaVertex(indexVertex);
    indexType.resetCache();
    try {
        IndexSerializer.register((MixedIndexType) indexType,key,transaction.getTxHandle());
    } catch (BackendException e) {
        throw new TitanException("Could not register new index field with index backend",e);
    }
    if (!indexVertex.isNew()) updatedTypes.add(indexVertex);
    if (!key.isNew()) updateIndex(index, SchemaAction.REGISTER_INDEX);
}
 
Example 14
Project: titan0.5.4-hbase1.1.1-custom   File: ManagementSystem.java   View source code 5 votes vote down vote up
private TitanGraphIndex createCompositeIndex(String indexName, ElementCategory elementCategory, boolean unique, TitanSchemaType constraint, PropertyKey... keys) {
    checkIndexName(indexName);
    Preconditions.checkArgument(keys!=null && keys.length>0,"Need to provide keys to index [%s]",indexName);
    Preconditions.checkArgument(!unique || elementCategory==ElementCategory.VERTEX,"Unique indexes can only be created on vertices [%s]",indexName);
    boolean allSingleKeys = true;
    boolean oneNewKey = false;
    for (PropertyKey key : keys) {
        Preconditions.checkArgument(key!=null && key instanceof PropertyKeyVertex,"Need to provide valid keys: %s",key);
        if (key.getCardinality()!=Cardinality.SINGLE) allSingleKeys=false;
        if (key.isNew()) oneNewKey = true;
        else updatedTypes.add((PropertyKeyVertex)key);
    }

    Cardinality indexCardinality;
    if (unique) indexCardinality=Cardinality.SINGLE;
    else indexCardinality=(allSingleKeys?Cardinality.SET:Cardinality.LIST);

    TypeDefinitionMap def = new TypeDefinitionMap();
    def.setValue(TypeDefinitionCategory.INTERNAL_INDEX,true);
    def.setValue(TypeDefinitionCategory.ELEMENT_CATEGORY,elementCategory);
    def.setValue(TypeDefinitionCategory.BACKING_INDEX,Token.INTERNAL_INDEX_NAME);
    def.setValue(TypeDefinitionCategory.INDEXSTORE_NAME,indexName);
    def.setValue(TypeDefinitionCategory.INDEX_CARDINALITY,indexCardinality);
    def.setValue(TypeDefinitionCategory.STATUS,oneNewKey?SchemaStatus.ENABLED:SchemaStatus.INSTALLED);
    TitanSchemaVertex indexVertex = transaction.makeSchemaVertex(TitanSchemaCategory.GRAPHINDEX,indexName,def);
    for (int i = 0; i <keys.length; i++) {
        Parameter[] paras = {ParameterType.INDEX_POSITION.getParameter(i)};
        addSchemaEdge(indexVertex,keys[i],TypeDefinitionCategory.INDEX_FIELD,paras);
    }

    Preconditions.checkArgument(constraint==null || (elementCategory.isValidConstraint(constraint) && constraint instanceof TitanSchemaVertex));
    if (constraint!=null) {
        addSchemaEdge(indexVertex,(TitanSchemaVertex)constraint,TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT,null);
    }
    updateSchemaVertex(indexVertex);
    TitanGraphIndexWrapper index = new TitanGraphIndexWrapper(indexVertex.asIndexType());
    if (!oneNewKey) updateIndex(index,SchemaAction.REGISTER_INDEX);
    return index;
}
 
Example 15
Project: titan-cassandra-elasticsearch-index   File: TitanStart.java   View source code 4 votes vote down vote up
public static void main(String[] args) throws Exception {

		Configuration conf = new PropertiesConfiguration( getRelativeResourcePath( "titan-cassandra-es.properties" ) );
		// start elastic search on startup
		Node node = new NodeBuilder().node();
		
		TitanGraph graph = TitanFactory.open(conf);
		/* Comment if you do not want to reload the graph every time */
		graph.close();
		TitanCleanup.clear(graph);
		graph = TitanFactory.open(conf);
		GraphOfTheGodsFactory.load(graph);
		/* graph loaded  */
		
		// create own indexes
		TitanManagement mgmt = graph.openManagement();
		PropertyKey name = mgmt.getPropertyKey("name");
		PropertyKey age = mgmt.getPropertyKey("age");
		mgmt.buildIndex( "byNameComposite", Vertex.class ).addKey(name).buildCompositeIndex();
		// index consisting of multiple properties
		mgmt.buildIndex( "byNameAndAgeComposite", Vertex.class ).addKey(name).addKey(age).buildCompositeIndex();
		mgmt.commit();
		
		// wait for the index to become available
		ManagementSystem.awaitGraphIndexStatus(graph, "byNameComposite").call();
		ManagementSystem.awaitGraphIndexStatus(graph, "byNameAndAgeComposite").call();
		
		// create new vertex
		Vertex me = graph.addVertex("theOneAndOnly");
		me.property( "name", "me" );
		me.property( "age", 1 );
		graph.tx().commit();
		System.out.println("Created the one and only!");
		
		// re index the existing data (not required, just for demo purposes)
		mgmt = graph.openManagement();
		mgmt.updateIndex( mgmt.getGraphIndex("byNameComposite"), SchemaAction.REINDEX ).get();
		mgmt.updateIndex( mgmt.getGraphIndex("byNameAndAgeComposite"), SchemaAction.REINDEX ).get();
		mgmt.commit();
		
		GraphTraversalSource g = graph.traversal();
		GremlinPipeline<GraphTraversal<?, ?>, ?> pipe = new GremlinPipeline();
		
		// read our new vertex
		pipe.start( g.V().has( "name", "me" ) );	
		Vertex v = (Vertex)pipe.next();
		System.out.println();
		System.out.println( "Label: " + v.label() );
		System.out.println( "Name: " + v.property("name").value() );
		System.out.println( "Age: " + v.property("age").value() );
		System.out.println();
		
		// read different vertex
		pipe.start( g.V().has( "name", "hercules" ) );	
		Vertex herclues = (Vertex)pipe.next();
		System.out.println( "Label: " + herclues.label() );
		System.out.println( "Name: " + herclues.property("name").value() );
		System.out.println( "Age: " + herclues.property("age").value() );
		
		// print some edges
		Iterator<Edge> it = herclues.edges( Direction.OUT );
		while( it.hasNext() ) {
			Edge e = it.next();
			System.out.println( "Out: " + e.label()  + " --> " + e.inVertex().property("name").value() );
		}
		System.out.println();
		
		// close graph
		graph.close();
		// close elastic search on shutdown
		node.close();
		
		System.exit(0);
	}
 
Example 16
Project: keti   File: GraphConfig.java   View source code 4 votes vote down vote up
public static void reIndex(final Graph newGraph, final String indexName)
        throws InterruptedException, ExecutionException {
    TitanManagement mgmt = ((TitanGraph) newGraph).openManagement();
    mgmt.updateIndex(mgmt.getGraphIndex(indexName), SchemaAction.REINDEX).get();
    newGraph.tx().commit();
}
 
Example 17
Project: titan1withtp3.1   File: TitanGraphTest.java   View source code 4 votes vote down vote up
@Test
public void testGotGIndexRemoval() throws InterruptedException, ExecutionException {
    clopen(option(LOG_SEND_DELAY, MANAGEMENT_LOG), Duration.ZERO,
            option(KCVSLog.LOG_READ_LAG_TIME, MANAGEMENT_LOG), Duration.ofMillis(50),
            option(LOG_READ_INTERVAL, MANAGEMENT_LOG), Duration.ofMillis(250)
    );

    final String name = "name";

    // Load Graph of the Gods
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph,
            true); // True makes the index on names unique.  Test fails when this is true.
    // Change to false and test will pass.
    newTx();
    finishSchema();

    TitanGraphIndex gindex = mgmt.getGraphIndex(name);

    // Sanity checks on the index that we assume GraphOfTheGodsFactory created
    assertNotNull(gindex);
    assertEquals(1, gindex.getFieldKeys().length);
    assertEquals(name, gindex.getFieldKeys()[0].name());
    assertEquals("internalindex", gindex.getBackingIndex());
    assertEquals(SchemaStatus.ENABLED, gindex.getIndexStatus(gindex.getFieldKeys()[0]));
    finishSchema();

    // Disable name index
    gindex = mgmt.getGraphIndex(name);
    mgmt.updateIndex(gindex, SchemaAction.DISABLE_INDEX);
    mgmt.commit();
    tx.commit();

    ManagementUtil.awaitGraphIndexUpdate(graph, name, 5, ChronoUnit.SECONDS);
    finishSchema();

    // Remove name index
    gindex = mgmt.getGraphIndex(name);
    mgmt.updateIndex(gindex, SchemaAction.REMOVE_INDEX);
    TitanManagement.IndexJobFuture gmetrics = mgmt.getIndexJobStatus(gindex);
    finishSchema();

    // Should have deleted at least one record
    assertNotEquals(0, gmetrics.get().getCustom(IndexRemoveJob.DELETED_RECORDS_COUNT));
}
 
Example 18
Project: titan1withtp3.1   File: AbstractIndexManagementIT.java   View source code 4 votes vote down vote up
@Test
public void testRepairGraphIndex() throws InterruptedException, BackendException, ExecutionException {
    tx.commit();
    mgmt.commit();

    // Load the "Graph of the Gods" sample data (WITHOUT mixed index coverage)
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true);

    // Create and enable a graph index on age
    TitanManagement m = graph.openManagement();
    PropertyKey age = m.getPropertyKey("age");
    m.buildIndex("verticesByAge", Vertex.class).addKey(age).buildCompositeIndex();
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to REGISTERED
    assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "verticesByAge")
            .status(SchemaStatus.REGISTERED).call().getSucceeded());

    m = graph.openManagement();
    TitanGraphIndex index = m.getGraphIndex("verticesByAge");
    m.updateIndex(index, SchemaAction.ENABLE_INDEX);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to ENABLED
    assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "verticesByAge")
            .status(SchemaStatus.ENABLED).call().getSucceeded());

    // Run a query that hits the index but erroneously returns nothing because we haven't repaired yet
    assertFalse(graph.query().has("age", 10000).vertices().iterator().hasNext());

    // Repair
    MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
    m = graph.openManagement();
    index = m.getGraphIndex("verticesByAge");
    ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REINDEX).get();
    assertEquals(6, metrics.getCustom(IndexRepairJob.ADDED_RECORDS_COUNT));

    // Test the index
    Iterable<TitanVertex> hits = graph.query().has("age", 4500).vertices();
    assertNotNull(hits);
    assertEquals(1, Iterables.size(hits));
    TitanVertex v = Iterables.getOnlyElement(hits);
    assertNotNull(v);

    assertEquals("neptune", v.value("name"));
}
 
Example 19
Project: titan1.0.1.kafka   File: TitanGraphTest.java   View source code 4 votes vote down vote up
@Test
public void testGotGIndexRemoval() throws InterruptedException, ExecutionException {
    clopen(option(LOG_SEND_DELAY, MANAGEMENT_LOG), Duration.ZERO,
            option(KCVSLog.LOG_READ_LAG_TIME, MANAGEMENT_LOG), Duration.ofMillis(50),
            option(LOG_READ_INTERVAL, MANAGEMENT_LOG), Duration.ofMillis(250)
    );

    final String name = "name";

    // Load Graph of the Gods
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph,
            true); // True makes the index on names unique.  Test fails when this is true.
    // Change to false and test will pass.
    newTx();
    finishSchema();

    TitanGraphIndex gindex = mgmt.getGraphIndex(name);

    // Sanity checks on the index that we assume GraphOfTheGodsFactory created
    assertNotNull(gindex);
    assertEquals(1, gindex.getFieldKeys().length);
    assertEquals(name, gindex.getFieldKeys()[0].name());
    assertEquals("internalindex", gindex.getBackingIndex());
    assertEquals(SchemaStatus.ENABLED, gindex.getIndexStatus(gindex.getFieldKeys()[0]));
    finishSchema();

    // Disable name index
    gindex = mgmt.getGraphIndex(name);
    mgmt.updateIndex(gindex, SchemaAction.DISABLE_INDEX);
    mgmt.commit();
    tx.commit();

    ManagementUtil.awaitGraphIndexUpdate(graph, name, 5, ChronoUnit.SECONDS);
    finishSchema();

    // Remove name index
    gindex = mgmt.getGraphIndex(name);
    mgmt.updateIndex(gindex, SchemaAction.REMOVE_INDEX);
    TitanManagement.IndexJobFuture gmetrics = mgmt.getIndexJobStatus(gindex);
    finishSchema();

    // Should have deleted at least one record
    assertNotEquals(0, gmetrics.get().getCustom(IndexRemoveJob.DELETED_RECORDS_COUNT));
}
 
Example 20
Project: titan1.0.1.kafka   File: AbstractIndexManagementIT.java   View source code 4 votes vote down vote up
@Test
public void testRepairGraphIndex() throws InterruptedException, BackendException, ExecutionException {
    tx.commit();
    mgmt.commit();

    // Load the "Graph of the Gods" sample data (WITHOUT mixed index coverage)
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true);

    // Create and enable a graph index on age
    TitanManagement m = graph.openManagement();
    PropertyKey age = m.getPropertyKey("age");
    m.buildIndex("verticesByAge", Vertex.class).addKey(age).buildCompositeIndex();
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to REGISTERED
    assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "verticesByAge")
            .status(SchemaStatus.REGISTERED).call().getSucceeded());

    m = graph.openManagement();
    TitanGraphIndex index = m.getGraphIndex("verticesByAge");
    m.updateIndex(index, SchemaAction.ENABLE_INDEX);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to ENABLED
    assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "verticesByAge")
            .status(SchemaStatus.ENABLED).call().getSucceeded());

    // Run a query that hits the index but erroneously returns nothing because we haven't repaired yet
    assertFalse(graph.query().has("age", 10000).vertices().iterator().hasNext());

    // Repair
    MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
    m = graph.openManagement();
    index = m.getGraphIndex("verticesByAge");
    ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REINDEX).get();
    assertEquals(6, metrics.getCustom(IndexRepairJob.ADDED_RECORDS_COUNT));

    // Test the index
    Iterable<TitanVertex> hits = graph.query().has("age", 4500).vertices();
    assertNotNull(hits);
    assertEquals(1, Iterables.size(hits));
    TitanVertex v = Iterables.getOnlyElement(hits);
    assertNotNull(v);

    assertEquals("neptune", v.value("name"));
}
 
Example 21
Project: titan0.5.4-hbase1.1.1-custom   File: TitanIndexRepairMapper.java   View source code 4 votes vote down vote up
/**
 * Check that our target index is in either the ENABLED or REGISTERED state.
 */
private void validateIndexStatus() {
    if (indexType==null || StringUtils.isBlank(indexType)) {
        index = mgmt.getGraphIndex(indexName);
    } else {
        indexRelationType = mgmt.getRelationType(indexType);
        Preconditions.checkArgument(indexRelationType!=null,"Could not find relation type: %s",indexType);
        index = mgmt.getRelationIndex(indexRelationType,indexName);
    }
    Preconditions.checkArgument(index!=null,"Could not find index: %s",indexName);
    log.info("Found index {}", indexName);
    TitanSchemaVertex schemaVertex = mgmt.getSchemaVertex(index);
    Set<SchemaStatus> acceptableStatuses = SchemaAction.REINDEX.getApplicableStatus();
    boolean isValidIndex = true;
    String invalidIndexHint;
    if (index instanceof RelationTypeIndex ||
            (index instanceof TitanGraphIndex && ((TitanGraphIndex)index).isCompositeIndex()) ) {
        SchemaStatus actualStatus = schemaVertex.getStatus();
        isValidIndex = acceptableStatuses.contains(actualStatus);
        invalidIndexHint = String.format(
                "The index has status %s, but one of %s is required",
                actualStatus, acceptableStatuses);
    } else {
        Preconditions.checkArgument(index instanceof TitanGraphIndex,"Unexpected index: %s",index);
        TitanGraphIndex gindex = (TitanGraphIndex)index;
        Preconditions.checkArgument(gindex.isMixedIndex());
        Map<String, SchemaStatus> invalidKeyStatuses = Maps.newHashMap();
        for (PropertyKey key : gindex.getFieldKeys()) {
            SchemaStatus status = gindex.getIndexStatus(key);
            if (status!=SchemaStatus.DISABLED && !acceptableStatuses.contains(status)) {
                isValidIndex=false;
                invalidKeyStatuses.put(key.getName(), status);
                log.warn("Index {} has key {} in an invalid status {}",index,key,status);
            }
        }
        invalidIndexHint = String.format(
                "The following index keys have invalid status: %s (status must be one of %s)",
                Joiner.on(",").withKeyValueSeparator(" has status ").join(invalidKeyStatuses), acceptableStatuses);
    }
    Preconditions.checkArgument(isValidIndex, "The index %s is in an invalid state and cannot be indexed. %s", indexName, invalidIndexHint);
    // TODO consider retrieving the current Job object and calling killJob() if !isValidIndex -- would be more efficient than throwing an exception on the first pair processed by each mapper
    log.debug("Index {} is valid for re-indexing");
}
 
Example 22
Project: titan0.5.4-hbase1.1.1-custom   File: ManagementSystem.java   View source code 4 votes vote down vote up
@Override
public void updateIndex(TitanIndex index, SchemaAction updateAction) {
    Preconditions.checkArgument(updateAction!=null,"Need to provide update action");
    Preconditions.checkArgument(updateAction!=SchemaAction.REMOVE_INDEX);

    TitanSchemaVertex schemaVertex = getSchemaVertex(index);
    Set<TitanSchemaVertex> dependentTypes;
    Set<PropertyKeyVertex> keySubset = ImmutableSet.of();
    if (index instanceof RelationTypeIndex) {
        dependentTypes = ImmutableSet.of((TitanSchemaVertex)((InternalRelationType)schemaVertex).getBaseType());
        Preconditions.checkArgument(updateAction.getApplicableStatus().contains(schemaVertex.getStatus()),
                "Update action [%s] does not apply for index with status [%s]",updateAction,schemaVertex.getStatus());
    } else if (index instanceof TitanGraphIndex) {
        IndexType indexType = schemaVertex.asIndexType();
        dependentTypes = Sets.newHashSet();
        if (indexType.isCompositeIndex()) {
            Preconditions.checkArgument(updateAction.getApplicableStatus().contains(schemaVertex.getStatus()),
                    "Update action [%s] does not apply for index with status [%s]",updateAction,schemaVertex.getStatus());
            for (PropertyKey key : ((TitanGraphIndex)index).getFieldKeys()) {
                dependentTypes.add((PropertyKeyVertex)key);
            }
        } else {
            keySubset = Sets.newHashSet();
            MixedIndexType cindexType = (MixedIndexType)indexType;
            Set<SchemaStatus> applicableStatus = updateAction.getApplicableStatus();
            for (ParameterIndexField field : cindexType.getFieldKeys()) {
                if (applicableStatus.contains(field.getStatus())) keySubset.add((PropertyKeyVertex)field.getFieldKey());
            }
            Preconditions.checkArgument(!keySubset.isEmpty(),"Update action [%s] does not apply to any fields for index [%s]",updateAction,index);
            dependentTypes.addAll(keySubset);
        }
    } else throw new UnsupportedOperationException("Updates not supported for index: " + index);

    switch(updateAction) {
        case REGISTER_INDEX:
            setStatus(schemaVertex,SchemaStatus.INSTALLED,keySubset);
            updatedTypes.add(schemaVertex);
            updatedTypes.addAll(dependentTypes);
            setUpdateTrigger(new UpdateStatusTrigger(graph, schemaVertex, SchemaStatus.REGISTERED, keySubset));
            break;
        case REINDEX:
            throw new UnsupportedOperationException(updateAction + " requires a manual step: run a MapReduce reindex on index name \"" + index.getName() + "\"");
        case ENABLE_INDEX:
            setStatus(schemaVertex,SchemaStatus.ENABLED,keySubset);
            updatedTypes.add(schemaVertex);
            if (!keySubset.isEmpty()) updatedTypes.addAll(dependentTypes);
            break;
        case DISABLE_INDEX:
            setStatus(schemaVertex,SchemaStatus.INSTALLED,keySubset);
            updatedTypes.add(schemaVertex);
            if (!keySubset.isEmpty()) updatedTypes.addAll(dependentTypes);
            setUpdateTrigger(new UpdateStatusTrigger(graph, schemaVertex, SchemaStatus.DISABLED, keySubset));
            break;
        case REMOVE_INDEX:
            throw new UnsupportedOperationException("Removing indexes is not yet supported");
        default: throw new UnsupportedOperationException("Update action not supported: " + updateAction);
    }
}
 
Example 23
Project: ldbc_snb_implementations   File: Main.java   View source code 4 votes vote down vote up
public static void main(String args[]) {
        //Load database
        //URL url = TitanImporter.class.getClassLoader().getResource("bdb.conf");
        URL url = TitanImporter.class.getClassLoader().getResource("bdbMWE.conf");
        if (url == null) {
            System.err.println("Missing resource bdb.conf");
            return;
        }
        String confPath = url.getPath();
        TitanGraph g = TitanFactory.open(confPath);
        TitanManagement m = g.getManagementSystem();
//        m.set("index.search.elasticsearch.client-only",false);
//        m.set("index.search.elasticsearch.local-mode",true);
//        m.commit();
//        g.commit();
//        g.shutdown();
//
//        g = TitanFactory.open(confPath);

        Logger logger = LoggerFactory.getLogger(Main.class);
        logger.debug("make id property");
        m.makePropertyKey(IdGraph.ID).dataType(Long.class).cardinality(Cardinality.SINGLE).make();
        m.commit();
        g.commit();

        logger.debug("make index");
        m = g.getManagementSystem();
        PropertyKey id = m.getPropertyKey(IdGraph.ID);
        m.buildIndex("byvid", Vertex.class).addKey(id).unique().buildCompositeIndex();
        logger.info("index status {}", m.getGraphIndex("byvid").getIndexStatus(m.getPropertyKey(IdGraph.ID)));
        m.commit();
        m = g.getManagementSystem();
        logger.info("index status {}", m.getGraphIndex("byvid").getIndexStatus(m.getPropertyKey(IdGraph.ID)));
        m.commit();
        g.commit();
        m = g.getManagementSystem();
        m.updateIndex(m.getGraphIndex("byvid"), SchemaAction.REGISTER_INDEX);
        logger.info("set register trigger");
        m.commit();
        g.commit();
        m = g.getManagementSystem();
        logger.info("index status {}", m.getGraphIndex("byvid").getIndexStatus(m.getPropertyKey(IdGraph.ID)));
        m.commit();

        m = g.getManagementSystem();
        logger.info("index status {}", m.getGraphIndex("byvid").getIndexStatus(m.getPropertyKey(IdGraph.ID)));
        m.updateIndex(m.getGraphIndex("byvid"), SchemaAction.ENABLE_INDEX);
        m.commit();
        m = g.getManagementSystem();
        logger.info("index status {}", m.getGraphIndex("byvid").getIndexStatus(m.getPropertyKey(IdGraph.ID)));
        m.commit();
        Vertex p = g.addVertexWithLabel("person");
        p.setProperty(IdGraph.ID, 11);
        Iterable<Vertex> vL = g.query().has(IdGraph.ID, 11).vertices();
        for (Vertex v : vL)
            logger.info("found: {}", v.toString());
//        TitanImporter ti = new TitanImporter();
//        try {
//            ti.init(confPath, WorkloadEnum.INTERACTIVE);
//        } catch (DBgenImporter.ConnectionException e) {
//            e.printStackTrace();
//        }
//        File dir = new File(System.getProperty("validationFolderName"));
//        if (!dir.exists())
//            System.err.println("Validation data folder not found ");
//        try {
//            ti.importData(dir);
//        } catch (IOException e) {
//            e.printStackTrace();
//        } catch (SchemaViolationException e) {
//            e.printStackTrace();
//        }
//        ti.shutdown();
    }