Java Code Examples for com.thinkaurelius.titan.core.Cardinality

The following are top voted examples for showing how to use com.thinkaurelius.titan.core.Cardinality. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: titan1withtp3.1   File: IndexProviderTest.java   View source code 6 votes vote down vote up
public static final Map<String,KeyInformation> getMapping(final IndexFeatures indexFeatures) {
    Preconditions.checkArgument(indexFeatures.supportsStringMapping(Mapping.TEXTSTRING) ||
            (indexFeatures.supportsStringMapping(Mapping.TEXT) && indexFeatures.supportsStringMapping(Mapping.STRING)),
            "Index must support string and text mapping");
    return new HashMap<String,KeyInformation>() {{
        put(TEXT,new StandardKeyInformation(String.class, Cardinality.SINGLE, new Parameter("mapping",
                indexFeatures.supportsStringMapping(Mapping.TEXT)?Mapping.TEXT:Mapping.TEXTSTRING)));
        put(TIME,new StandardKeyInformation(Long.class, Cardinality.SINGLE));
        put(WEIGHT,new StandardKeyInformation(Double.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.DEFAULT)));
        put(LOCATION,new StandardKeyInformation(Geoshape.class, Cardinality.SINGLE));
        put(NAME,new StandardKeyInformation(String.class, Cardinality.SINGLE, new Parameter("mapping",
                indexFeatures.supportsStringMapping(Mapping.STRING)?Mapping.STRING:Mapping.TEXTSTRING)));
        if(indexFeatures.supportsCardinality(Cardinality.LIST)) {
            put(PHONE_LIST, new StandardKeyInformation(String.class, Cardinality.LIST, new Parameter("mapping",
                    indexFeatures.supportsStringMapping(Mapping.STRING) ? Mapping.STRING : Mapping.TEXTSTRING)));
        }
        if(indexFeatures.supportsCardinality(Cardinality.SET)) {
            put(PHONE_SET, new StandardKeyInformation(String.class, Cardinality.SET, new Parameter("mapping",
                    indexFeatures.supportsStringMapping(Mapping.STRING) ? Mapping.STRING : Mapping.TEXTSTRING)));
        }
        put(DATE,new StandardKeyInformation(Instant.class, Cardinality.SINGLE));
    }};
}
 
Example 2
Project: titan1withtp3.1   File: TitanGraphTest.java   View source code 6 votes vote down vote up
@Test
public void testTinkerPopCardinality() {
    PropertyKey id = mgmt.makePropertyKey("id").cardinality(Cardinality.SINGLE).dataType(Integer.class).make();
    PropertyKey name = mgmt.makePropertyKey("name").cardinality(Cardinality.SINGLE).dataType(String.class).make();
    PropertyKey names = mgmt.makePropertyKey("names").cardinality(Cardinality.LIST).dataType(String.class).make();

    mgmt.buildIndex("byId", Vertex.class).addKey(id).buildCompositeIndex();

    finishSchema();
    GraphTraversalSource gts;
    Vertex v;

    v = graph.addVertex("id", 1);
    v.property(single, "name", "t1");
    graph.addVertex("id", 2, "names", "n1", "names", "n2");
    graph.tx().commit();

    gts = graph.traversal();
    v = gts.V().has("id", 1).next();
    v.property(single, "name", "t2");
    v = gts.V().has("id", 1).next();
    v.property(single, "name", "t3");
    assertCount(1, gts.V(v).properties("name"));
    assertCount(2, gts.V().has("id", 2).properties("names"));
    assertCount(2, gts.V().hasLabel("vertex"));
}
 
Example 3
Project: titan0.5.4-hbase1.1.1-custom   File: TestCoreElements.java   View source code 6 votes vote down vote up
@Test
public void testMultiplicityCardinality() {
    assertEquals(Multiplicity.MULTI,Multiplicity.convert(Cardinality.LIST));
    assertEquals(Multiplicity.SIMPLE,Multiplicity.convert(Cardinality.SET));
    assertEquals(Multiplicity.MANY2ONE,Multiplicity.convert(Cardinality.SINGLE));

    assertEquals(Multiplicity.MULTI.getCardinality(),Cardinality.LIST);
    assertEquals(Multiplicity.SIMPLE.getCardinality(),Cardinality.SET);
    assertEquals(Multiplicity.MANY2ONE.getCardinality(),Cardinality.SINGLE);

    assertFalse(Multiplicity.MULTI.isConstrained());
    assertTrue(Multiplicity.SIMPLE.isConstrained());
    assertTrue(Multiplicity.ONE2ONE.isConstrained());

    assertTrue(Multiplicity.ONE2ONE.isConstrained(Direction.BOTH));
    assertTrue(Multiplicity.SIMPLE.isConstrained(Direction.BOTH));

    assertFalse(Multiplicity.MULTI.isUnique(Direction.OUT));
    assertTrue(Multiplicity.MANY2ONE.isUnique(Direction.OUT));
}
 
Example 4
Project: titan1withtp3.1   File: ElasticSearchIndexTest.java   View source code 6 votes vote down vote up
@Test
public void testSupport() {
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE), Text.CONTAINS));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Text.CONTAINS_PREFIX));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Text.CONTAINS_REGEX));
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Text.REGEX));
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.STRING)), Text.CONTAINS));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.STRING)), Text.PREFIX));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.STRING)), Text.REGEX));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.STRING)), Cmp.EQUAL));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.STRING)), Cmp.NOT_EQUAL));

    assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.EQUAL));
    assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.LESS_THAN_EQUAL));
    assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.LESS_THAN));
    assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.GREATER_THAN));
    assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.GREATER_THAN_EQUAL));
    assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.NOT_EQUAL));

    assertTrue(index.supports(of(Boolean.class, Cardinality.SINGLE), Cmp.EQUAL));
    assertTrue(index.supports(of(Boolean.class, Cardinality.SINGLE), Cmp.NOT_EQUAL));

    assertTrue(index.supports(of(UUID.class, Cardinality.SINGLE), Cmp.EQUAL));
    assertTrue(index.supports(of(UUID.class, Cardinality.SINGLE), Cmp.NOT_EQUAL));
}
 
