if (parameters == null) parameters = new Parameter[0]; IndexType indexType = ((TitanGraphIndexWrapper) index).getBaseIndex(); Preconditions.checkArgument(indexType instanceof MixedIndexType, "Can only add keys to an external index, not %s", index.name()); Preconditions.checkArgument(indexType instanceof IndexTypeWrapper && key instanceof TitanSchemaVertex && ((IndexTypeWrapper) indexType).getSchemaBase() instanceof TitanSchemaVertex); Preconditions.checkArgument(!field.getFieldKey().equals(key), "Key [%s] has already been added to index %s", key.name(), index.name());
TitanGraphIndex mixed = mgmt.buildIndex("mixed", Vertex.class).addKey(weight) .addKey(text, getTextMapping()).buildMixedIndex(INDEX); mixed.name(); composite.name(); finishSchema(); numV / strs.length, new boolean[]{false, true}); evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[0]), ElementCategory.VERTEX, numV / strs.length, new boolean[]{true, true}, mixed.name()); evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[0]).has("flag"), ElementCategory.VERTEX, numV / strs.length, new boolean[]{false, true}, mixed.name()); evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[0]).has("weight", Cmp.EQUAL, 1.5), ElementCategory.VERTEX, numV / divisor, new boolean[]{true, true}, composite.name()); evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[0]).has("weight", Cmp.EQUAL, 1.5).has("flag"), ElementCategory.VERTEX, numV / divisor, new boolean[]{false, true}, composite.name()); evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[2]).has("weight", Cmp.EQUAL, 2.5), ElementCategory.VERTEX, numV / divisor, new boolean[]{true, true}, mixed.name()); evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[2]).has("weight", Cmp.EQUAL, 2.5).has("flag"), ElementCategory.VERTEX, numV / divisor, new boolean[]{false, true}, mixed.name()); evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[3]).has("name", Cmp.EQUAL, strs[3]).has("weight", Cmp.EQUAL, 3.5), ElementCategory.VERTEX, numV / divisor, new boolean[]{true, true}, mixed.name(), composite.name()); evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[3]).has("name", Cmp.EQUAL, strs[3]).has("weight", Cmp.EQUAL, 3.5).has("flag"), ElementCategory.VERTEX, numV / divisor, new boolean[]{false, true}, mixed.name(), composite.name()); numV / strs.length, new boolean[]{false, true}); evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[0]), ElementCategory.VERTEX, numV / strs.length, new boolean[]{true, true}, mixed.name()); evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[0]).has("flag"), ElementCategory.VERTEX, numV / strs.length, new boolean[]{false, true}, mixed.name());
assertEquals("prop1", prop1.name()); assertTrue(Vertex.class.isAssignableFrom(vertex3.getIndexedElement())); assertTrue(TitanVertexProperty.class.isAssignableFrom(prop1.getIndexedElement())); assertEquals("prop1", prop1.name()); assertTrue(Vertex.class.isAssignableFrom(vertex3.getIndexedElement())); assertTrue(TitanVertexProperty.class.isAssignableFrom(prop1.getIndexedElement())); ElementCategory.EDGE, 1, new boolean[]{true, sorted}, edge1.name()); evaluateQuery(tx.query().has("time", Contain.IN, ImmutableList.of(10, 20, 30)).has("weight", Cmp.EQUAL, 0), ElementCategory.EDGE, 3, new boolean[]{true, sorted}, edge1.name()); evaluateQuery(tx.query().has("time", Cmp.EQUAL, 10).has("weight", Cmp.EQUAL, 0).has("text", Cmp.EQUAL, strs[10 % strs.length]), ElementCategory.EDGE, 1, new boolean[]{false, sorted}, edge1.name()); evaluateQuery(tx.query().has("time", Cmp.EQUAL, 10).has("weight", Cmp.EQUAL, 1), ElementCategory.EDGE, 1, new boolean[]{true, sorted}, edge1.name()); evaluateQuery(tx.query().has("time", Cmp.EQUAL, 20).has("weight", Cmp.EQUAL, 0), ElementCategory.EDGE, 1, new boolean[]{true, sorted}, edge1.name()); evaluateQuery(tx.query().has("time", Cmp.EQUAL, 20).has("weight", Cmp.EQUAL, 3), ElementCategory.EDGE, 0, new boolean[]{true, sorted}, edge1.name()); evaluateQuery(tx.query().has("text", Cmp.EQUAL, strs[0]).has(LABEL_NAME, "connect"), ElementCategory.EDGE, numV / strs.length, new boolean[]{true, sorted}, edge2.name()); evaluateQuery(tx.query().has("text", Cmp.EQUAL, strs[0]).has(LABEL_NAME, "connect").limit(10), ElementCategory.EDGE, 10, new boolean[]{true, sorted}, edge2.name()); evaluateQuery(tx.query().has("text", Cmp.EQUAL, strs[0]), ElementCategory.EDGE, numV / strs.length * 2, new boolean[]{false, sorted}); ElementCategory.PROPERTY, 2, new boolean[]{true, sorted}, prop1.name()); evaluateQuery(tx.query().has("weight", Cmp.EQUAL, 0.0).has("text", Cmp.EQUAL, strs[0]), ElementCategory.PROPERTY, 2 * numV / (4 * 5), new boolean[]{true, sorted}, prop2.name());
assertEquals("index2", index2.name()); assertEquals(INDEX, index3.getBackingIndex()); assertFalse(index2.isUnique()); assertEquals("index2", index2.name()); assertEquals(INDEX, index3.getBackingIndex()); assertFalse(index2.isUnique()); numV / strs.length, new boolean[]{true, true}, index2.name()); evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[0]).has(LABEL_NAME, Cmp.EQUAL, "person").orderBy("weight", decr), ElementCategory.VERTEX, numV / strs.length, new boolean[]{true, true}, weight, Order.DESC, index2.name()); evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[3]).has(LABEL_NAME, Cmp.EQUAL, "org"), ElementCategory.VERTEX, numV / strs.length, new boolean[]{true, true}, index3.name()); evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[1]).has(LABEL_NAME, Cmp.EQUAL, "org").orderBy("weight", decr), ElementCategory.VERTEX, numV / strs.length, new boolean[]{true, true}, weight, Order.DESC, index3.name()); evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[0]).has("weight", Cmp.EQUAL, 2.5).has(LABEL_NAME, Cmp.EQUAL, "person"), ElementCategory.VERTEX, numV / (modulo * strs.length), new boolean[]{true, true}, index2.name()); evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[2]).has(LABEL_NAME, Cmp.EQUAL, "person"), ElementCategory.VERTEX, numV / strs.length, new boolean[]{false, true}, index1.name()); evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[3]).has(LABEL_NAME, Cmp.EQUAL, "person"), ElementCategory.VERTEX, 0, new boolean[]{false, true}, index1.name()); evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[0]), ElementCategory.VERTEX, numV / strs.length, new boolean[]{true, true}, index1.name()); evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[2]).has("text", Text.CONTAINS, strs[2]).has(LABEL_NAME, Cmp.EQUAL, "person"), ElementCategory.VERTEX, numV / strs.length, new boolean[]{true, true}, index1.name(), index2.name()); evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[0]).has("text", Text.CONTAINS, strs[0]).has(LABEL_NAME, Cmp.EQUAL, "person").orderBy("weight", incr), ElementCategory.VERTEX, numV / strs.length, new boolean[]{true, true}, weight, Order.ASC, index1.name(), index2.name()); numV / strs.length, new boolean[]{true, true}, index2.name());
mixed.name(); finishSchema();
TitanGraphIndex gindex = mgmt.getGraphIndex("timeIndex"); mgmt.changeName(gindex, "byTime"); assertEquals("byTime", gindex.name());
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; }
if (parameters == null) parameters = new Parameter[0]; IndexType indexType = ((TitanGraphIndexWrapper) index).getBaseIndex(); Preconditions.checkArgument(indexType instanceof MixedIndexType, "Can only add keys to an external index, not %s", index.name()); Preconditions.checkArgument(indexType instanceof IndexTypeWrapper && key instanceof TitanSchemaVertex && ((IndexTypeWrapper) indexType).getSchemaBase() instanceof TitanSchemaVertex); Preconditions.checkArgument(!field.getFieldKey().equals(key), "Key [%s] has already been added to index %s", key.name(), index.name());