private void createTripleIndices(final String tripleIndexes, TitanGraph titanGraph) { if (null == tripleIndexes) { throw new IllegalArgumentException("index list, if supplied, must be non-null"); } Set<String> u = new HashSet<String>(); String[] a = tripleIndexes.split(","); for (String s : a) { String pattern = s.trim(); if (pattern.length() > 0) { u.add(pattern); } } for (String key : u) { if (!titanGraph.getIndexedKeys(Edge.class).contains(key)) { titanGraph.createKeyIndex(key, Edge.class); } } }
private void createTripleIndices(final String tripleIndexes, TitanGraph titanGraph) { if (null == tripleIndexes) { throw new IllegalArgumentException("index list, if supplied, must be non-null"); } Set<String> u = new HashSet<String>(); String[] a = tripleIndexes.split(","); for (String s : a) { String pattern = s.trim(); if (pattern.length() > 0) { u.add(pattern); } } for (String key : u) { if (!titanGraph.getIndexedKeys(Edge.class).contains(key)) { titanGraph.createKeyIndex(key, Edge.class); } } }
private static void codeSnippets() throws Exception { TitanGraph g = TitanFactory.open("/tmp/titan"); g.createKeyIndex("name", Vertex.class); Vertex juno = g.addVertex(null); juno.setProperty("name", "juno"); juno = g.getVertices("name", "juno").iterator().next(); TransactionalGraph tx = g.newTransaction(); Thread[] threads = new Thread[10]; for (int i = 0; i < threads.length; i++) { //threads[i]=new Thread(new DoSomething(tx)); threads[i].start(); } for (int i = 0; i < threads.length; i++) threads[i].join(); tx.commit(); }
/** * Initialise the handler using the graph passed as arguments. * * @param graph */ public TitanRDFHandler(TitanGraph graph, String indexes) { this.graph = new BatchGraph(graph); if (!graph.getIndexedKeys(Vertex.class).contains(VALUE)) { graph.createKeyIndex(VALUE, Vertex.class); } createTripleIndices(indexes, graph); namespaces = graph.addVertex(NAMESPACES_VERTEX_ID); }
private static void codeSnippets() throws Exception { TitanGraph g = TitanFactory.open("/tmp/titan"); g.createKeyIndex("name", Vertex.class); Vertex juno = g.addVertex(null); juno.setProperty("name", "juno"); juno = g.getVertices("name", "juno").iterator().next(); TransactionalGraph tx = g.newTransaction(); Thread[] threads = new Thread[10]; for (int i = 0; i < threads.length; i++) { //threads[i]=new Thread(new DoSomething(tx)); threads[i].start(); } for (int i = 0; i < threads.length; i++) threads[i].join(); tx.commit(); }
/** * Initialise the handler using the graph passed as arguments. * * @param graph */ public TitanRDFHandler(TitanGraph graph, String indexes) { this.graph = new BatchGraph(graph); if (!graph.getIndexedKeys(Vertex.class).contains(VALUE)) { graph.createKeyIndex(VALUE, Vertex.class); } createTripleIndices(indexes, graph); namespaces = graph.addVertex(NAMESPACES_VERTEX_ID); }
public GraphContext(File diskCache) { File lucene = new File(diskCache, "graphsearch"); FileUtils.deleteQuietly(lucene); File berkley = new File(diskCache, "graph"); FileUtils.deleteQuietly(berkley); Configuration conf = new BaseConfiguration(); conf.setProperty("storage.directory", berkley.getAbsolutePath()); conf.setProperty("storage.backend", "berkeleyje"); conf.setProperty("storage.index.search.backend", "lucene"); conf.setProperty("storage.index.search.directory", lucene.getAbsolutePath()); graph = TitanFactory.open(conf); graph.createKeyIndex("qualifiedName", Vertex.class, new Parameter<String, String>("type", "UNIQUE")); batch = new BatchGraph<TitanGraph>(graph, 1000L); FramedGraphFactory factory = new FramedGraphFactory( new TypedGraphModuleBuilder() .withClass(JavaClassFacet.class) .withClass(org.jboss.windup.graph.model.resource.File.class) .withClass(XmlFacet.class) .withClass(Meta.class) .withClass(JBossModuleMeta.class) .build() ); framed = factory.create(graph); }
public GraphContext(File diskCache) { File lucene = new File(diskCache, "graphsearch"); FileUtils.deleteQuietly(lucene); File berkley = new File(diskCache, "graph"); FileUtils.deleteQuietly(berkley); Configuration conf = new BaseConfiguration(); conf.setProperty("storage.directory", berkley.getAbsolutePath()); conf.setProperty("storage.backend", "berkeleyje"); conf.setProperty("storage.index.search.backend", "lucene"); conf.setProperty("storage.index.search.directory", lucene.getAbsolutePath()); graph = TitanFactory.open(conf); graph.createKeyIndex("qualifiedName", Vertex.class, new Parameter<String, String>("type", "UNIQUE")); batch = new BatchGraph<TitanGraph>(graph, 1000L); FramedGraphFactory factory = new FramedGraphFactory( new TypedGraphModuleBuilder() .withClass(JavaClassFacet.class) .withClass(org.jboss.windup.graph.model.resource.File.class) .withClass(XmlFacet.class) .withClass(Meta.class) .withClass(JBossModuleMeta.class) .build() ); framed = factory.create(graph); }