Example 5
Project: titan0.5.4-hbase1.1.1-custom   File: LuceneIndex.java   View source code 6 votes vote down vote up
@Override
public boolean supports(KeyInformation information, TitanPredicate titanPredicate) {
    if (information.getCardinality()!= Cardinality.SINGLE) return false;
    Class<?> dataType = information.getDataType();
    Mapping mapping = Mapping.getMapping(information);
    if (mapping!=Mapping.DEFAULT && !AttributeUtil.isString(dataType)) return false;

    if (Number.class.isAssignableFrom(dataType)) {
        if (titanPredicate instanceof Cmp) return true;
    } else if (dataType == Geoshape.class) {
        return titanPredicate == Geo.WITHIN;
    } else if (AttributeUtil.isString(dataType)) {
        switch(mapping) {
            case DEFAULT:
            case TEXT:
                return titanPredicate == Text.CONTAINS || titanPredicate == Text.CONTAINS_PREFIX; // || titanPredicate == Text.CONTAINS_REGEX;
            case STRING:
                return titanPredicate == Cmp.EQUAL || titanPredicate==Cmp.NOT_EQUAL || titanPredicate==Text.PREFIX || titanPredicate==Text.REGEX;
        }
    }
    return false;
}
 
Example 6
Project: incubator-atlas   File: Titan1Graph.java   View source code 6 votes vote down vote up
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 7
Project: incubator-atlas   File: Titan0Graph.java   View source code 6 votes vote down vote up
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 8
Project: incubator-atlas   File: Titan0GraphManagement.java   View source code 6 votes vote down vote up
@Override
public AtlasPropertyKey makePropertyKey(String propertyName, Class propertyClass, AtlasCardinality cardinality) {

    if (cardinality.isMany()) {
        newMultProperties.add(propertyName);
    }

    PropertyKeyMaker propertyKeyBuilder = management.makePropertyKey(propertyName).dataType(propertyClass);

    if (cardinality != null) {
        Cardinality titanCardinality = TitanObjectFactory.createCardinality(cardinality);
        propertyKeyBuilder.cardinality(titanCardinality);
    }
    PropertyKey propertyKey = propertyKeyBuilder.make();
    return GraphDbObjectFactory.createPropertyKey(propertyKey);
}
 
Example 9
Project: titan0.5.4-hbase1.1.1-custom   File: AbstractVertex.java   View source code 6 votes vote down vote up
@Override
public <O> O getProperty(PropertyKey key) {
    if (!((InternalRelationType)key).isHiddenType() && tx().getConfiguration().hasPropertyPrefetching()) {
        getProperties().iterator().hasNext();
    }
    Iterator<TitanProperty> iter = query().type(key).properties().iterator();
    if (key.getCardinality()== Cardinality.SINGLE) {
        if (iter.hasNext()) return (O)iter.next().getValue();
        else return null;
    } else {
        List<Object> result = new ArrayList<Object>();
        while (iter.hasNext()) {
            result.add(iter.next().getValue());
        }
        return (O)result;
    }
}
 
Example 10
Project: titan1.0.1.kafka   File: IndexProviderTest.java   View source code 6 votes vote down vote up
public static final Map<String,KeyInformation> getMapping(final IndexFeatures indexFeatures) {
    Preconditions.checkArgument(indexFeatures.supportsStringMapping(Mapping.TEXTSTRING) ||
            (indexFeatures.supportsStringMapping(Mapping.TEXT) && indexFeatures.supportsStringMapping(Mapping.STRING)),
            "Index must support string and text mapping");
    return new HashMap<String,KeyInformation>() {{
        put(TEXT,new StandardKeyInformation(String.class, Cardinality.SINGLE, new Parameter("mapping",
                indexFeatures.supportsStringMapping(Mapping.TEXT)?Mapping.TEXT:Mapping.TEXTSTRING)));
        put(TIME,new StandardKeyInformation(Long.class, Cardinality.SINGLE));
        put(WEIGHT,new StandardKeyInformation(Double.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.DEFAULT)));
        put(LOCATION,new StandardKeyInformation(Geoshape.class, Cardinality.SINGLE));
        put(NAME,new StandardKeyInformation(String.class, Cardinality.SINGLE, new Parameter("mapping",
                indexFeatures.supportsStringMapping(Mapping.STRING)?Mapping.STRING:Mapping.TEXTSTRING)));
        if(indexFeatures.supportsCardinality(Cardinality.LIST)) {
            put(PHONE_LIST, new StandardKeyInformation(String.class, Cardinality.LIST, new Parameter("mapping",
                    indexFeatures.supportsStringMapping(Mapping.STRING) ? Mapping.STRING : Mapping.TEXTSTRING)));
        }
        if(indexFeatures.supportsCardinality(Cardinality.SET)) {
            put(PHONE_SET, new StandardKeyInformation(String.class, Cardinality.SET, new Parameter("mapping",
                    indexFeatures.supportsStringMapping(Mapping.STRING) ? Mapping.STRING : Mapping.TEXTSTRING)));
        }
        put(DATE,new StandardKeyInformation(Instant.class, Cardinality.SINGLE));
    }};
}
 
