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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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 41
Project: peapod   File: TitanSuite.java   Source Code and License 5 votes vote down vote up
@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 42
Project: titan1.0.1.kafka   File: HasStepFolder.java   Source Code and License 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 43
Project: titan1withtp3.1   File: LuceneIndexTest.java   Source Code and License 4 votes vote down vote up
@Test
public void testSupport() {
    // DEFAULT(=TEXT) support
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE), Text.CONTAINS));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE), Text.CONTAINS_PREFIX));
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE), Text.CONTAINS_REGEX)); // TODO Not supported yet
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE), Text.REGEX));
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE), Text.PREFIX));
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE), Cmp.EQUAL));
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE), Cmp.NOT_EQUAL));

    // Same tests as above, except explicitly specifying TEXT instead of relying on DEFAULT
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Text.CONTAINS));
    assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Text.CONTAINS_PREFIX));
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Text.CONTAINS_REGEX)); // TODO Not supported yet
    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.TEXT)), Text.PREFIX));
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Cmp.EQUAL));
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Cmp.NOT_EQUAL));

    // STRING support
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.STRING)), Text.CONTAINS));
    assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.STRING)), Text.CONTAINS_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)), Text.PREFIX));
    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 44
Project: titan1withtp3.1   File: IndexProviderTest.java   Source Code and License 4 votes vote down vote up
public static StandardKeyInformation of(Class<?> clazz, Cardinality cardinality,  Parameter... paras) {
    return new StandardKeyInformation(clazz, cardinality, paras);
}
 
Example 45
Project: titan1withtp3.1   File: TitanGraphTest.java   Source Code and License 4 votes vote down vote up
@Test
public void testSchemaNameChange() {
    PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
    EdgeLabel knows = mgmt.makeEdgeLabel("knows").multiplicity(Multiplicity.MULTI).make();
    mgmt.buildEdgeIndex(knows, "byTime", Direction.BOTH, time);
    mgmt.buildIndex("timeIndex", Vertex.class).addKey(time).buildCompositeIndex();
    mgmt.makeVertexLabel("people").make();
    finishSchema();

    //CREATE SMALL GRAPH
    TitanVertex v = tx.addVertex("people");
    v.property(VertexProperty.Cardinality.single, "time", 5);
    v.addEdge("knows", v, "time", 11);

    newTx();
    v = getOnlyElement(tx.query().has("time", 5).vertices());
    assertNotNull(v);
    assertEquals("people", v.label());
    assertEquals(5, v.<Integer>value("time").intValue());
    assertCount(1, v.query().direction(Direction.IN).labels("knows").edges());
    assertCount(1, v.query().direction(Direction.OUT).labels("knows").has("time", 11).edges());
    newTx();

    //UPDATE SCHEMA NAMES

    assertTrue(mgmt.containsRelationType("knows"));
    knows = mgmt.getEdgeLabel("knows");
    mgmt.changeName(knows, "know");
    assertEquals("know", knows.name());

    assertTrue(mgmt.containsRelationIndex(knows, "byTime"));
    RelationTypeIndex rindex = mgmt.getRelationIndex(knows, "byTime");
    assertEquals("byTime", rindex.name());
    mgmt.changeName(rindex, "overTime");
    assertEquals("overTime", rindex.name());

    assertTrue(mgmt.containsVertexLabel("people"));
    VertexLabel vl = mgmt.getVertexLabel("people");
    mgmt.changeName(vl, "person");
    assertEquals("person", vl.name());

    assertTrue(mgmt.containsGraphIndex("timeIndex"));
    TitanGraphIndex gindex = mgmt.getGraphIndex("timeIndex");
    mgmt.changeName(gindex, "byTime");
    assertEquals("byTime", gindex.name());

    finishSchema();

    //VERIFY UPDATES IN MGMT SYSTEM

    assertTrue(mgmt.containsRelationType("know"));
    assertFalse(mgmt.containsRelationType("knows"));
    knows = mgmt.getEdgeLabel("know");

    assertTrue(mgmt.containsRelationIndex(knows, "overTime"));
    assertFalse(mgmt.containsRelationIndex(knows, "byTime"));

    assertTrue(mgmt.containsVertexLabel("person"));
    assertFalse(mgmt.containsVertexLabel("people"));

    assertTrue(mgmt.containsGraphIndex("byTime"));
    assertFalse(mgmt.containsGraphIndex("timeIndex"));

    //VERIFY UPDATES IN TRANSACTION
    newTx();
    v = getOnlyElement(tx.query().has("time", 5).vertices());
    assertNotNull(v);
    assertEquals("person", v.label());
    assertEquals(5, v.<Integer>value("time").intValue());
    assertCount(1, v.query().direction(Direction.IN).labels("know").edges());
    assertCount(0, v.query().direction(Direction.IN).labels("knows").edges());
    assertCount(1, v.query().direction(Direction.OUT).labels("know").has("time", 11).edges());
}
 
