Search in sources :

Example 1 with AtlasCardinality

use of org.apache.atlas.repository.graphdb.AtlasCardinality in project incubator-atlas by apache.

the class Titan0GraphManagement method makePropertyKey.

@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);
}
Also used : PropertyKeyMaker(com.thinkaurelius.titan.core.schema.PropertyKeyMaker) Cardinality(com.thinkaurelius.titan.core.Cardinality) AtlasCardinality(org.apache.atlas.repository.graphdb.AtlasCardinality) AtlasPropertyKey(org.apache.atlas.repository.graphdb.AtlasPropertyKey) PropertyKey(com.thinkaurelius.titan.core.PropertyKey)

Example 2 with AtlasCardinality

use of org.apache.atlas.repository.graphdb.AtlasCardinality in project incubator-atlas by apache.

the class GraphBackedSearchIndexer method createIndexForAttribute.

private void createIndexForAttribute(AtlasGraphManagement management, String typeName, AtlasAttributeDef attributeDef) {
    final String propertyName = GraphHelper.encodePropertyKey(typeName + "." + attributeDef.getName());
    AtlasCardinality cardinality = toAtlasCardinality(attributeDef.getCardinality());
    boolean isUnique = attributeDef.getIsUnique();
    boolean isIndexable = attributeDef.getIsIndexable();
    String attribTypeName = attributeDef.getTypeName();
    boolean isBuiltInType = AtlasTypeUtil.isBuiltInType(attribTypeName);
    boolean isArrayType = AtlasTypeUtil.isArrayType(attribTypeName);
    boolean isMapType = AtlasTypeUtil.isMapType(attribTypeName);
    try {
        AtlasType atlasType = typeRegistry.getType(attribTypeName);
        if (isMapType || isArrayType || isClassificationType(atlasType) || isEntityType(atlasType)) {
            LOG.warn("Ignoring non-indexable attribute {}", attribTypeName);
        } else if (isBuiltInType) {
            createIndexes(management, propertyName, getPrimitiveClass(attribTypeName), isUnique, cardinality, false, isIndexable);
        } else if (isEnumType(atlasType)) {
            createIndexes(management, propertyName, String.class, isUnique, cardinality, false, isIndexable);
        } else if (isStructType(atlasType)) {
            AtlasStructDef structDef = typeRegistry.getStructDefByName(attribTypeName);
            updateIndexForTypeDef(management, structDef);
        }
    } catch (AtlasBaseException e) {
        LOG.error("No type exists for {}", attribTypeName, e);
    }
}
Also used : AtlasCardinality(org.apache.atlas.repository.graphdb.AtlasCardinality) AtlasStructDef(org.apache.atlas.model.typedef.AtlasStructDef) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasType(org.apache.atlas.type.AtlasType)

Example 3 with AtlasCardinality

use of org.apache.atlas.repository.graphdb.AtlasCardinality in project incubator-atlas by apache.

the class GraphBackedSearchIndexer method createIndexForAttribute.

private void createIndexForAttribute(AtlasGraphManagement management, String typeName, AttributeInfo field) {
    final String propertyName = GraphHelper.encodePropertyKey(typeName + "." + field.name);
    switch(field.dataType().getTypeCategory()) {
        case PRIMITIVE:
            AtlasCardinality cardinality = getCardinality(field.multiplicity);
            createIndexes(management, propertyName, getPrimitiveClass(field.dataType()), field.isUnique, cardinality, false, field.isIndexable);
            break;
        case ENUM:
            cardinality = getCardinality(field.multiplicity);
            createIndexes(management, propertyName, String.class, field.isUnique, cardinality, false, field.isIndexable);
            break;
        case ARRAY:
        case MAP:
            // IGNORE: Can only index single-valued property keys on vertices in Mixed Index
            break;
        case STRUCT:
            StructType structType = (StructType) field.dataType();
            createIndexForFields(management, structType, structType.fieldMapping().fields);
            break;
        case TRAIT:
            // do nothing since this is NOT contained in other types
            break;
        case CLASS:
            //createEdgeMixedIndex(propertyName);
            break;
        default:
            throw new IllegalArgumentException("bad data type" + field.dataType().getName());
    }
}
Also used : AtlasCardinality(org.apache.atlas.repository.graphdb.AtlasCardinality) StructType(org.apache.atlas.typesystem.types.StructType) AtlasStructType(org.apache.atlas.type.AtlasStructType)

Example 4 with AtlasCardinality

use of org.apache.atlas.repository.graphdb.AtlasCardinality in project incubator-atlas by apache.

the class Titan1GraphManagement method makePropertyKey.

@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);
}
Also used : PropertyKeyMaker(com.thinkaurelius.titan.core.schema.PropertyKeyMaker) Cardinality(com.thinkaurelius.titan.core.Cardinality) AtlasCardinality(org.apache.atlas.repository.graphdb.AtlasCardinality) AtlasPropertyKey(org.apache.atlas.repository.graphdb.AtlasPropertyKey) PropertyKey(com.thinkaurelius.titan.core.PropertyKey)

Aggregations

AtlasCardinality (org.apache.atlas.repository.graphdb.AtlasCardinality)4 Cardinality (com.thinkaurelius.titan.core.Cardinality)2 PropertyKey (com.thinkaurelius.titan.core.PropertyKey)2 PropertyKeyMaker (com.thinkaurelius.titan.core.schema.PropertyKeyMaker)2 AtlasPropertyKey (org.apache.atlas.repository.graphdb.AtlasPropertyKey)2 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)1 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)1 AtlasStructType (org.apache.atlas.type.AtlasStructType)1 AtlasType (org.apache.atlas.type.AtlasType)1 StructType (org.apache.atlas.typesystem.types.StructType)1