Example 11
Project: titan1.0.1.kafka   File: TitanGraphTest.java   View source code 6 votes vote down vote up
@Test
public void testTinkerPopCardinality() {
    PropertyKey id = mgmt.makePropertyKey("id").cardinality(Cardinality.SINGLE).dataType(Integer.class).make();
    PropertyKey name = mgmt.makePropertyKey("name").cardinality(Cardinality.SINGLE).dataType(String.class).make();
    PropertyKey names = mgmt.makePropertyKey("names").cardinality(Cardinality.LIST).dataType(String.class).make();

    mgmt.buildIndex("byId", Vertex.class).addKey(id).buildCompositeIndex();

    finishSchema();
    GraphTraversalSource gts;
    Vertex v;

    v = graph.addVertex("id", 1);
    v.property(single, "name", "t1");
    graph.addVertex("id", 2, "names", "n1", "names", "n2");
    graph.tx().commit();

    gts = graph.traversal();
    v = gts.V().has("id", 1).next();
    v.property(single, "name", "t2");
    v = gts.V().has("id", 1).next();
    v.property(single, "name", "t3");
    assertCount(1, gts.V(v).properties("name"));
    assertCount(2, gts.V().has("id", 2).properties("names"));
    assertCount(2, gts.V().hasLabel("vertex"));
}
 
Example 12
Project: titan1.0.1.kafka   File: TestCoreElements.java   View source code 6 votes vote down vote up
@Test
public void testMultiplicityCardinality() {
    assertEquals(Multiplicity.MULTI,Multiplicity.convert(Cardinality.LIST));
    assertEquals(Multiplicity.SIMPLE,Multiplicity.convert(Cardinality.SET));
    assertEquals(Multiplicity.MANY2ONE,Multiplicity.convert(Cardinality.SINGLE));

    assertEquals(Multiplicity.MULTI.getCardinality(),Cardinality.LIST);
    assertEquals(Multiplicity.SIMPLE.getCardinality(),Cardinality.SET);
    assertEquals(Multiplicity.MANY2ONE.getCardinality(),Cardinality.SINGLE);

    assertFalse(Multiplicity.MULTI.isConstrained());
    assertTrue(Multiplicity.SIMPLE.isConstrained());
    assertTrue(Multiplicity.ONE2ONE.isConstrained());

    assertTrue(Multiplicity.ONE2ONE.isConstrained(Direction.BOTH));
    assertTrue(Multiplicity.SIMPLE.isConstrained(Direction.BOTH));

    assertFalse(Multiplicity.MULTI.isUnique(Direction.OUT));
    assertTrue(Multiplicity.MANY2ONE.isUnique(Direction.OUT));
}
 
Example 13
Project: titan1.0.1.kafka   File: ElasticSearchIndexTest.java   View source code 6 votes vote down vote up
@Test
public void testSupport() {
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE), Text.CONTAINS));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Text.CONTAINS_PREFIX));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Text.CONTAINS_REGEX));
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Text.REGEX));
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.STRING)), Text.CONTAINS));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.STRING)), Text.PREFIX));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.STRING)), Text.REGEX));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.STRING)), Cmp.EQUAL));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.STRING)), Cmp.NOT_EQUAL));

    assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.EQUAL));
    assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.LESS_THAN_EQUAL));
    assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.LESS_THAN));
    assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.GREATER_THAN));
    assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.GREATER_THAN_EQUAL));
    assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.NOT_EQUAL));

    assertTrue(index.supports(of(Boolean.class, Cardinality.SINGLE), Cmp.EQUAL));
    assertTrue(index.supports(of(Boolean.class, Cardinality.SINGLE), Cmp.NOT_EQUAL));

    assertTrue(index.supports(of(UUID.class, Cardinality.SINGLE), Cmp.EQUAL));
    assertTrue(index.supports(of(UUID.class, Cardinality.SINGLE), Cmp.NOT_EQUAL));
}
 
Example 14
Project: titan1.0.1.kafka   File: ManagementSystem.java   View source code 6 votes vote down vote up
private TitanGraphIndex createMixedIndex(String indexName, ElementCategory elementCategory,
                                         TitanSchemaType constraint, String backingIndex) {
    Preconditions.checkArgument(graph.getIndexSerializer().containsIndex(backingIndex), "Unknown external index backend: %s", backingIndex);
    checkIndexName(indexName);

    TypeDefinitionMap def = new TypeDefinitionMap();
    def.setValue(TypeDefinitionCategory.INTERNAL_INDEX, false);
    def.setValue(TypeDefinitionCategory.ELEMENT_CATEGORY, elementCategory);
    def.setValue(TypeDefinitionCategory.BACKING_INDEX, backingIndex);
    def.setValue(TypeDefinitionCategory.INDEXSTORE_NAME, indexName);
    def.setValue(TypeDefinitionCategory.INDEX_CARDINALITY, Cardinality.LIST);
    def.setValue(TypeDefinitionCategory.STATUS, SchemaStatus.ENABLED);
    TitanSchemaVertex indexVertex = transaction.makeSchemaVertex(TitanSchemaCategory.GRAPHINDEX, indexName, def);

    Preconditions.checkArgument(constraint == null || (elementCategory.isValidConstraint(constraint) && constraint instanceof TitanSchemaVertex));
    if (constraint != null) {
        addSchemaEdge(indexVertex, (TitanSchemaVertex) constraint, TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT, null);
    }
    updateSchemaVertex(indexVertex);
    return new TitanGraphIndexWrapper(indexVertex.asIndexType());
}
 