Example 46
Project: titan1withtp3.1   File: TitanIndexTest.java   Source Code and License 4 votes vote down vote up
@Test
public void testDualMapping() {
    if (!indexFeatures.supportsStringMapping(Mapping.TEXTSTRING)) return;

    PropertyKey name = makeKey("name", String.class);
    TitanGraphIndex mixed = mgmt.buildIndex("mixed", Vertex.class).addKey(name, Mapping.TEXTSTRING.asParameter()).buildMixedIndex(INDEX);
    mixed.name();
    finishSchema();


    tx.addVertex("name", "Long John Don");
    tx.addVertex("name", "Long Little Lewis");
    tx.addVertex("name", "Middle Sister Mabel");

    clopen();
    evaluateQuery(tx.query().has("name", Cmp.EQUAL, "Long John Don"), ElementCategory.VERTEX,
            1, new boolean[]{true, true}, "mixed");
    evaluateQuery(tx.query().has("name", Text.CONTAINS, "Long"), ElementCategory.VERTEX,
            2, new boolean[]{true, true}, "mixed");
    evaluateQuery(tx.query().has("name", Text.CONTAINS, "Long Don"), ElementCategory.VERTEX,
            1, new boolean[]{true, true}, "mixed");
    evaluateQuery(tx.query().has("name", Text.CONTAINS_PREFIX, "Lon"), ElementCategory.VERTEX,
            2, new boolean[]{true, true}, "mixed");
    evaluateQuery(tx.query().has("name", Text.CONTAINS_REGEX, "Lit*le"), ElementCategory.VERTEX,
            1, new boolean[]{true, true}, "mixed");
    evaluateQuery(tx.query().has("name", Text.REGEX, "Long.*"), ElementCategory.VERTEX,
            2, new boolean[]{true, true}, "mixed");
    evaluateQuery(tx.query().has("name", Text.PREFIX, "Middle"), ElementCategory.VERTEX,
            1, new boolean[]{true, true}, "mixed");

    for (Vertex u : tx.getVertices()) {
        String n = u.<String>value("name");
        if (n.endsWith("Don")) {
            u.remove();
        } else if (n.endsWith("Lewis")) {
            u.property(VertexProperty.Cardinality.single, "name", "Big Brother Bob");
        } else if (n.endsWith("Mabel")) {
            u.property("name").remove();
        }
    }

    clopen();

    evaluateQuery(tx.query().has("name", Text.CONTAINS, "Long"), ElementCategory.VERTEX,
            0, new boolean[]{true, true}, "mixed");
    evaluateQuery(tx.query().has("name", Text.CONTAINS, "Big"), ElementCategory.VERTEX,
            1, new boolean[]{true, true}, "mixed");
    evaluateQuery(tx.query().has("name", Text.PREFIX, "Big"), ElementCategory.VERTEX,
            1, new boolean[]{true, true}, "mixed");
    evaluateQuery(tx.query().has("name", Text.PREFIX, "Middle"), ElementCategory.VERTEX,
            0, new boolean[]{true, true}, "mixed");

}
 
