当前位置: 首页>>代码示例>>Java>>正文


Java TitanManagement.updateIndex方法代码示例

本文整理汇总了Java中com.thinkaurelius.titan.core.schema.TitanManagement.updateIndex方法的典型用法代码示例。如果您正苦于以下问题:Java TitanManagement.updateIndex方法的具体用法?Java TitanManagement.updateIndex怎么用?Java TitanManagement.updateIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.thinkaurelius.titan.core.schema.TitanManagement的用法示例。


在下文中一共展示了TitanManagement.updateIndex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRemoveGraphIndex

import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
@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));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:28,代码来源:AbstractIndexManagementIT.java

示例2: testRemoveRelationIndex

import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
@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));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:30,代码来源:AbstractIndexManagementIT.java

示例3: testRepairRelationIndex

import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
@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));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:41,代码来源:AbstractIndexManagementIT.java

示例4: testRepairGraphIndex

import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
@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"));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:49,代码来源:AbstractIndexManagementIT.java

示例5: main

import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
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();
    }
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:75,代码来源:Main.java


注:本文中的com.thinkaurelius.titan.core.schema.TitanManagement.updateIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。