Example 15
Project: titan1withtp3.1   File: LuceneIndex.java   View source code 5 votes vote down vote up
@Override
public boolean supports(KeyInformation information, TitanPredicate titanPredicate) {
    if (information.getCardinality()!= Cardinality.SINGLE) return false;
    Class<?> dataType = information.getDataType();
    Mapping mapping = Mapping.getMapping(information);
    if (mapping!=Mapping.DEFAULT && !AttributeUtil.isString(dataType)) return false;

    if (Number.class.isAssignableFrom(dataType)) {
        if (titanPredicate instanceof Cmp) return true;
    } else if (dataType == Geoshape.class) {
        return titanPredicate == Geo.WITHIN;
    } else if (AttributeUtil.isString(dataType)) {
        switch(mapping) {
            case DEFAULT:
            case TEXT:
                return titanPredicate == Text.CONTAINS || titanPredicate == Text.CONTAINS_PREFIX; // || titanPredicate == Text.CONTAINS_REGEX;
            case STRING:
                return titanPredicate == Cmp.EQUAL || titanPredicate==Cmp.NOT_EQUAL || titanPredicate==Text.PREFIX || titanPredicate==Text.REGEX;
        }
    } else if (dataType == Date.class || dataType == Instant.class) {
        if (titanPredicate instanceof Cmp) return true;
    } else if (dataType == Boolean.class) {
        return titanPredicate == Cmp.EQUAL || titanPredicate == Cmp.NOT_EQUAL;
    } else if (dataType == UUID.class) {
        return titanPredicate == Cmp.EQUAL || titanPredicate == Cmp.NOT_EQUAL;
    }
    return false;
}
 
Example 16
Project: titan1withtp3.1   File: LuceneIndex.java   View source code 5 votes vote down vote up
@Override
public boolean supports(KeyInformation information) {
    if (information.getCardinality()!= Cardinality.SINGLE) return false;
    Class<?> dataType = information.getDataType();
    Mapping mapping = Mapping.getMapping(information);
    if (Number.class.isAssignableFrom(dataType) || dataType == Geoshape.class || dataType == Date.class || dataType == Instant.class || dataType == Boolean.class || dataType == UUID.class) {
        if (mapping==Mapping.DEFAULT) return true;
    } else if (AttributeUtil.isString(dataType)) {
        if (mapping==Mapping.DEFAULT || mapping==Mapping.STRING || mapping==Mapping.TEXT) return true;
    }
    return false;
}
 
Example 17
Project: titan1.0.1.kafka   File: SolrIndex.java   View source code 5 votes vote down vote up
@Override
    public boolean supports(KeyInformation information, TitanPredicate titanPredicate) {
        Class<?> dataType = information.getDataType();
        Mapping mapping = Mapping.getMapping(information);
        if (mapping!=Mapping.DEFAULT && !AttributeUtil.isString(dataType)) return false;

        if(information.getCardinality() != Cardinality.SINGLE) {
            return false;
        }

        if (Number.class.isAssignableFrom(dataType)) {
            return titanPredicate instanceof Cmp;
        } else if (dataType == Geoshape.class) {
            return titanPredicate == Geo.WITHIN;
        } else if (AttributeUtil.isString(dataType)) {
            switch(mapping) {
                case DEFAULT:
                case TEXT:
                    return titanPredicate == Text.CONTAINS || titanPredicate == Text.CONTAINS_PREFIX || titanPredicate == Text.CONTAINS_REGEX;
                case STRING:
                    return titanPredicate == Cmp.EQUAL || titanPredicate==Cmp.NOT_EQUAL || titanPredicate==Text.REGEX || titanPredicate==Text.PREFIX;
//                case TEXTSTRING:
//                    return (titanPredicate instanceof Text) || titanPredicate == Cmp.EQUAL || titanPredicate==Cmp.NOT_EQUAL;
            }
        } else if (dataType == Date.class || dataType == Instant.class) {
            if (titanPredicate instanceof Cmp) return true;
        } else if (dataType == Boolean.class) {
            return titanPredicate == Cmp.EQUAL || titanPredicate == Cmp.NOT_EQUAL;
        } else if (dataType == UUID.class) {
            return titanPredicate == Cmp.EQUAL || titanPredicate==Cmp.NOT_EQUAL;
        }
        return false;
    }
 
Example 18
Project: titan1withtp3.1   File: TitanGraphTest.java   View source code 5 votes vote down vote up
/**
 * This test exercises different types of updates against cardinality restricted properties
 * to ensure that the resulting behavior is fully consistent.
 */
@Test
public void testPropertyCardinality() {
    PropertyKey uid = mgmt.makePropertyKey("uid").dataType(Long.class).cardinality(Cardinality.SINGLE).make();
    PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
    mgmt.buildIndex("byUid", Vertex.class).addKey(uid).unique().buildCompositeIndex();
    mgmt.buildIndex("byName", Vertex.class).addKey(name).buildCompositeIndex();

    finishSchema();

    TitanVertex v1 = tx.addVertex();
    v1.property("name", "name1");
    TitanVertex v2 = tx.addVertex();
    v2.property("uid", 512);

    newTx();

    v1 = tx.getVertex(v1.longId());
    v1.property("name", "name2"); //Ensure that the old index record gets removed
    v2 = tx.getVertex(v2.longId());
    v2.property("uid", 512); //Ensure that replacement is allowed

    newTx();

    assertCount(0, tx.query().has("name", "name1").vertices());
    assertCount(1, tx.query().has("name", "name2").vertices());
    assertCount(1, tx.query().has("uid", 512).vertices());
}
 
Example 19
Project: titan1withtp3.1   File: CassandraInputFormatIT.java   View source code 5 votes vote down vote up
@Test
public void testReadWideVertexWithManyProperties() {
    int numProps = 1 << 16;

    long numV  = 1;
    mgmt.makePropertyKey("p").cardinality(Cardinality.LIST).dataType(Integer.class).make();
    mgmt.commit();
    finishSchema();

    for (int j = 0; j < numV; j++) {
        Vertex v = graph.addVertex();
        for (int i = 0; i < numProps; i++) {
            v.property("p", i);
        }
    }
    graph.tx().commit();

    assertEquals(numV, (long) graph.traversal().V().count().next());
    Map<String, Object> propertiesOnVertex = graph.traversal().V().valueMap().next();
    List<?> valuesOnP = (List)propertiesOnVertex.values().iterator().next();
    assertEquals(numProps, valuesOnP.size());
    Graph g = GraphFactory.open("target/test-classes/cassandra-read.properties");
    GraphTraversalSource t = g.traversal(GraphTraversalSource.computer(SparkGraphComputer.class));
    assertEquals(numV, (long) t.V().count().next());
    propertiesOnVertex = t.V().valueMap().next();
    valuesOnP = (List)propertiesOnVertex.values().iterator().next();
    assertEquals(numProps, valuesOnP.size());
}
 
