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


Java TitanGraph类代码示例

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


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

示例1: createUniqueCompositeIndex

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
public static void createUniqueCompositeIndex(final Graph newGraph, final String indexName,
        final String[] propertyKeyNames, final Class<?> propertyKeyType) throws InterruptedException {

    Assert.notEmpty(propertyKeyNames);
    newGraph.tx().rollback(); // Never create new indexes while a transaction is active
    TitanManagement mgmt = ((TitanGraph) newGraph).openManagement();
    IndexBuilder indexBuilder = mgmt.buildIndex(indexName, Vertex.class);
    if (!mgmt.containsGraphIndex(indexName)) {
        for (String propertyKeyName : propertyKeyNames) {
            PropertyKey indexPropertyKey = getOrCreatePropertyKey(propertyKeyName, propertyKeyType, mgmt);
            indexBuilder.addKey(indexPropertyKey);
        }
        indexBuilder.unique().buildCompositeIndex();
    }
    mgmt.commit();
    // Wait for the index to become available
    ManagementSystem.awaitGraphIndexStatus((TitanGraph) newGraph, indexName).status(SchemaStatus.ENABLED).call();
}
 
开发者ID:eclipse,项目名称:keti,代码行数:19,代码来源:GraphConfig.java

示例2: loadRelationTypes

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
/**
 * Given a path for Titan config file, connects and gets the internal Titan types,
 * converting them to MizoTitanRelationTypes mapped by type-ids
 * @param titanConfigPath Path to Titan's config path
 * @return Mapping between relation type-ids to InternalRelationType instances
 */
protected static HashMap<Long, MizoTitanRelationType> loadRelationTypes(String titanConfigPath) {
    TitanGraph g = TitanFactory.open(titanConfigPath);
    StandardTitanTx tx = (StandardTitanTx)g.buildTransaction().readOnly().start();

    HashMap<Long, MizoTitanRelationType> relations = Maps.newHashMap();

    tx.query()
            .has(BaseKey.SchemaCategory, Contain.IN, Lists.newArrayList(TitanSchemaCategory.values()))
            .vertices()
            .forEach(v -> {
                if (v instanceof InternalRelationType)
                    relations.put(v.longId(), new MizoTitanRelationType((InternalRelationType)v));
            });

    tx.close();

    try {
        ((StandardTitanGraph)g).getBackend().close();
    } catch (BackendException e) {
        e.printStackTrace();
    }

    return relations;
}
 
开发者ID:imri,项目名称:mizo,代码行数:31,代码来源:MizoRDD.java

