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);
}
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);
}
}
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());
}
}
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);
}
Aggregations