Example 20
Project: titan1withtp3.1   File: IndexFeatures.java   View source code 5 votes vote down vote up
public IndexFeatures(boolean supportsDocumentTTL,
                     Mapping defaultMap,
                     ImmutableSet<Mapping> supportedMap, String wildcardField, ImmutableSet<Cardinality> supportedCardinaities, boolean supportsNanoseconds) {

    Preconditions.checkArgument(defaultMap!=null || defaultMap!=Mapping.DEFAULT);
    Preconditions.checkArgument(supportedMap!=null && !supportedMap.isEmpty()
                                && supportedMap.contains(defaultMap));
    this.supportsDocumentTTL = supportsDocumentTTL;
    this.defaultStringMapping = defaultMap;
    this.supportedStringMappings = supportedMap;
    this.wildcardField = wildcardField;
    this.supportedCardinaities = supportedCardinaities;
    this.supportsNanoseconds = supportsNanoseconds;
}
 
Example 21
Project: titan1withtp3.1   File: StandardKeyInformation.java   View source code 5 votes vote down vote up
public StandardKeyInformation(Class<?> dataType, Cardinality cardinality, Parameter... parameters) {
    Preconditions.checkNotNull(dataType);
    Preconditions.checkNotNull(parameters);
    this.dataType = dataType;
    this.parameters = parameters;
    this.cardinality = cardinality;
}
 
Example 22
Project: titan1withtp3.1   File: BaseVertexCentricQueryBuilder.java   View source code 5 votes vote down vote up
@Override
public Q orderBy(String keyName, org.apache.tinkerpop.gremlin.process.traversal.Order order) {
    Preconditions.checkArgument(schemaInspector.containsPropertyKey(keyName), "Provided key does not exist: %s", keyName);
    PropertyKey key = schemaInspector.getPropertyKey(keyName);
    Preconditions.checkArgument(key != null && order != null, "Need to specify and key and an order");
    Preconditions.checkArgument(Comparable.class.isAssignableFrom(key.dataType()),
            "Can only order on keys with comparable data type. [%s] has datatype [%s]", key.name(), key.dataType());
    Preconditions.checkArgument(key.cardinality() == Cardinality.SINGLE, "Ordering is undefined on multi-valued key [%s]", key.name());
    Preconditions.checkArgument(!(key instanceof SystemRelationType), "Cannot use system types in ordering: %s", key);
    Preconditions.checkArgument(!orders.containsKey(key));
    Preconditions.checkArgument(orders.isEmpty(), "Only a single sort order is supported on vertex queries");
    orders.add(key, Order.convert(order));
    return getThis();
}
 
Example 23
Project: titan0.5.4-hbase1.1.1-custom   File: TitanGraphQueryTestSuite.java   View source code 5 votes vote down vote up
@Override
public void testGraphQueryForEdges() {
    TitanGraph g = (TitanGraph) graphTest.generateGraph();
    if (g.getRelationType("weight") == null) {
        TitanManagement mgmt = g.getManagementSystem();
        mgmt.makePropertyKey("weight").dataType(Double.class).cardinality(Cardinality.SINGLE).make();
        mgmt.commit();
    }
    g.shutdown();
    super.testGraphQueryForEdges();
}
 
Example 24
Project: titan1withtp3.1   File: ManagementSystem.java   View source code 5 votes vote down vote up
private TitanGraphIndex createCompositeIndex(String indexName, ElementCategory elementCategory, boolean unique, TitanSchemaType constraint, PropertyKey... keys) {
    checkIndexName(indexName);
    Preconditions.checkArgument(keys != null && keys.length > 0, "Need to provide keys to index [%s]", indexName);
    Preconditions.checkArgument(!unique || elementCategory == ElementCategory.VERTEX, "Unique indexes can only be created on vertices [%s]", indexName);
    boolean allSingleKeys = true;
    boolean oneNewKey = false;
    for (PropertyKey key : keys) {
        Preconditions.checkArgument(key != null && key instanceof PropertyKeyVertex, "Need to provide valid keys: %s", key);
        if (key.cardinality() != Cardinality.SINGLE) allSingleKeys = false;
        if (key.isNew()) oneNewKey = true;
        else updatedTypes.add((PropertyKeyVertex) key);
    }

    Cardinality indexCardinality;
    if (unique) indexCardinality = Cardinality.SINGLE;
    else indexCardinality = (allSingleKeys ? Cardinality.SET : Cardinality.LIST);

    TypeDefinitionMap def = new TypeDefinitionMap();
    def.setValue(TypeDefinitionCategory.INTERNAL_INDEX, true);
    def.setValue(TypeDefinitionCategory.ELEMENT_CATEGORY, elementCategory);
    def.setValue(TypeDefinitionCategory.BACKING_INDEX, Token.INTERNAL_INDEX_NAME);
    def.setValue(TypeDefinitionCategory.INDEXSTORE_NAME, indexName);
    def.setValue(TypeDefinitionCategory.INDEX_CARDINALITY, indexCardinality);
    def.setValue(TypeDefinitionCategory.STATUS, oneNewKey ? SchemaStatus.ENABLED : SchemaStatus.INSTALLED);
    TitanSchemaVertex indexVertex = transaction.makeSchemaVertex(TitanSchemaCategory.GRAPHINDEX, indexName, def);
    for (int i = 0; i < keys.length; i++) {
        Parameter[] paras = {ParameterType.INDEX_POSITION.getParameter(i)};
        addSchemaEdge(indexVertex, keys[i], TypeDefinitionCategory.INDEX_FIELD, paras);
    }

    Preconditions.checkArgument(constraint == null || (elementCategory.isValidConstraint(constraint) && constraint instanceof TitanSchemaVertex));
    if (constraint != null) {
        addSchemaEdge(indexVertex, (TitanSchemaVertex) constraint, TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT, null);
    }
    updateSchemaVertex(indexVertex);
    TitanGraphIndexWrapper index = new TitanGraphIndexWrapper(indexVertex.asIndexType());
    if (!oneNewKey) updateIndex(index, SchemaAction.REGISTER_INDEX);
    return index;
}
 
