本文整理汇总了Java中com.thinkaurelius.titan.core.Cardinality.SINGLE属性的典型用法代码示例。如果您正苦于以下问题:Java Cardinality.SINGLE属性的具体用法?Java Cardinality.SINGLE怎么用?Java Cardinality.SINGLE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.thinkaurelius.titan.core.Cardinality
的用法示例。
在下文中一共展示了Cardinality.SINGLE属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Titan1Graph
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();
}
}
}
示例2: getProperty
@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;
}
}
示例3: supports
@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;
}
示例4: createCompositeIndex
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;
}
示例5: StandardKeyInformation
public StandardKeyInformation(Class<?> dataType, Parameter... parameters) {
Preconditions.checkNotNull(dataType);
Preconditions.checkNotNull(parameters);
this.dataType = dataType;
this.parameters = parameters;
this.cardinality = Cardinality.SINGLE;
}
示例6: validTitanOrder
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;
}
示例7: getPropertyKey
@Override
public PropertyKeyDefinition getPropertyKey(String name) {
Cardinality card = Cardinality.SINGLE;
if (name.endsWith("list")) card=Cardinality.LIST;
else if (name.endsWith("set")) card=Cardinality.SET;
return new PropertyKeyDefinition(name, getId(), card, Object.class);
}
示例8: supports
@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;
}
示例9: createCardinality
/**
* 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;
}
示例10: createCardinality
/**
* 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);
}
}
示例11: isUnique
@Override
public boolean isUnique() {
if (index.isMixedIndex()) return false;
return ((CompositeIndexType)index).getCardinality()== Cardinality.SINGLE;
}
示例12: getPropertyKey
@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);
}
示例13: cardinality
@Override
public Cardinality cardinality() {
return Cardinality.SINGLE;
}