Example 47
Project: titan1withtp3.1   File: TitanIndexTest.java   Source Code and License 4 votes vote down vote up
@Category({BrittleTests.class})
    @Test
    public void testIndexReplay() throws Exception {
        final TimestampProvider times = graph.getConfiguration().getTimestampProvider();
        final Instant startTime = times.getTime();
        clopen(option(SYSTEM_LOG_TRANSACTIONS), true
                , option(KCVSLog.LOG_READ_LAG_TIME, TRANSACTION_LOG), Duration.ofMillis(50)
                , option(LOG_READ_INTERVAL, TRANSACTION_LOG), Duration.ofMillis(250)
                , option(MAX_COMMIT_TIME), Duration.ofSeconds(1)
                , option(STORAGE_WRITE_WAITTIME), Duration.ofMillis(300)
                , option(TestMockIndexProvider.INDEX_BACKEND_PROXY, INDEX), readConfig.get(INDEX_BACKEND, INDEX)
                , option(INDEX_BACKEND, INDEX), TestMockIndexProvider.class.getName()
                , option(TestMockIndexProvider.INDEX_MOCK_FAILADD, INDEX), true
        );

        PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).make();
        PropertyKey age = mgmt.makePropertyKey("age").dataType(Integer.class).make();
        mgmt.buildIndex("mi", Vertex.class).addKey(name, getTextMapping()).addKey(age).buildMixedIndex(INDEX);
        finishSchema();
        Vertex vs[] = new TitanVertex[4];

        vs[0] = tx.addVertex("name", "Big Boy Bobson", "age", 55);
        newTx();
        vs[1] = tx.addVertex("name", "Long Little Lewis", "age", 35);
        vs[2] = tx.addVertex("name", "Tall Long Tiger", "age", 75);
        vs[3] = tx.addVertex("name", "Long John Don", "age", 15);
        newTx();
        vs[2] = getV(tx, vs[2]);
        vs[2].remove();
        vs[3] = getV(tx, vs[3]);
        vs[3].property(VertexProperty.Cardinality.single, "name", "Bad Boy Badsy");
        vs[3].property("age").remove();
        newTx();
        vs[0] = getV(tx, vs[0]);
        vs[0].property(VertexProperty.Cardinality.single, "age", 66);
        newTx();

        clopen();
        //Just to make sure nothing has been persisted to index
        evaluateQuery(tx.query().has("name", Text.CONTAINS, "boy"),
                ElementCategory.VERTEX, 0, new boolean[]{true, true}, "mi");
        /*
        Transaction Recovery
         */
        TransactionRecovery recovery = TitanFactory.startTransactionRecovery(graph, startTime);
        //wait
        Thread.sleep(12000L);

        recovery.shutdown();
        long[] recoveryStats = ((StandardTransactionLogProcessor) recovery).getStatistics();

        clopen();

        evaluateQuery(tx.query().has("name", Text.CONTAINS, "boy"),
                ElementCategory.VERTEX, 2, new boolean[]{true, true}, "mi");
        evaluateQuery(tx.query().has("name", Text.CONTAINS, "long"),
                ElementCategory.VERTEX, 1, new boolean[]{true, true}, "mi");
//        TitanVertex v = Iterables.getOnlyElement(tx.query().has("name",Text.CONTAINS,"long").vertices());
//        System.out.println(v.getProperty("age"));
        evaluateQuery(tx.query().has("name", Text.CONTAINS, "long").interval("age", 30, 40),
                ElementCategory.VERTEX, 1, new boolean[]{true, true}, "mi");
        evaluateQuery(tx.query().has("age", 75),
                ElementCategory.VERTEX, 0, new boolean[]{true, true}, "mi");
        evaluateQuery(tx.query().has("name", Text.CONTAINS, "boy").interval("age", 60, 70),
                ElementCategory.VERTEX, 1, new boolean[]{true, true}, "mi");
        evaluateQuery(tx.query().interval("age", 0, 100),
                ElementCategory.VERTEX, 2, new boolean[]{true, true}, "mi");


        assertEquals(1, recoveryStats[0]); //schema transaction was successful
        assertEquals(4, recoveryStats[1]); //all 4 index transaction had provoked errors in the indexing backend
    }
 
