mgmt.buildIndex(foo, Vertex.class).addKey(f).buildCompositeIndex(); PropertyKey b = mgmt.makePropertyKey(bar).dataType(String.class).cardinality(Cardinality.LIST).make(); mgmt.buildIndex(bar, Vertex.class).addKey(b).buildCompositeIndex(); finishSchema();
mgmt.buildIndex("mi", Vertex.class).addKey(name, getTextMapping()).addKey(age).buildMixedIndex(INDEX); finishSchema(); final Vertex vs[] = new JanusGraphVertex[4];
@Test public void checkPropertyLockingAndIndex() { PropertyKey uid = makeKey("uid",String.class); JanusGraphIndex index = mgmt.buildIndex("uid",Vertex.class).unique().addKey(uid).buildCompositeIndex(); mgmt.setConsistency(index, ConsistencyModifier.LOCK); mgmt.makePropertyKey("name").dataType(String.class).make(); mgmt.makePropertyKey("age").dataType(Integer.class).make(); finishSchema(); metricsPrefix = "checkPropertyLockingAndIndex"; JanusGraphTransaction tx = graph.buildTransaction().groupName(metricsPrefix).start(); JanusGraphVertex v = tx.addVertex("uid", "v1", "age", 25, "name", "john"); assertEquals(25,v.property("age").value()); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); verifyLockingOverwrite(1); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1L)); resetMetrics(); tx = graph.buildTransaction().groupName(metricsPrefix).start(); v = Iterables.getOnlyElement(tx.query().has("uid", Cmp.EQUAL, "v1").vertices()); assertEquals(25,v.property("age").value()); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 1L)); verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE, 1L)); verifyStoreMetrics(METRICS_STOREMANAGER_NAME); }
janusGraphManagement.buildIndex(indexData.getIndexName(), Vertex.class).addKey(propKey).buildCompositeIndex(); janusGraphManagement.buildIndex(indexData.getIndexName(), Vertex.class).addKey(propKey, Mapping.STRING.asParameter()) .buildMixedIndex("search"); janusGraphManagement.buildIndex(indexData.getIndexName(), Vertex.class).addKey(propKey).buildMixedIndex("search"); janusGraphManagement.buildIndex(indexData.getIndexName(), Vertex.class).addKey(propKey).buildCompositeIndex(); janusGraphManagement.buildIndex(indexName, Edge.class).addKey(propKey).buildCompositeIndex();
janusGraphManagement.buildIndex(indexData.getIndexName(), Vertex.class).addKey(propKey).buildCompositeIndex(); janusGraphManagement.buildIndex(indexData.getIndexName(), Vertex.class).addKey(propKey, Mapping.STRING.asParameter()) .buildMixedIndex("search"); janusGraphManagement.buildIndex(indexData.getIndexName(), Vertex.class).addKey(propKey).buildMixedIndex("search"); janusGraphManagement.buildIndex(indexData.getIndexName(), Vertex.class).addKey(propKey).buildCompositeIndex(); janusGraphManagement.buildIndex(indexName, Edge.class).addKey(propKey).buildCompositeIndex();
if (mgmt.getGraphIndex(CHARACTER) == null) { final PropertyKey characterKey = mgmt.makePropertyKey(CHARACTER).dataType(String.class).make(); mgmt.buildIndex(CHARACTER, Vertex.class).addKey(characterKey).unique().buildCompositeIndex(); mgmt.buildIndex(COMIC_BOOK, Vertex.class).addKey(comicBookKey).unique().buildCompositeIndex(); mgmt.makePropertyKey(WEAPON).dataType(String.class).make(); mgmt.makeEdgeLabel(APPEARED).multiplicity(Multiplicity.MULTI).make();
/** * Create both <i>posts</i> and <i>follows</i> edges and related index. * <br/> * * Because the property and index for both follows and posts is the same we create them at the same point here. */ private void createEdgeSchema() { LOGGER.info("create edges schema"); EdgeLabel posts = mgt.makeEdgeLabel(POSTS).make(); EdgeLabel follows = mgt.makeEdgeLabel(FOLLOWS).make(); PropertyKey createdAt = mgt.makePropertyKey(CREATED_AT).dataType(Long.class).make(); mgt.buildIndex(indexName(POSTS, CREATED_AT), Edge.class). addKey(createdAt). indexOnly(posts). buildMixedIndex(BACKING_INDEX); mgt.buildIndex(indexName(FOLLOWS, CREATED_AT), Edge.class). addKey(createdAt). indexOnly(follows). buildMixedIndex(BACKING_INDEX); }
private static void makeIndicesComposite(JanusGraphManagement management){ ResourceBundle keys = ResourceBundle.getBundle("indices-composite"); Set<String> keyString = keys.keySet(); for(String propertyKeyLabel : keyString){ String indexLabel = "by" + propertyKeyLabel; JanusGraphIndex index = management.getGraphIndex(indexLabel); if(index == null) { boolean isUnique = Boolean.parseBoolean(keys.getString(propertyKeyLabel)); PropertyKey key = management.getPropertyKey(propertyKeyLabel); JanusGraphManagement.IndexBuilder indexBuilder = management.buildIndex(indexLabel, Vertex.class).addKey(key); if (isUnique) { indexBuilder.unique(); } indexBuilder.buildCompositeIndex(); } } } }
@Override public void createEdgeCompositeIndex(String propertyName, boolean isUnique, List<AtlasPropertyKey> propertyKeys) { IndexBuilder indexBuilder = management.buildIndex(propertyName, Edge.class); for (AtlasPropertyKey key : propertyKeys) { PropertyKey janusKey = AtlasJanusObjectFactory.createPropertyKey(key); indexBuilder.addKey(janusKey); } if (isUnique) { indexBuilder.unique(); } indexBuilder.buildCompositeIndex(); } }
@Override public void createEdgeMixedIndex(String indexName, String backingIndex, List<AtlasPropertyKey> propertyKeys) { IndexBuilder indexBuilder = management.buildIndex(indexName, Edge.class); for (AtlasPropertyKey key : propertyKeys) { PropertyKey janusKey = AtlasJanusObjectFactory.createPropertyKey(key); indexBuilder.addKey(janusKey); } indexBuilder.buildMixedIndex(backingIndex); }
@Override public void createVertexMixedIndex(String indexName, String backingIndex, List<AtlasPropertyKey> propertyKeys) { IndexBuilder indexBuilder = management.buildIndex(indexName, Vertex.class); for (AtlasPropertyKey key : propertyKeys) { PropertyKey janusKey = AtlasJanusObjectFactory.createPropertyKey(key); indexBuilder.addKey(janusKey); } indexBuilder.buildMixedIndex(backingIndex); }
/** * Create the user schema - vertex label, property and index. */ private void createUserSchema(){ LOGGER.info("Create {} schema", USER); VertexLabel user = mgt.makeVertexLabel(USER).make(); PropertyKey userName = mgt.makePropertyKey(USER_NAME).dataType(String.class).make(); mgt.buildIndex(indexName(USER, USER_NAME), Vertex.class). addKey(userName, Mapping.STRING.asParameter()). indexOnly(user). buildMixedIndex(BACKING_INDEX); }
@Override public void createFullTextMixedIndex(String indexName, String backingIndex, List<AtlasPropertyKey> propertyKeys) { IndexBuilder indexBuilder = management.buildIndex(indexName, Vertex.class); for (AtlasPropertyKey key : propertyKeys) { PropertyKey janusKey = AtlasJanusObjectFactory.createPropertyKey(key); indexBuilder.addKey(janusKey, org.janusgraph.core.schema.Parameter.of("mapping", Mapping.TEXT)); } indexBuilder.buildMixedIndex(backingIndex); }
/** * Create the statusUpdate schema - vertex label, property and full-text index. */ private void createStatusUpdateSchema(){ LOGGER.info("Create {} schema", STATUS_UPDATE); VertexLabel statusUpdate = mgt.makeVertexLabel(STATUS_UPDATE).make(); PropertyKey content = mgt.makePropertyKey(CONTENT).dataType(String.class).make(); mgt.buildIndex(indexName(STATUS_UPDATE, CONTENT), Vertex.class). addKey(content, Mapping.TEXTSTRING.asParameter()). indexOnly(statusUpdate). buildMixedIndex(BACKING_INDEX); }
protected void createSchema(JanusGraph graph) { JanusGraphManagement mgmt = graph.openManagement(); if (!mgmt.containsGraphIndex(COMPOSITE_INDEX_NAME)) { final PropertyKey customId = mgmt.makePropertyKey(PROP_CUSTOM_ID_KEY).dataType(String.class).make(); JanusGraphManagement.IndexBuilder customIdIndexBuilder = mgmt.buildIndex(COMPOSITE_INDEX_NAME, Vertex.class).addKey(customId); customIdIndexBuilder.buildCompositeIndex(); mgmt.makeVertexLabel(VERTEX_LABEL_LEVEL_1).make(); mgmt.commit(); } }
@Override public void createVertexCompositeIndex(String propertyName, boolean isUnique, List<AtlasPropertyKey> propertyKeys) { IndexBuilder indexBuilder = management.buildIndex(propertyName, Vertex.class); for (AtlasPropertyKey key : propertyKeys) { PropertyKey janusKey = AtlasJanusObjectFactory.createPropertyKey(key); indexBuilder.addKey(janusKey); } if (isUnique) { indexBuilder.unique(); } indexBuilder.buildCompositeIndex(); }
JanusGraphIndex edge1 = mgmt.buildIndex("edge1", Edge.class).addKey(time).addKey(weight).buildCompositeIndex(); JanusGraphIndex edge2 = mgmt.buildIndex("edge2", Edge.class) .indexOnly(connect).addKey(text).buildCompositeIndex(); .addKey(time).buildCompositeIndex(); JanusGraphIndex prop2 = mgmt.buildIndex("prop2", JanusGraphVertexProperty.class) .addKey(weight).addKey(text).buildCompositeIndex(); JanusGraphIndex vertex1 = mgmt.buildIndex("vertex1", Vertex.class).addKey(time) .indexOnly(person).unique().buildCompositeIndex(); JanusGraphIndex vertex12 = mgmt.buildIndex("vertex12", Vertex.class).addKey(text) .indexOnly(person).buildCompositeIndex(); JanusGraphIndex vertex2 = mgmt.buildIndex("vertex2", Vertex.class).addKey(time).addKey(name) .indexOnly(organization).buildCompositeIndex(); JanusGraphIndex vertex3 = mgmt.buildIndex("vertex3", Vertex.class).addKey(name).buildCompositeIndex(); mgmt.buildIndex("blablub", Vertex.class).addKey(text, Mapping.TEXT.asParameter()).buildCompositeIndex(); fail(); } catch (IllegalArgumentException ignored) { mgmt.buildIndex("edge1", Vertex.class).addKey(weight).buildCompositeIndex(); fail(); } catch (IllegalArgumentException ignored) { mgmt.buildIndex("jupdup", Vertex.class).addKey(ImplicitKey.ID).buildCompositeIndex(); fail(); } catch (IllegalArgumentException ignored) { mgmt.buildIndex("edgexyz", Edge.class).addKey(time).unique().buildCompositeIndex();
mgmt.buildPropertyIndex(sensor, "byTime", decr, time); mgmt.buildEdgeIndex(friend, "byTime", Direction.OUT, decr, time); mgmt.buildIndex("bySensorReading", Vertex.class).addKey(name).buildCompositeIndex(); finishSchema(); newTx();
mgmt.makePropertyKey("phone").dataType(String.class).cardinality(Cardinality.LIST).make(); mgmt.buildIndex("theIndex", Vertex.class).addKey(text, getTextMapping(), getFieldMap(text)).buildMixedIndex(INDEX); finishSchema();
addKey(name, getStringMapping()).buildMixedIndex(INDEX); JanusGraphIndex index2 = mgmt.buildIndex("index2", Vertex.class).indexOnly(person). addKey(text, getTextMapping()).addKey(weight).buildMixedIndex(INDEX); JanusGraphIndex index3 = mgmt.buildIndex("index3", Vertex.class).indexOnly(org). addKey(text, getTextMapping()).addKey(weight).buildMixedIndex(INDEX); mgmt.buildIndex("index2", Vertex.class).addKey(weight).buildMixedIndex(INDEX); fail(); } catch (final IllegalArgumentException ignored) { mgmt.buildIndex("index2", Vertex.class).addKey(weight).buildCompositeIndex(); fail(); } catch (final IllegalArgumentException ignored) { mgmt.buildIndex("index2", Vertex.class).addKey(weight).buildMixedIndex(INDEX); fail(); } catch (final IllegalArgumentException ignored) { mgmt.buildIndex("index2", Vertex.class).addKey(weight).buildCompositeIndex(); fail(); } catch (final IllegalArgumentException ignored) {