Example 25
Project: titan1withtp3.1   File: BaseKey.java   View source code 5 votes vote down vote up
private BaseKey(String name, Class<?> dataType, int id, Index index, Cardinality cardinality) {
    super(name, id, TitanSchemaCategory.PROPERTYKEY);
    Preconditions.checkArgument(index!=null && cardinality!=null);
    this.dataType = dataType;
    this.index = index;
    this.cardinality = cardinality;
}
 
Example 26
Project: titan1withtp3.1   File: HasStepFolder.java   View source code 5 votes vote down vote up
public static boolean validTitanOrder(OrderGlobalStep ostep, Traversal rootTraversal,
                                      boolean isVertexOrder) {
    for (Comparator comp : (List<Comparator>) ostep.getComparators()) {
        if (!(comp instanceof ElementValueComparator)) return false;
        ElementValueComparator evc = (ElementValueComparator) comp;
        if (!(evc.getValueComparator() instanceof Order)) return false;

        TitanTransaction tx = TitanTraversalUtil.getTx(rootTraversal.asAdmin());
        String key = evc.getPropertyKey();
        PropertyKey pkey = tx.getPropertyKey(key);
        if (pkey == null || !(Comparable.class.isAssignableFrom(pkey.dataType()))) return false;
        if (isVertexOrder && pkey.cardinality() != Cardinality.SINGLE) return false;
    }
    return true;
}
 
Example 27
Project: titan1withtp3.1   File: SolrIndex.java   View source code 5 votes vote down vote up
@Override
    public boolean supports(KeyInformation information, TitanPredicate titanPredicate) {
        Class<?> dataType = information.getDataType();
        Mapping mapping = Mapping.getMapping(information);
        if (mapping!=Mapping.DEFAULT && !AttributeUtil.isString(dataType)) return false;

        if(information.getCardinality() != Cardinality.SINGLE) {
            return false;
        }

        if (Number.class.isAssignableFrom(dataType)) {
            return titanPredicate instanceof Cmp;
        } else if (dataType == Geoshape.class) {
            return titanPredicate == Geo.WITHIN;
        } else if (AttributeUtil.isString(dataType)) {
            switch(mapping) {
                case DEFAULT:
                case TEXT:
                    return titanPredicate == Text.CONTAINS || titanPredicate == Text.CONTAINS_PREFIX || titanPredicate == Text.CONTAINS_REGEX;
                case STRING:
                    return titanPredicate == Cmp.EQUAL || titanPredicate==Cmp.NOT_EQUAL || titanPredicate==Text.REGEX || titanPredicate==Text.PREFIX;
//                case TEXTSTRING:
//                    return (titanPredicate instanceof Text) || titanPredicate == Cmp.EQUAL || titanPredicate==Cmp.NOT_EQUAL;
            }
        } else if (dataType == Date.class || dataType == Instant.class) {
            if (titanPredicate instanceof Cmp) return true;
        } else if (dataType == Boolean.class) {
            return titanPredicate == Cmp.EQUAL || titanPredicate == Cmp.NOT_EQUAL;
        } else if (dataType == UUID.class) {
            return titanPredicate == Cmp.EQUAL || titanPredicate==Cmp.NOT_EQUAL;
        }
        return false;
    }
 
Example 28
Project: titan1withtp3.1   File: SolrIndex.java   View source code 5 votes vote down vote up
@Override
public boolean supports(KeyInformation information) {
    if(information.getCardinality() != Cardinality.SINGLE) {
        return false;
    }
    Class<?> dataType = information.getDataType();
    Mapping mapping = Mapping.getMapping(information);
    if (Number.class.isAssignableFrom(dataType) || dataType == Geoshape.class || dataType == Date.class || dataType == Instant.class || dataType == Boolean.class || dataType == UUID.class) {
        if (mapping==Mapping.DEFAULT) return true;
    } else if (AttributeUtil.isString(dataType)) {
        if (mapping==Mapping.DEFAULT || mapping==Mapping.TEXT || mapping==Mapping.STRING) return true;
    }
    return false;
}
 
Example 29
Project: incubator-atlas   File: TitanObjectFactory.java   View source code 5 votes vote down vote up
/**
 * Converts a Multiplicity to a Cardinality.
 *
 * @param multiplicity
 * @return
 */
public static Cardinality createCardinality(AtlasCardinality cardinality) {
    switch(cardinality) {

    case SINGLE:
        return Cardinality.SINGLE;
    case LIST:
        return Cardinality.LIST;
    case SET:
        return Cardinality.SET;
    default:
        throw new IllegalStateException("Unrecognized cardinality: " + cardinality);
    }
}
 
Example 30
Project: incubator-atlas   File: GraphDbObjectFactory.java   View source code 5 votes vote down vote up
/**
 * Converts a Multiplicity to a Cardinality.
 *
 * @param cardinality
 * @return
 */
public static AtlasCardinality createCardinality(Cardinality cardinality) {

    if (cardinality == Cardinality.SINGLE) {
        return AtlasCardinality.SINGLE;
    } else if (cardinality == Cardinality.LIST) {
        return AtlasCardinality.LIST;
    }
    return AtlasCardinality.SET;
}
 