Example 48
Project: titan1withtp3.1   File: TitanIndexTest.java   Source Code and License 4 votes vote down vote up
@Test
public void testVertexTTLWithMixedIndices() throws Exception {
    if (!features.hasCellTTL() || !indexFeatures.supportsDocumentTTL()) {
        return;
    }

    PropertyKey name = makeKey("name", String.class);
    PropertyKey time = makeKey("time", Long.class);
    PropertyKey text = makeKey("text", String.class);

    VertexLabel event = mgmt.makeVertexLabel("event").setStatic().make();
    final int eventTTLSeconds = (int) TestGraphConfigs.getTTL(TimeUnit.SECONDS);
    mgmt.setTTL(event, Duration.ofSeconds(eventTTLSeconds));

    mgmt.buildIndex("index1", Vertex.class).
            addKey(name, getStringMapping()).addKey(time).buildMixedIndex(INDEX);
    mgmt.buildIndex("index2", Vertex.class).indexOnly(event).
            addKey(text, getTextMapping()).buildMixedIndex(INDEX);

    assertEquals(Duration.ZERO, mgmt.getTTL(name));
    assertEquals(Duration.ZERO, mgmt.getTTL(time));
    assertEquals(Duration.ofSeconds(eventTTLSeconds), mgmt.getTTL(event));
    finishSchema();

    TitanVertex v1 = tx.addVertex("event");
    v1.property(VertexProperty.Cardinality.single, "name", "first event");
    v1.property(VertexProperty.Cardinality.single, "text", "this text will help to identify the first event");
    long time1 = System.currentTimeMillis();
    v1.property(VertexProperty.Cardinality.single, "time", time1);
    TitanVertex v2 = tx.addVertex("event");
    v2.property(VertexProperty.Cardinality.single, "name", "second event");
    v2.property(VertexProperty.Cardinality.single, "text", "this text won't match");
    long time2 = time1 + 1;
    v2.property(VertexProperty.Cardinality.single, "time", time2);

    evaluateQuery(tx.query().has("name", "first event").orderBy("time", decr),
            ElementCategory.VERTEX, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC, "index1");
    evaluateQuery(tx.query().has("text", Text.CONTAINS, "help").has(LABEL_NAME, "event"),
            ElementCategory.VERTEX, 1, new boolean[]{true, true}, "index2");

    clopen();

    Object v1Id = v1.id();
    Object v2Id = v2.id();

    evaluateQuery(tx.query().has("name", "first event").orderBy("time", decr),
            ElementCategory.VERTEX, 1, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC, "index1");
    evaluateQuery(tx.query().has("text", Text.CONTAINS, "help").has(LABEL_NAME, "event"),
            ElementCategory.VERTEX, 1, new boolean[]{true, true}, "index2");

    v1 = getV(tx, v1Id);
    v2 = getV(tx, v1Id);
    assertNotNull(v1);
    assertNotNull(v2);

    Thread.sleep(TimeUnit.MILLISECONDS.convert((long) Math.ceil(eventTTLSeconds * 1.25), TimeUnit.SECONDS));

    clopen();

    Thread.sleep(TimeUnit.MILLISECONDS.convert((long) Math.ceil(eventTTLSeconds * 1.25), TimeUnit.SECONDS));

    evaluateQuery(tx.query().has("text", Text.CONTAINS, "help").has(LABEL_NAME, "event"),
            ElementCategory.VERTEX, 0, new boolean[]{true, true}, "index2");
    evaluateQuery(tx.query().has("name", "first event").orderBy("time", decr),
            ElementCategory.VERTEX, 0, new boolean[]{true, true}, tx.getPropertyKey("time"), Order.DESC, "index1");


    v1 = getV(tx, v1Id);
    v2 = getV(tx, v2Id);
    assertNull(v1);
    assertNull(v2);
}
 
Example 49
Project: titan1withtp3.1   File: TitanIndexTest.java   Source Code and License 4 votes vote down vote up
private void testNestedWrites(String initialValue, String updatedValue) throws BackendException {
    // This method touches a single vertex with multiple transactions,
    // leading to deadlock under BDB and cascading test failures. Check for
    // the hasTxIsolation() store feature, which is currently true for BDB
    // but false for HBase/Cassandra. This is kind of a hack; a more robust
    // approach might implement different methods/assertions depending on
    // whether the store is capable of deadlocking or detecting conflicting
    // writes and aborting a transaction.
    Backend b = null;
    try {
        b = graph.getConfiguration().getBackend();
        if (b.getStoreFeatures().hasTxIsolation()) {
            log.info("Skipping " + getClass().getSimpleName() + "." + methodName.getMethodName());
            return;
        }
    } finally {
        if (null != b)
            b.close();
    }

    final String propName = "foo";

    // Write schema and one vertex
    PropertyKey prop = makeKey(propName, String.class);
    createExternalVertexIndex(prop, INDEX);
    finishSchema();

    TitanVertex v = graph.addVertex();
    if (null != initialValue)
        v.property(VertexProperty.Cardinality.single, propName, initialValue);
    graph.tx().commit();

    Object id = v.id();

    // Open two transactions and modify the same vertex
    TitanTransaction vertexDeleter = graph.newTransaction();
    TitanTransaction propDeleter = graph.newTransaction();

    getV(vertexDeleter, id).remove();
    if (null == updatedValue)
        getV(propDeleter, id).property(propName).remove();
    else
        getV(propDeleter, id).property(VertexProperty.Cardinality.single, propName, updatedValue);

    vertexDeleter.commit();
    propDeleter.commit();

    // The vertex must not exist after deletion
    graph.tx().rollback();
    assertEquals(null, getV(graph, id));
    assertEmpty(graph.query().has(propName).vertices());
    if (null != updatedValue)
        assertEmpty(graph.query().has(propName, updatedValue).vertices());
    graph.tx().rollback();
}
 
