Search in sources :

Example 6 with TitanGraph

use of com.thinkaurelius.titan.core.TitanGraph in project titan by thinkaurelius.

the class VertexListTest method testLists.

@Test
public void testLists() {
    int num = 13;
    TitanGraph g = TitanFactory.open("inmemory");
    StandardTitanTx tx = (StandardTitanTx) g.newTransaction();
    VertexLongList vll = new VertexLongList(tx);
    VertexArrayList val = new VertexArrayList(tx);
    for (int i = 0; i < num; i++) {
        TitanVertex v = tx.addVertex();
        vll.add(v);
        val.add(v);
    }
    assertEquals(num, Iterables.size(vll));
    assertEquals(num, Iterables.size(val));
    vll.sort();
    val.sort();
    assertTrue(vll.isSorted());
    assertTrue(val.isSorted());
    for (Iterable<TitanVertex> iterable : new Iterable[] { val, vll }) {
        Iterator<TitanVertex> iter = iterable.iterator();
        TitanVertex previous = null;
        for (int i = 0; i < num; i++) {
            TitanVertex next = iter.next();
            if (previous != null)
                assertTrue(previous.longId() < next.longId());
            previous = next;
        }
        try {
            iter.next();
            fail();
        } catch (NoSuchElementException ex) {
        }
    }
    tx.commit();
    g.close();
}
Also used : TitanGraph(com.thinkaurelius.titan.core.TitanGraph) VertexLongList(com.thinkaurelius.titan.graphdb.query.vertex.VertexLongList) TitanVertex(com.thinkaurelius.titan.core.TitanVertex) VertexArrayList(com.thinkaurelius.titan.graphdb.query.vertex.VertexArrayList) StandardTitanTx(com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx) NoSuchElementException(java.util.NoSuchElementException) Test(org.junit.Test)

Example 7 with TitanGraph

use of com.thinkaurelius.titan.core.TitanGraph in project titan by thinkaurelius.

the class BerkeleyElasticsearchTest method testGraphOfTheGodsFactoryCreate.

/**
     * Test {@link com.thinkaurelius.titan.example.GraphOfTheGodsFactory#create(String)}.
     */
@Test
public void testGraphOfTheGodsFactoryCreate() {
    File bdbtmp = new File("target/gotgfactory");
    IOUtils.deleteDirectory(bdbtmp, true);
    TitanGraph gotg = GraphOfTheGodsFactory.create(bdbtmp.getPath());
    TitanIndexTest.assertGraphOfTheGods(gotg);
    gotg.close();
}
Also used : TitanGraph(com.thinkaurelius.titan.core.TitanGraph) File(java.io.File) Test(org.junit.Test) TitanIndexTest(com.thinkaurelius.titan.graphdb.TitanIndexTest)

Example 8 with TitanGraph

use of com.thinkaurelius.titan.core.TitanGraph in project titan by thinkaurelius.

the class HadoopVertexScanMapper method setup.

@Override
protected void setup(Context context) throws IOException, InterruptedException {
    /* Don't call super implementation super.setup(context); */
    org.apache.hadoop.conf.Configuration hadoopConf = DEFAULT_COMPAT.getContextConfiguration(context);
    ModifiableHadoopConfiguration scanConf = ModifiableHadoopConfiguration.of(TitanHadoopConfiguration.MAPRED_NS, hadoopConf);
    VertexScanJob vertexScan = getVertexScanJob(scanConf);
    ModifiableConfiguration graphConf = getTitanConfiguration(context);
    TitanGraph graph = TitanFactory.open(graphConf);
    job = VertexJobConverter.convert(graph, vertexScan);
    metrics = new HadoopContextScanMetrics(context);
    finishSetup(scanConf, graphConf);
}
Also used : TitanGraph(com.thinkaurelius.titan.core.TitanGraph) Configuration(org.apache.hadoop.conf.Configuration) VertexScanJob(com.thinkaurelius.titan.graphdb.olap.VertexScanJob) ModifiableConfiguration(com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration) ModifiableHadoopConfiguration(com.thinkaurelius.titan.hadoop.config.ModifiableHadoopConfiguration)