Example 31
Project: incubator-atlas   File: GraphDbObjectFactory.java   View source code 5 votes vote down vote up
/**
 * Converts a Multiplicity to a Cardinality.
 *
 * @param cardinality
 * @return
 */
public static AtlasCardinality createCardinality(Cardinality cardinality) {

    if (cardinality == Cardinality.SINGLE) {
        return AtlasCardinality.SINGLE;
    } else if (cardinality == Cardinality.LIST) {
        return AtlasCardinality.LIST;
    }
    return AtlasCardinality.SET;
}
 
Example 32
Project: titan1.0.1.kafka   File: IndexProviderTest.java   View source code 5 votes vote down vote up
@Test
public void testCommonSupport() {
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE)));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT))));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.STRING))));

    assertTrue(index.supports(of(Double.class, Cardinality.SINGLE)));
    assertFalse(index.supports(of(Double.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.TEXT))));

    assertTrue(index.supports(of(Long.class, Cardinality.SINGLE)));
    assertTrue(index.supports(of(Long.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.DEFAULT))));
    assertTrue(index.supports(of(Integer.class, Cardinality.SINGLE)));
    assertTrue(index.supports(of(Short.class, Cardinality.SINGLE)));
    assertTrue(index.supports(of(Byte.class, Cardinality.SINGLE)));
    assertTrue(index.supports(of(Float.class, Cardinality.SINGLE)));
    assertTrue(index.supports(of(Geoshape.class, Cardinality.SINGLE)));
    assertFalse(index.supports(of(Object.class, Cardinality.SINGLE)));
    assertFalse(index.supports(of(Exception.class, Cardinality.SINGLE)));

    assertTrue(index.supports(of(Double.class, Cardinality.SINGLE), Cmp.EQUAL));
    assertTrue(index.supports(of(Double.class, Cardinality.SINGLE), Cmp.GREATER_THAN_EQUAL));
    assertTrue(index.supports(of(Double.class, Cardinality.SINGLE), Cmp.LESS_THAN));
    assertTrue(index.supports(of(Double.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.DEFAULT)), Cmp.LESS_THAN));
    assertFalse(index.supports(of(Double.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.TEXT)), Cmp.LESS_THAN));
    assertTrue(index.supports(of(Geoshape.class, Cardinality.SINGLE), Geo.WITHIN));

    assertFalse(index.supports(of(Double.class, Cardinality.SINGLE), Geo.INTERSECT));
    assertFalse(index.supports(of(Long.class, Cardinality.SINGLE), Text.CONTAINS));
    assertFalse(index.supports(of(Geoshape.class, Cardinality.SINGLE), Geo.DISJOINT));
}
 
Example 33
Project: titan1.0.1.kafka   File: TitanGraphTest.java   View source code 5 votes vote down vote up
/**
 * This test exercises different types of updates against cardinality restricted properties
 * to ensure that the resulting behavior is fully consistent.
 */
@Test
public void testPropertyCardinality() {
    PropertyKey uid = mgmt.makePropertyKey("uid").dataType(Long.class).cardinality(Cardinality.SINGLE).make();
    PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
    mgmt.buildIndex("byUid", Vertex.class).addKey(uid).unique().buildCompositeIndex();
    mgmt.buildIndex("byName", Vertex.class).addKey(name).buildCompositeIndex();

    finishSchema();

    TitanVertex v1 = tx.addVertex();
    v1.property("name", "name1");
    TitanVertex v2 = tx.addVertex();
    v2.property("uid", 512);

    newTx();

    v1 = tx.getVertex(v1.longId());
    v1.property("name", "name2"); //Ensure that the old index record gets removed
    v2 = tx.getVertex(v2.longId());
    v2.property("uid", 512); //Ensure that replacement is allowed

    newTx();

    assertCount(0, tx.query().has("name", "name1").vertices());
    assertCount(1, tx.query().has("name", "name2").vertices());
    assertCount(1, tx.query().has("uid", 512).vertices());
}
 
Example 34
Project: titan1.0.1.kafka   File: CassandraInputFormatIT.java   View source code 5 votes vote down vote up
@Test
public void testReadWideVertexWithManyProperties() {
    int numProps = 1 << 16;

    long numV  = 1;
    mgmt.makePropertyKey("p").cardinality(Cardinality.LIST).dataType(Integer.class).make();
    mgmt.commit();
    finishSchema();

    for (int j = 0; j < numV; j++) {
        Vertex v = graph.addVertex();
        for (int i = 0; i < numProps; i++) {
            v.property("p", i);
        }
    }
    graph.tx().commit();

    assertEquals(numV, (long) graph.traversal().V().count().next());
    Map<String, Object> propertiesOnVertex = graph.traversal().V().valueMap().next();
    List<?> valuesOnP = (List)propertiesOnVertex.values().iterator().next();
    assertEquals(numProps, valuesOnP.size());
    Graph g = GraphFactory.open("target/test-classes/cassandra-read.properties");
    GraphTraversalSource t = g.traversal(GraphTraversalSource.computer(SparkGraphComputer.class));
    assertEquals(numV, (long) t.V().count().next());
    propertiesOnVertex = t.V().valueMap().next();
    valuesOnP = (List)propertiesOnVertex.values().iterator().next();
    assertEquals(numProps, valuesOnP.size());
}
 
Example 35
Project: titan0.5.4-hbase1.1.1-custom   File: BaseKey.java   View source code 5 votes vote down vote up
private BaseKey(String name, Class<?> dataType, int id, Index index, Cardinality cardinality) {
    super(name, id, TitanSchemaCategory.PROPERTYKEY);
    Preconditions.checkArgument(index!=null && cardinality!=null);
    this.dataType = dataType;
    this.index = index;
    this.cardinality = cardinality;
}
 