Example 50
Project: titan1withtp3.1   File: TitanIndexTest.java   Source Code and License 4 votes vote down vote up
/**
 * Tests indexing lists
 */
@Test
public void testListIndexing() {
    testIndexing(Cardinality.LIST);
}
 
Example 51
Project: titan1withtp3.1   File: TitanIndexTest.java   Source Code and License 4 votes vote down vote up
/**
 * Tests indexing sets
 */
@Test
public void testSetIndexing() {
    testIndexing(Cardinality.SET);
}
 
Example 52
Project: titan0.5.4-hbase1.1.1-custom   File: StandardKeyInformation.java   Source Code and License 4 votes vote down vote up
@Override
public Cardinality getCardinality() {
    return cardinality;
}
 
Example 53
Project: titan1withtp3.1   File: TitanGraphBaseTest.java   Source Code and License 4 votes vote down vote up
public PropertyKey makeVertexIndexedKey(String name, Class datatype) {
    PropertyKey key = mgmt.makePropertyKey(name).dataType(datatype).cardinality(Cardinality.SINGLE).make();
    mgmt.buildIndex(name,Vertex.class).addKey(key).buildCompositeIndex();
    return key;
}
 
Example 54
Project: titan1withtp3.1   File: TitanGraphBaseTest.java   Source Code and License 4 votes vote down vote up
public PropertyKey makeKey(String name, Class datatype) {
    PropertyKey key = mgmt.makePropertyKey(name).dataType(datatype).cardinality(Cardinality.SINGLE).make();
    return key;
}
 
Example 55
Project: titan0.5.4-hbase1.1.1-custom   File: DefaultSchemaProvider.java   Source Code and License 4 votes vote down vote up
@Override
public PropertyKeyDefinition getPropertyKey(String name) {
    log.debug("Creating default property key definition for {}", name);
    return new PropertyKeyDefinition(name, FaunusElement.NO_ID, Cardinality.SINGLE, Object.class);
}
 
Example 56
Project: titan1withtp3.1   File: IndexFeatures.java   Source Code and License 4 votes vote down vote up
public Builder supportsCardinality(Cardinality cardinality) {
    supportedCardinalities.add(cardinality);
    return this;
}
 
Example 57
Project: titan1withtp3.1   File: StandardKeyInformation.java   Source Code and License 4 votes vote down vote up
@Override
public Cardinality getCardinality() {
    return cardinality;
}
 
Example 58
Project: titan1withtp3.1   File: TitanGraphIndexWrapper.java   Source Code and License 4 votes vote down vote up
@Override
public boolean isUnique() {
    if (index.isMixedIndex()) return false;
    return ((CompositeIndexType)index).getCardinality()== Cardinality.SINGLE;
}
 
Example 59
Project: titan1withtp3.1   File: CompositeIndexTypeWrapper.java   Source Code and License 4 votes vote down vote up
@Override
public Cardinality getCardinality() {
    return base.getDefinition().getValue(TypeDefinitionCategory.INDEX_CARDINALITY,Cardinality.class);
}
 
Example 60
Project: titan1withtp3.1   File: StandardPropertyKeyMaker.java   Source Code and License 4 votes vote down vote up
public StandardPropertyKeyMaker(StandardTitanTx tx, String name, IndexSerializer indexSerializer,
                                final AttributeHandler attributeHandler) {
    super(tx, name, indexSerializer, attributeHandler);
    dataType = null;
    cardinality(Cardinality.SINGLE);
}