示例3: clear

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
@Override
public void clear(Graph g, final Configuration configuration) throws Exception {
    if (null != g) {
        while (g instanceof WrappedGraph) g = ((WrappedGraph<? extends Graph>) g).getBaseGraph();
        TitanGraph graph = (TitanGraph) g;
        if (graph.isOpen()) {
            if (g.tx().isOpen()) g.tx().rollback();
            g.close();
        }
    }

    WriteConfiguration config = new CommonsConfiguration(configuration);
    BasicConfiguration readConfig = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE);
    if (readConfig.has(GraphDatabaseConfiguration.STORAGE_BACKEND)) {
        TitanGraphBaseTest.clearGraph(config);
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:18,代码来源:AbstractTitanGraphProvider.java

示例4: loadGraphData

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
@Override
public void loadGraphData(final Graph g, final LoadGraphWith loadGraphWith, final Class testClass, final String testName) {
    if (loadGraphWith != null) {
        this.createIndices((TitanGraph) g, loadGraphWith.value());
    } else {
        if (TransactionTest.class.equals(testClass) && testName.equalsIgnoreCase("shouldExecuteWithCompetingThreads")) {
            TitanManagement mgmt = ((TitanGraph) g).openManagement();
            mgmt.makePropertyKey("blah").dataType(Double.class).make();
            mgmt.makePropertyKey("bloop").dataType(Integer.class).make();
            mgmt.makePropertyKey("test").dataType(Object.class).make();
            mgmt.makeEdgeLabel("friend").make();
            mgmt.commit();
        }
    }
    super.loadGraphData(g, loadGraphWith, testClass, testName);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:17,代码来源:AbstractTitanGraphProvider.java

示例5: SchemaContainer

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
public SchemaContainer(TitanGraph graph) {
    vertexLabels = Maps.newHashMap();
    relationTypes = Maps.newHashMap();
    TitanManagement mgmt = graph.getManagementSystem();

    try {
        for (VertexLabel vl : mgmt.getVertexLabels()) {
            VertexLabelDefinition vld = new VertexLabelDefinition(vl);
            vertexLabels.put(vld.getName(),vld);
        }

        for (EdgeLabel el : mgmt.getRelationTypes(EdgeLabel.class)) {
            EdgeLabelDefinition eld = new EdgeLabelDefinition(el);
            relationTypes.put(eld.getName(),eld);
        }
        for (PropertyKey pk : mgmt.getRelationTypes(PropertyKey.class)) {
            PropertyKeyDefinition pkd = new PropertyKeyDefinition(pk);
            relationTypes.put(pkd.getName(), pkd);
        }
    } finally {
        mgmt.rollback();
    }

}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:25,代码来源:SchemaContainer.java

示例6: testTitanFactoryBuilder

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
@Test
public void testTitanFactoryBuilder()
{
    String baseDir = Joiner.on(File.separator).join("target", "es", "titanfactory_jvmlocal_ext");
    TitanFactory.Builder builder = TitanFactory.build();
    builder.set("storage.backend", "inmemory");
    builder.set("index." + INDEX_NAME + ".elasticsearch.interface", "NODE");
    builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.data", "true");
    builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.client", "false");
    builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.local", "true");
    builder.set("index." + INDEX_NAME + ".elasticsearch.ext.path.data", baseDir + File.separator + "data");
    builder.set("index." + INDEX_NAME + ".elasticsearch.ext.path.work", baseDir + File.separator + "work");
    builder.set("index." + INDEX_NAME + ".elasticsearch.ext.path.logs", baseDir + File.separator + "logs");
    TitanGraph graph = builder.open(); // Must not throw an exception
    assertTrue(graph.isOpen());
    graph.close();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:18,代码来源:ElasticSearchConfigTest.java

示例7: getIndexJobFinisher

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

示例8: testCanReadListValuedProperty

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
@Test
public void testCanReadListValuedProperty() throws Exception {
    TitanGraph tg = TitanFactory.open(getTitanConfiguration());

    TitanManagement mgmt = tg.getManagementSystem();
    mgmt.makePropertyKey("email").dataType(String.class).cardinality(com.thinkaurelius.titan.core.Cardinality.LIST).make();
    mgmt.commit();
    tg.commit();

    TitanVertex v = tg.addVertex();
    v.addProperty("email", "one");
    v.addProperty("email", "two");
    tg.commit();

    Configuration c = new Configuration();
    c.set("titan.hadoop.input.format", "com.thinkaurelius.titan.hadoop.formats.cassandra.TitanCassandraInputFormat");
    c.set("titan.hadoop.input.conf.storage.backend", "cassandrathrift");
    c.set("titan.hadoop.input.conf.storage.cassandra.keyspace", KEYSPACE_NAME);
    c.set("titan.hadoop.sideeffect.format", "org.apache.hadoop.mapreduce.lib.output.TextOutputFormat");
    c.set("titan.hadoop.output.format", "com.thinkaurelius.titan.hadoop.formats.graphson.GraphSONOutputFormat");
    c.set("cassandra.input.partitioner.class", "org.apache.cassandra.dht.Murmur3Partitioner");

    HadoopGraph hg = new HadoopGraph(c);

    assertEquals(0, new HadoopPipeline(hg).V().map().submit());
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:27,代码来源:TitanCassandraInputFormatTest.java

示例9: SchemaContainer

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
public SchemaContainer(TitanGraph graph) {
    vertexLabels = Maps.newHashMap();
    relationTypes = Maps.newHashMap();
    TitanManagement mgmt = graph.openManagement();

    try {
        for (VertexLabel vl : mgmt.getVertexLabels()) {
            VertexLabelDefinition vld = new VertexLabelDefinition(vl);
            vertexLabels.put(vld.getName(),vld);
        }

        for (EdgeLabel el : mgmt.getRelationTypes(EdgeLabel.class)) {
            EdgeLabelDefinition eld = new EdgeLabelDefinition(el);
            relationTypes.put(eld.getName(),eld);
        }
        for (PropertyKey pk : mgmt.getRelationTypes(PropertyKey.class)) {
            PropertyKeyDefinition pkd = new PropertyKeyDefinition(pk);
            relationTypes.put(pkd.getName(), pkd);
        }
    } finally {
        mgmt.rollback();
    }

}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:25,代码来源:SchemaContainer.java

示例10: clear

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
/**
 * Clears out the entire graph. This will delete ALL of the data stored in this graph and the data will NOT be
 * recoverable. This method is intended only for development and testing use.
 *
 * @param graph
 * @throws IllegalArgumentException if the graph has not been shut down
 * @throws com.thinkaurelius.titan.core.TitanException if clearing the storage is unsuccessful
 */
public static final void clear(TitanGraph graph) {
    Preconditions.checkNotNull(graph);
    Preconditions.checkArgument(graph instanceof StandardTitanGraph,"Invalid graph instance detected: %s",graph.getClass());
    StandardTitanGraph g = (StandardTitanGraph)graph;
    Preconditions.checkArgument(!g.isOpen(),"Graph needs to be shut down before it can be cleared.");
    final GraphDatabaseConfiguration config = g.getConfiguration();
    BackendOperation.execute(new Callable<Boolean>(){
        @Override
        public Boolean call() throws Exception {
            config.getBackend().clearStorage();
            return true;
        }
        @Override
        public String toString() { return "ClearBackend"; }
    }, Duration.ofSeconds(20));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:25,代码来源:TitanCleanup.java

示例11: setup

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
@Override
protected void setup(Context context) throws IOException, InterruptedException {
    super.setup(context);

    // Catch any exceptions, log a warning, and allow the subclass to continue even if schema loading failed
    try {
        ModifiableHadoopConfiguration faunusConf =
                ModifiableHadoopConfiguration.of(DEFAULT_COMPAT.getContextConfiguration(context));

        if (faunusConf.get(TitanHadoopConfiguration.OUTPUT_TITAN_TYPE_CHECKING)) {
            TitanGraph g = TitanFactory.open(faunusConf.getOutputConf());
            FaunusSchemaManager.getTypeManager(null).setSchemaProvider(new SchemaContainer(g));
            log.info("Loaded schema associated with {}", g);
        } else {
            log.debug("Titan schema checking is disabled");
        }
    } catch (Throwable t) {
        log.warn("Unable to load Titan schema", t);
    }
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:21,代码来源:TitanSchemaAwareMapper.java

示例12: main

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
public static void main(String[] args) {
    String dataDir = "./data";
    TitanGraph graph = TitanFactory.open("berkeleyje:" + dataDir);

    // see org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory.generateClassic()
    final Vertex marko = graph.addVertex("name", "marko", "age", 29);
    final Vertex vadas = graph.addVertex("name", "vadas", "age", 27);
    final Vertex lop = graph.addVertex("name", "lop", "lang", "java");
    final Vertex josh = graph.addVertex("name", "josh", "age", 32);
    final Vertex ripple = graph.addVertex("name", "ripple", "lang", "java");
    final Vertex peter = graph.addVertex("name", "peter", "age", 35);
    marko.addEdge("knows", vadas, "weight", 0.5f);
    marko.addEdge("knows", josh, "weight", 1.0f);
    marko.addEdge("created", lop, "weight", 0.4f);
    josh.addEdge("created", ripple, "weight", 1.0f);
    josh.addEdge("created", lop, "weight", 0.4f);
    peter.addEdge("created", lop, "weight", 0.2f);

    GraphTraversalSource g = graph.traversal();
    Vertex fromNode = g.V().has("name", "marko").next();
    Vertex toNode = g.V().has("name", "peter").next();
    ArrayList list = new ArrayList();
    g.V(fromNode).repeat(both().simplePath()).until(is(toNode)).limit(1).path().fill(list);
    LOGGER.info(list.toString());
    System.exit(0);
}
 
开发者ID:pluradj,项目名称:titan-tp3-java-example,代码行数:27,代码来源:JavaExample.java

示例13: getGraphInstance

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
public static TitanGraph getGraphInstance() {
    if (graphInstance == null) {
        synchronized (Titan1GraphDatabase.class) {
            if (graphInstance == null) {
                Configuration config;
                try {
                    config = getConfiguration();
                } catch (AtlasException e) {
                    throw new RuntimeException(e);
                }

                graphInstance = TitanFactory.open(config);
                atlasGraphInstance = new Titan1Graph();
                validateIndexBackend(config);
            }
        }
    }
    return graphInstance;
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:20,代码来源:Titan1GraphDatabase.java

示例14: getEdge

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
public TitanEdge getEdge(FaunusEdge faunusEdge, TitanVertex in, TitanVertex out, TitanGraph graph, Mapper.Context context) {
    Bindings bindings = new SimpleBindings();
    bindings.put("faunusEdge", faunusEdge);
    bindings.put("inVertex", in);
    bindings.put("outVertex", out);
    bindings.put("graph", graph);
    bindings.put("context", context);
    bindings.put("log", LOGGER);
    DEFAULT_COMPAT.incrementContextCounter(context, Counters.EDGE_LOADER_SCRIPT_CALLS, 1L);
    try {
        TitanEdge edge = (TitanEdge)edgeMethod.eval(bindings);
        LOGGER.debug("Compiled edge method returned {}", edge);
        DEFAULT_COMPAT.incrementContextCounter(context, Counters.EDGE_LOADER_SCRIPT_RETURNS, 1L);
        return edge;
    } catch (ScriptException e) {
        DEFAULT_COMPAT.incrementContextCounter(context, Counters.EDGE_LOADER_SCRIPT_EXCEPTIONS, 1L);
        throw new RuntimeException(e);
    }
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:20,代码来源:LoaderScriptWrapper.java

示例15: getGraphInstance

import com.thinkaurelius.titan.core.TitanGraph; //导入依赖的package包/类
public static TitanGraph getGraphInstance() {
    if (graphInstance == null) {
        synchronized (Titan0GraphDatabase.class) {
            if (graphInstance == null) {
                Configuration config;
                try {
                    config = getConfiguration();
                } catch (AtlasException e) {
                    throw new RuntimeException(e);
                }

                graphInstance = TitanFactory.open(config);
                atlasGraphInstance = new Titan0Graph();
                validateIndexBackend(config);
            }
        }
    }
    return graphInstance;
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:20,代码来源:Titan0GraphDatabase.java


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