com.thinkaurelius.titan.core.schema.TitanManagement Java Examples
The following examples show how to use
com.thinkaurelius.titan.core.schema.TitanManagement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractTitanGraphProvider.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
@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); }
Example #2
Source File: SchemaContainer.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
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(); } }
Example #3
Source File: Titan1Graph.java From incubator-atlas with Apache License 2.0 | 6 votes |
public Titan1Graph() { //determine multi-properties once at startup TitanManagement mgmt = null; try { mgmt = Titan1GraphDatabase.getGraphInstance().openManagement(); Iterable<PropertyKey> keys = mgmt.getRelationTypes(PropertyKey.class); multiProperties = new HashSet<>(); for (PropertyKey key : keys) { if (key.cardinality() != Cardinality.SINGLE) { multiProperties.add(key.name()); } } } finally { if (mgmt != null) { mgmt.rollback(); } } }
Example #4
Source File: Titan0Graph.java From incubator-atlas with Apache License 2.0 | 6 votes |
public Titan0Graph() { //determine multi-properties once at startup TitanManagement mgmt = null; try { mgmt = Titan0GraphDatabase.getGraphInstance().getManagementSystem(); Iterable<PropertyKey> keys = mgmt.getRelationTypes(PropertyKey.class); multiProperties = Collections.synchronizedSet(new HashSet<String>()); for(PropertyKey key : keys) { if (key.getCardinality() != Cardinality.SINGLE) { multiProperties.add(key.getName()); } } } finally { if (mgmt != null) { mgmt.rollback(); } } }
Example #5
Source File: EdgeSerializerTest.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
@Test public void testValueOrdering() { StandardTitanGraph graph = (StandardTitanGraph) StorageSetup.getInMemoryGraph(); TitanManagement mgmt = graph.openManagement(); EdgeLabel father = mgmt.makeEdgeLabel("father").multiplicity(Multiplicity.MANY2ONE).make(); for (int i=1;i<=5;i++) mgmt.makePropertyKey("key" + i).dataType(Integer.class).make(); mgmt.commit(); TitanVertex v1 = graph.addVertex(), v2 = graph.addVertex(); TitanEdge e1 = v1.addEdge("father",v2); for (int i=1;i<=5;i++) e1.property("key"+i,i); graph.tx().commit(); e1.remove(); graph.tx().commit(); }
Example #6
Source File: TitanGraphBaseTest.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
public void clopen(Object... settings) { config = getConfiguration(); if (mgmt!=null && mgmt.isOpen()) mgmt.rollback(); if (null != tx && tx.isOpen()) tx.commit(); if (settings!=null && settings.length>0) { Map<TestConfigOption,Object> options = validateConfigOptions(settings); TitanManagement gconf = null; ModifiableConfiguration lconf = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,config, BasicConfiguration.Restriction.LOCAL); for (Map.Entry<TestConfigOption,Object> option : options.entrySet()) { if (option.getKey().option.isLocal()) { lconf.set(option.getKey().option,option.getValue(),option.getKey().umbrella); } else { if (gconf==null) gconf = graph.openManagement(); gconf.set(ConfigElement.getPath(option.getKey().option,option.getKey().umbrella),option.getValue()); } } if (gconf!=null) gconf.commit(); lconf.close(); } if (null != graph && graph.isOpen()) graph.close(); Preconditions.checkNotNull(config); open(config); }
Example #7
Source File: Titan0GraphDatabase.java From incubator-atlas with Apache License 2.0 | 6 votes |
static void validateIndexBackend(Configuration config) { String configuredIndexBackend = config.getString(INDEX_BACKEND_CONF); TitanManagement managementSystem = null; try { managementSystem = getGraphInstance().getManagementSystem(); String currentIndexBackend = managementSystem.get(INDEX_BACKEND_CONF); if (!equals(configuredIndexBackend, currentIndexBackend)) { throw new RuntimeException("Configured Index Backend " + configuredIndexBackend + " differs from earlier configured Index Backend " + currentIndexBackend + ". Aborting!"); } } finally { if (managementSystem != null) { managementSystem.commit(); } } }
Example #8
Source File: Titan0GraphManagement.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Override public void createVertexIndex(String propertyName, String backingIndex, List<AtlasPropertyKey> propertyKeys) { TitanManagement.IndexBuilder indexBuilder = management.buildIndex(propertyName, Vertex.class); for(AtlasPropertyKey key : propertyKeys) { PropertyKey titanKey = TitanObjectFactory.createPropertyKey(key); indexBuilder.addKey(titanKey); } indexBuilder.buildMixedIndex(backingIndex); }
Example #9
Source File: Titan0GraphManagement.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Override public void createExactMatchIndex(String propertyName, boolean enforceUniqueness, List<AtlasPropertyKey> propertyKeys) { TitanManagement.IndexBuilder indexBuilder = management.buildIndex(propertyName, Vertex.class); for(AtlasPropertyKey key : propertyKeys) { PropertyKey titanKey = TitanObjectFactory.createPropertyKey(key); indexBuilder.addKey(titanKey); } if (enforceUniqueness) { indexBuilder.unique(); } indexBuilder.buildCompositeIndex(); }
Example #10
Source File: Titan1GraphDatabase.java From incubator-atlas with Apache License 2.0 | 5 votes |
static void validateIndexBackend(Configuration config) { String configuredIndexBackend = config.getString(INDEX_BACKEND_CONF); TitanManagement managementSystem = getGraphInstance().openManagement(); String currentIndexBackend = managementSystem.get(INDEX_BACKEND_CONF); managementSystem.commit(); if (!configuredIndexBackend.equals(currentIndexBackend)) { throw new RuntimeException("Configured Index Backend " + configuredIndexBackend + " differs from earlier configured Index Backend " + currentIndexBackend + ". Aborting!"); } }
Example #11
Source File: Titan1GraphManagement.java From incubator-atlas with Apache License 2.0 | 5 votes |
public void createExactMatchVertexIndex(String propertyName, boolean enforceUniqueness, List<AtlasPropertyKey> propertyKeys) { TitanManagement.IndexBuilder indexBuilder = management.buildIndex(propertyName, Vertex.class); for (AtlasPropertyKey key : propertyKeys) { PropertyKey titanKey = TitanObjectFactory.createPropertyKey(key); indexBuilder.addKey(titanKey); } if (enforceUniqueness) { indexBuilder.unique(); } indexBuilder.buildCompositeIndex(); }
Example #12
Source File: Titan1GraphManagement.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Override public void createVertexIndex(String propertyName, String backingIndex, List<AtlasPropertyKey> propertyKeys) { TitanManagement.IndexBuilder indexBuilder = management.buildIndex(propertyName, Vertex.class); for (AtlasPropertyKey key : propertyKeys) { PropertyKey titanKey = TitanObjectFactory.createPropertyKey(key); indexBuilder.addKey(titanKey); } indexBuilder.buildMixedIndex(backingIndex); }
Example #13
Source File: Titan1Graph.java From incubator-atlas with Apache License 2.0 | 5 votes |
private Set<String> getIndexKeys(Class<? extends Element> titanElementClass) { TitanManagement mgmt = getGraph().openManagement(); Iterable<TitanGraphIndex> indices = mgmt.getGraphIndexes(titanElementClass); Set<String> result = new HashSet<String>(); for (TitanGraphIndex index : indices) { result.add(index.name()); } mgmt.commit(); return result; }
Example #14
Source File: TitanSuite.java From peapod with Apache License 2.0 | 5 votes |
@BeforeClass public static void setGraphProvider() throws IOException { GraphTest.graphProvider = new GraphProvider() { public Graph getGraph() throws IOException { TitanGraph graph = TitanFactory.build().set("storage.backend", "inmemory").open(); TitanManagement management = graph.openManagement(); management.makePropertyKey("location").dataType(String.class).cardinality(Cardinality.LIST).make(); management.makePropertyKey("firstName").dataType(String.class).cardinality(Cardinality.LIST).make(); management.commit(); return graph; } }; }
Example #15
Source File: ManagementTest.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test public void testReservedNamesRejectedForPropertyKeys() { for (String s : ILLEGAL_USER_DEFINED_NAMES) { TitanManagement tm = graph.openManagement(); try { tm.makePropertyKey(s); Assert.fail("Property key \"" + s + "\" must be rejected"); } catch (IllegalArgumentException e) { log.debug("Caught expected exception", e); } finally { tm.commit(); } } }
Example #16
Source File: RelationIndexStatusWatcher.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
/** * Poll a relation index until it has a certain {@link SchemaStatus}, * or until a configurable timeout is exceeded. * * @return a report with information about schema state, execution duration, and the index */ @Override public RelationIndexStatusReport call() throws InterruptedException { Preconditions.checkNotNull(g, "Graph instance must not be null"); Preconditions.checkNotNull(relationIndexName, "Index name must not be null"); Preconditions.checkNotNull(status, "Target status must not be null"); RelationTypeIndex idx; Timer t = new Timer(TimestampProviders.MILLI).start(); boolean timedOut; while (true) { SchemaStatus actualStatus = null; TitanManagement mgmt = null; try { mgmt = g.openManagement(); idx = mgmt.getRelationIndex(mgmt.getRelationType(relationTypeName), relationIndexName); actualStatus = idx.getIndexStatus(); LOGGER.info("Index {} (relation type {}) has status {}", relationIndexName, relationTypeName, actualStatus); if (status.equals(actualStatus)) { return new RelationIndexStatusReport(true, relationIndexName, relationTypeName, actualStatus, status, t.elapsed()); } } finally { if (null != mgmt) mgmt.rollback(); // Let an exception here propagate up the stack } timedOut = null != timeout && 0 < t.elapsed().compareTo(timeout); if (timedOut) { LOGGER.info("Timed out ({}) while waiting for index {} (relation type {}) to reach status {}", timeout, relationIndexName, relationTypeName, status); return new RelationIndexStatusReport(false, relationIndexName, relationTypeName, actualStatus, status, t.elapsed()); } Thread.sleep(poll.toMillis()); } }
Example #17
Source File: ManagementSystem.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Override public TitanManagement.IndexBuilder indexOnly(TitanSchemaType schemaType) { Preconditions.checkNotNull(schemaType); Preconditions.checkArgument(elementCategory.isValidConstraint(schemaType), "Need to specify a valid schema type for this index definition: %s", schemaType); constraint = schemaType; return this; }
Example #18
Source File: ManagementTest.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test public void testReservedNamesRejectedForEdgeLabels() { for (String s : ILLEGAL_USER_DEFINED_NAMES) { TitanManagement tm = graph.openManagement(); try { tm.makeEdgeLabel(s); Assert.fail("Edge label \"" + s + "\" must be rejected"); } catch (IllegalArgumentException e) { log.debug("Caught expected exception", e); } finally { tm.commit(); } } }
Example #19
Source File: ManagementTest.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test public void testReservedNamesRejectedForVertexLabels() { for (String s : ILLEGAL_USER_DEFINED_NAMES) { TitanManagement tm = graph.openManagement(); VertexLabelMaker vlm = null; try { vlm = tm.makeVertexLabel(s); Assert.fail("Vertex label \"" + s + "\" must be rejected"); } catch (IllegalArgumentException e) { log.debug("Caught expected exception", e); } finally { tm.commit(); } } }
Example #20
Source File: SerializerGraphConfiguration.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test public void testOnlyRegisteredSerialization() { TitanManagement mgmt = graph.openManagement(); PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).make(); PropertyKey any = mgmt.makePropertyKey("any").cardinality(Cardinality.LIST).dataType(Object.class).make(); mgmt.buildIndex("byTime",Vertex.class).addKey(time).buildCompositeIndex(); EdgeLabel knows = mgmt.makeEdgeLabel("knows").make(); VertexLabel person = mgmt.makeVertexLabel("person").make(); mgmt.commit(); TitanTransaction tx = graph.newTransaction(); TitanVertex v = tx.addVertex("person"); v.property("time", 5); v.property("any", new Double(5.0)); v.property("any", new TClass1(5,1.5f)); v.property("any", TEnum.THREE); tx.commit(); tx = graph.newTransaction(); v = tx.query().has("time",5).vertices().iterator().next(); assertEquals(5,(int)v.value("time")); assertEquals(3, Iterators.size(v.properties("any"))); tx.rollback(); //Verify that non-registered objects aren't allowed for (Object o : new Object[]{new TClass2("abc",5)}) { tx = graph.newTransaction(); v = tx.addVertex("person"); try { v.property("any", o); //Should not be allowed tx.commit(); fail(); } catch (IllegalArgumentException e) { } finally { if (tx.isOpen()) tx.rollback(); } } }
Example #21
Source File: AbstractIndexManagementIT.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@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)); }
Example #22
Source File: AbstractIndexManagementIT.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@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)); }
Example #23
Source File: AbstractIndexManagementIT.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@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)); }
Example #24
Source File: Titan1GraphManagement.java From incubator-atlas with Apache License 2.0 | 4 votes |
public Titan1GraphManagement(Titan1Graph graph, TitanManagement managementSystem) { this.management = managementSystem; this.graph = graph; }
Example #25
Source File: Titan0GraphManagement.java From incubator-atlas with Apache License 2.0 | 4 votes |
public Titan0GraphManagement(Titan0Graph graph, TitanManagement managementSystem) { this.graph = graph; management = managementSystem; }
Example #26
Source File: AbstractIndexManagementIT.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
@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")); }
Example #27
Source File: GraphOfTheGodsFactory.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
public static void load(final TitanGraph graph, String mixedIndexName, boolean uniqueNameCompositeIndex) { //Create Schema TitanManagement mgmt = graph.openManagement(); final PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).make(); TitanManagement.IndexBuilder nameIndexBuilder = mgmt.buildIndex("name", Vertex.class).addKey(name); if (uniqueNameCompositeIndex) nameIndexBuilder.unique(); TitanGraphIndex namei = nameIndexBuilder.buildCompositeIndex(); mgmt.setConsistency(namei, ConsistencyModifier.LOCK); final PropertyKey age = mgmt.makePropertyKey("age").dataType(Integer.class).make(); if (null != mixedIndexName) mgmt.buildIndex("vertices", Vertex.class).addKey(age).buildMixedIndex(mixedIndexName); final PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).make(); final PropertyKey reason = mgmt.makePropertyKey("reason").dataType(String.class).make(); final PropertyKey place = mgmt.makePropertyKey("place").dataType(Geoshape.class).make(); if (null != mixedIndexName) mgmt.buildIndex("edges", Edge.class).addKey(reason).addKey(place).buildMixedIndex(mixedIndexName); mgmt.makeEdgeLabel("father").multiplicity(Multiplicity.MANY2ONE).make(); mgmt.makeEdgeLabel("mother").multiplicity(Multiplicity.MANY2ONE).make(); EdgeLabel battled = mgmt.makeEdgeLabel("battled").signature(time).make(); mgmt.buildEdgeIndex(battled, "battlesByTime", Direction.BOTH, Order.decr, time); mgmt.makeEdgeLabel("lives").signature(reason).make(); mgmt.makeEdgeLabel("pet").make(); mgmt.makeEdgeLabel("brother").make(); mgmt.makeVertexLabel("titan").make(); mgmt.makeVertexLabel("location").make(); mgmt.makeVertexLabel("god").make(); mgmt.makeVertexLabel("demigod").make(); mgmt.makeVertexLabel("human").make(); mgmt.makeVertexLabel("monster").make(); mgmt.commit(); TitanTransaction tx = graph.newTransaction(); // vertices Vertex saturn = tx.addVertex(T.label, "titan", "name", "saturn", "age", 10000); Vertex sky = tx.addVertex(T.label, "location", "name", "sky"); Vertex sea = tx.addVertex(T.label, "location", "name", "sea"); Vertex jupiter = tx.addVertex(T.label, "god", "name", "jupiter", "age", 5000); Vertex neptune = tx.addVertex(T.label, "god", "name", "neptune", "age", 4500); Vertex hercules = tx.addVertex(T.label, "demigod", "name", "hercules", "age", 30); Vertex alcmene = tx.addVertex(T.label, "human", "name", "alcmene", "age", 45); Vertex pluto = tx.addVertex(T.label, "god", "name", "pluto", "age", 4000); Vertex nemean = tx.addVertex(T.label, "monster", "name", "nemean"); Vertex hydra = tx.addVertex(T.label, "monster", "name", "hydra"); Vertex cerberus = tx.addVertex(T.label, "monster", "name", "cerberus"); Vertex tartarus = tx.addVertex(T.label, "location", "name", "tartarus"); // edges jupiter.addEdge("father", saturn); jupiter.addEdge("lives", sky, "reason", "loves fresh breezes"); jupiter.addEdge("brother", neptune); jupiter.addEdge("brother", pluto); neptune.addEdge("lives", sea).property("reason", "loves waves"); neptune.addEdge("brother", jupiter); neptune.addEdge("brother", pluto); hercules.addEdge("father", jupiter); hercules.addEdge("mother", alcmene); hercules.addEdge("battled", nemean, "time", 1, "place", Geoshape.point(38.1f, 23.7f)); hercules.addEdge("battled", hydra, "time", 2, "place", Geoshape.point(37.7f, 23.9f)); hercules.addEdge("battled", cerberus, "time", 12, "place", Geoshape.point(39f, 22f)); pluto.addEdge("brother", jupiter); pluto.addEdge("brother", neptune); pluto.addEdge("lives", tartarus, "reason", "no fear of death"); pluto.addEdge("pet", cerberus); cerberus.addEdge("lives", tartarus); // commit the transaction to disk tx.commit(); }
Example #28
Source File: ManagementSystem.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
@Override public TitanManagement.IndexBuilder addKey(PropertyKey key) { Preconditions.checkArgument(key != null && (key instanceof PropertyKeyVertex), "Key must be a user defined key: %s", key); keys.put(key, null); return this; }
Example #29
Source File: StandardScanner.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
public TitanManagement.IndexJobFuture getRunningJob(Object jobId) { return runningJobs.get(jobId); }
Example #30
Source File: StandardScanner.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
public TitanManagement.IndexJobFuture execute() throws BackendException { Preconditions.checkArgument(job!=null,"Need to specify a job to execute"); Preconditions.checkArgument(StringUtils.isNotBlank(dbName),"Need to specify a database to execute against"); Preconditions.checkArgument(times!=null,"Need to configure the timestamp provider for this job"); StandardBaseTransactionConfig.Builder txBuilder = new StandardBaseTransactionConfig.Builder(); txBuilder.timestampProvider(times); Configuration scanConfig = manager.getFeatures().getScanTxConfig(); if (Configuration.EMPTY != graphConfiguration) { scanConfig = null == scanConfig ? graphConfiguration : new MergedConfiguration(graphConfiguration, scanConfig); } if (null != scanConfig) { txBuilder.customOptions(scanConfig); } // if (!txOptions.isEmpty()) { // ModifiableConfiguration writeConf = GraphDatabaseConfiguration.buildConfiguration(); // for (Map.Entry<String,Object> confEntry : txOptions.entrySet()) { // writeConf.set( // (ConfigOption<Object>) ConfigElement.parse(ROOT_NS, confEntry.getKey()).element, // confEntry.getValue()); // } // Configuration customConf = writeConf; // if (configuration!=Configuration.EMPTY) { // customConf = new MergedConfiguration(writeConf, configuration); // // } // txBuilder.customOptions(customConf); // } StoreTransaction storeTx = manager.beginTransaction(txBuilder.build()); KeyColumnValueStore kcvs = manager.openDatabase(dbName); openStores.add(kcvs); try { StandardScannerExecutor executor = new StandardScannerExecutor(job, finishJob, kcvs, storeTx, manager.getFeatures(), numProcessingThreads, workBlockSize, jobConfiguration, graphConfiguration); addJob(jobId,executor); new Thread(executor).start(); return executor; } catch (Throwable e) { storeTx.rollback(); throw e; } }