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();
}
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();
}
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);
}
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;
}
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();
}
Aggregations