Example 36
Project: titan0.5.4-hbase1.1.1-custom   File: StandardKeyInformation.java   View source code 5 votes vote down vote up
public StandardKeyInformation(Class<?> dataType, Parameter... parameters) {
    Preconditions.checkNotNull(dataType);
    Preconditions.checkNotNull(parameters);
    this.dataType = dataType;
    this.parameters = parameters;
    this.cardinality = Cardinality.SINGLE;
}
 
Example 37
Project: titan0.5.4-hbase1.1.1-custom   File: LuceneIndex.java   View source code 5 votes vote down vote up
@Override
public boolean supports(KeyInformation information) {
    if (information.getCardinality()!= Cardinality.SINGLE) return false;
    Class<?> dataType = information.getDataType();
    Mapping mapping = Mapping.getMapping(information);
    if (Number.class.isAssignableFrom(dataType) || dataType == Geoshape.class) {
        if (mapping==Mapping.DEFAULT) return true;
    } else if (AttributeUtil.isString(dataType)) {
        if (mapping==Mapping.DEFAULT || mapping==Mapping.STRING || mapping==Mapping.TEXT) return true;
    }
    return false;
}
 
Example 38
Project: titan1.0.1.kafka   File: BaseVertexCentricQueryBuilder.java   View source code 5 votes vote down vote up
@Override
public Q orderBy(String keyName, org.apache.tinkerpop.gremlin.process.traversal.Order order) {
    Preconditions.checkArgument(schemaInspector.containsPropertyKey(keyName), "Provided key does not exist: %s", keyName);
    PropertyKey key = schemaInspector.getPropertyKey(keyName);
    Preconditions.checkArgument(key != null && order != null, "Need to specify and key and an order");
    Preconditions.checkArgument(Comparable.class.isAssignableFrom(key.dataType()),
            "Can only order on keys with comparable data type. [%s] has datatype [%s]", key.name(), key.dataType());
    Preconditions.checkArgument(key.cardinality() == Cardinality.SINGLE, "Ordering is undefined on multi-valued key [%s]", key.name());
    Preconditions.checkArgument(!(key instanceof SystemRelationType), "Cannot use system types in ordering: %s", key);
    Preconditions.checkArgument(!orders.containsKey(key));
    Preconditions.checkArgument(orders.isEmpty(), "Only a single sort order is supported on vertex queries");
    orders.add(key, Order.convert(order));
    return getThis();
}
 
Example 39
Project: titan1.0.1.kafka   File: ManagementSystem.java   View source code 5 votes vote down vote up
private TitanGraphIndex createCompositeIndex(String indexName, ElementCategory elementCategory, boolean unique, TitanSchemaType constraint, PropertyKey... keys) {
    checkIndexName(indexName);
    Preconditions.checkArgument(keys != null && keys.length > 0, "Need to provide keys to index [%s]", indexName);
    Preconditions.checkArgument(!unique || elementCategory == ElementCategory.VERTEX, "Unique indexes can only be created on vertices [%s]", indexName);
    boolean allSingleKeys = true;
    boolean oneNewKey = false;
    for (PropertyKey key : keys) {
        Preconditions.checkArgument(key != null && key instanceof PropertyKeyVertex, "Need to provide valid keys: %s", key);
        if (key.cardinality() != Cardinality.SINGLE) allSingleKeys = false;
        if (key.isNew()) oneNewKey = true;
        else updatedTypes.add((PropertyKeyVertex) key);
    }

    Cardinality indexCardinality;
    if (unique) indexCardinality = Cardinality.SINGLE;
    else indexCardinality = (allSingleKeys ? Cardinality.SET : Cardinality.LIST);

    TypeDefinitionMap def = new TypeDefinitionMap();
    def.setValue(TypeDefinitionCategory.INTERNAL_INDEX, true);
    def.setValue(TypeDefinitionCategory.ELEMENT_CATEGORY, elementCategory);
    def.setValue(TypeDefinitionCategory.BACKING_INDEX, Token.INTERNAL_INDEX_NAME);
    def.setValue(TypeDefinitionCategory.INDEXSTORE_NAME, indexName);
    def.setValue(TypeDefinitionCategory.INDEX_CARDINALITY, indexCardinality);
    def.setValue(TypeDefinitionCategory.STATUS, oneNewKey ? SchemaStatus.ENABLED : SchemaStatus.INSTALLED);
    TitanSchemaVertex indexVertex = transaction.makeSchemaVertex(TitanSchemaCategory.GRAPHINDEX, indexName, def);
    for (int i = 0; i < keys.length; i++) {
        Parameter[] paras = {ParameterType.INDEX_POSITION.getParameter(i)};
        addSchemaEdge(indexVertex, keys[i], TypeDefinitionCategory.INDEX_FIELD, paras);
    }

    Preconditions.checkArgument(constraint == null || (elementCategory.isValidConstraint(constraint) && constraint instanceof TitanSchemaVertex));
    if (constraint != null) {
        addSchemaEdge(indexVertex, (TitanSchemaVertex) constraint, TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT, null);
    }
    updateSchemaVertex(indexVertex);
    TitanGraphIndexWrapper index = new TitanGraphIndexWrapper(indexVertex.asIndexType());
    if (!oneNewKey) updateIndex(index, SchemaAction.REGISTER_INDEX);
    return index;
}
 
Example 40
Project: titan1.0.1.kafka   File: BaseKey.java   View source code 5 votes vote down vote up
private BaseKey(String name, Class<?> dataType, int id, Index index, Cardinality cardinality) {
    super(name, id, TitanSchemaCategory.PROPERTYKEY);
    Preconditions.checkArgument(index!=null && cardinality!=null);
    this.dataType = dataType;
    this.index = index;
    this.cardinality = cardinality;
}