Example 9 with TitanGraph

use of com.thinkaurelius.titan.core.TitanGraph in project titan by thinkaurelius.

the class GraphOfTheGodsFactory method create.

public static TitanGraph create(final String directory) {
    TitanFactory.Builder config = TitanFactory.build();
    config.set("storage.backend", "berkeleyje");
    config.set("storage.directory", directory);
    config.set("index." + INDEX_NAME + ".backend", "elasticsearch");
    config.set("index." + INDEX_NAME + ".directory", directory + File.separator + "es");
    config.set("index." + INDEX_NAME + ".elasticsearch.local-mode", true);
    config.set("index." + INDEX_NAME + ".elasticsearch.client-only", false);
    TitanGraph graph = config.open();
    GraphOfTheGodsFactory.load(graph);
    return graph;
}
Also used : TitanGraph(com.thinkaurelius.titan.core.TitanGraph) TitanFactory(com.thinkaurelius.titan.core.TitanFactory)

Example 10 with TitanGraph

use of com.thinkaurelius.titan.core.TitanGraph in project titan by thinkaurelius.

the class GraphOfTheGodsFactory method main.

/**
     * Calls {@link TitanFactory#open(String)}, passing the Titan configuration file path
     * which must be the sole element in the {@code args} array, then calls
     * {@link #load(com.thinkaurelius.titan.core.TitanGraph)} on the opened graph,
     * then calls {@link com.thinkaurelius.titan.core.TitanGraph#close()}
     * and returns.
     * <p/>
     * This method may call {@link System#exit(int)} if it encounters an error, such as
     * failure to parse its arguments.  Only use this method when executing main from
     * a command line.  Use one of the other methods on this class ({@link #create(String)}
     * or {@link #load(com.thinkaurelius.titan.core.TitanGraph)}) when calling from
     * an enclosing application.
     *
     * @param args a singleton array containing a path to a Titan config properties file
     */
public static void main(String[] args) {
    if (null == args || 1 != args.length) {
        System.err.println("Usage: GraphOfTheGodsFactory <titan-config-file>");
        System.exit(1);
    }
    TitanGraph g = TitanFactory.open(args[0]);
    load(g);
    g.close();
}
Also used : TitanGraph(com.thinkaurelius.titan.core.TitanGraph)

Aggregations

TitanGraph (com.thinkaurelius.titan.core.TitanGraph)13 Test (org.junit.Test)5 StandardTitanGraph (com.thinkaurelius.titan.graphdb.database.StandardTitanGraph)3 TitanFactory (com.thinkaurelius.titan.core.TitanFactory)2 TitanVertex (com.thinkaurelius.titan.core.TitanVertex)2 TitanManagement (com.thinkaurelius.titan.core.schema.TitanManagement)2 LongHashSet (com.carrotsearch.hppc.LongHashSet)1 LongSet (com.carrotsearch.hppc.LongSet)1 RelationType (com.thinkaurelius.titan.core.RelationType)1 TitanSchemaType (com.thinkaurelius.titan.core.schema.TitanSchemaType)1 BasicConfiguration (com.thinkaurelius.titan.diskstorage.configuration.BasicConfiguration)1 ModifiableConfiguration (com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration)1 WriteConfiguration (com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration)1 CommonsConfiguration (com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration)1 TitanIndexTest (com.thinkaurelius.titan.graphdb.TitanIndexTest)1 IDPoolExhaustedException (com.thinkaurelius.titan.graphdb.database.idassigner.IDPoolExhaustedException)1 InternalRelation (com.thinkaurelius.titan.graphdb.internal.InternalRelation)1 InternalRelationType (com.thinkaurelius.titan.graphdb.internal.InternalRelationType)1 VertexScanJob (com.thinkaurelius.titan.graphdb.olap.VertexScanJob)1 VertexArrayList (com.thinkaurelius.titan.graphdb.query.vertex.VertexArrayList)1