本文整理汇总了Java中com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory类的典型用法代码示例。如果您正苦于以下问题:Java TypeDefinitionCategory类的具体用法?Java TypeDefinitionCategory怎么用?Java TypeDefinitionCategory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeDefinitionCategory类属于com.thinkaurelius.titan.graphdb.types包,在下文中一共展示了TypeDefinitionCategory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMixedIndex
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
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());
}
示例2: createMixedIndex
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
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());
}
示例3: addSchemaEdge
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
private TitanEdge addSchemaEdge(TitanVertex out, TitanVertex in, TypeDefinitionCategory def, Object modifier) {
assert def.isEdge();
TitanEdge edge = transaction.addEdge(out, in, BaseLabel.SchemaDefinitionEdge);
TypeDefinitionDescription desc = new TypeDefinitionDescription(def, modifier);
edge.property(BaseKey.SchemaDefinitionDesc.name(), desc);
return edge;
}
示例4: getSchemaElement
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
public TitanSchemaElement getSchemaElement(long id) {
TitanVertex v = transaction.getVertex(id);
if (v == null) return null;
if (v instanceof RelationType) {
if (((InternalRelationType) v).getBaseType() == null) return (RelationType) v;
return new RelationTypeIndexWrapper((InternalRelationType) v);
}
if (v instanceof TitanSchemaVertex) {
TitanSchemaVertex sv = (TitanSchemaVertex) v;
if (sv.getDefinition().containsKey(TypeDefinitionCategory.INTERNAL_INDEX)) {
return new TitanGraphIndexWrapper(sv.asIndexType());
}
}
throw new IllegalArgumentException("Not a valid schema element vertex: " + id);
}
示例5: addIndexKey
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
@Override
public void addIndexKey(final TitanGraphIndex index, final PropertyKey key, Parameter... parameters) {
Preconditions.checkArgument(index != null && key != null && index instanceof TitanGraphIndexWrapper
&& !(key instanceof BaseKey), "Need to provide valid index and key");
if (parameters == null) parameters = new Parameter[0];
IndexType indexType = ((TitanGraphIndexWrapper) index).getBaseIndex();
Preconditions.checkArgument(indexType instanceof MixedIndexType, "Can only add keys to an external index, not %s", index.name());
Preconditions.checkArgument(indexType instanceof IndexTypeWrapper && key instanceof TitanSchemaVertex
&& ((IndexTypeWrapper) indexType).getSchemaBase() instanceof TitanSchemaVertex);
TitanSchemaVertex indexVertex = (TitanSchemaVertex) ((IndexTypeWrapper) indexType).getSchemaBase();
for (IndexField field : indexType.getFieldKeys())
Preconditions.checkArgument(!field.getFieldKey().equals(key), "Key [%s] has already been added to index %s", key.name(), index.name());
//Assemble parameters
boolean addMappingParameter = !ParameterType.MAPPED_NAME.hasParameter(parameters);
Parameter[] extendedParas = new Parameter[parameters.length + 1 + (addMappingParameter ? 1 : 0)];
System.arraycopy(parameters, 0, extendedParas, 0, parameters.length);
int arrPosition = parameters.length;
if (addMappingParameter) extendedParas[arrPosition++] = ParameterType.MAPPED_NAME.getParameter(
graph.getIndexSerializer().getDefaultFieldName(key, parameters, indexType.getBackingIndexName()));
extendedParas[arrPosition++] = ParameterType.STATUS.getParameter(key.isNew() ? SchemaStatus.ENABLED : SchemaStatus.INSTALLED);
addSchemaEdge(indexVertex, key, TypeDefinitionCategory.INDEX_FIELD, extendedParas);
updateSchemaVertex(indexVertex);
indexType.resetCache();
//Check to see if the index supports this
if (!graph.getIndexSerializer().supports((MixedIndexType) indexType, ParameterIndexField.of(key, parameters))) {
throw new TitanException("Could not register new index field '" + key.name() + "' with index backend as the data type, cardinality or parameter combination is not supported.");
}
try {
IndexSerializer.register((MixedIndexType) indexType, key, transaction.getTxHandle());
} catch (BackendException e) {
throw new TitanException("Could not register new index field with index backend", e);
}
if (!indexVertex.isNew()) updatedTypes.add(indexVertex);
if (!key.isNew()) updateIndex(index, SchemaAction.REGISTER_INDEX);
}
示例6: createCompositeIndex
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
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;
}
示例7: addSchemaEdge
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
private TitanEdge addSchemaEdge(TitanVertex out, TitanVertex in, TypeDefinitionCategory def, Object modifier) {
assert def.isEdge();
TitanEdge edge = transaction.addEdge(out,in, BaseLabel.SchemaDefinitionEdge);
TypeDefinitionDescription desc = new TypeDefinitionDescription(def,modifier);
edge.setProperty(BaseKey.SchemaDefinitionDesc,desc);
return edge;
}
示例8: getSchemaElement
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
public TitanSchemaElement getSchemaElement(long id) {
TitanVertex v = transaction.getVertex(id);
if (v==null) return null;
if (v instanceof RelationType) {
if (((InternalRelationType)v).getBaseType()==null) return (RelationType)v;
return new RelationTypeIndexWrapper((InternalRelationType)v);
}
if (v instanceof TitanSchemaVertex) {
TitanSchemaVertex sv = (TitanSchemaVertex)v;
if (sv.getDefinition().containsKey(TypeDefinitionCategory.INTERNAL_INDEX)) {
return new TitanGraphIndexWrapper(sv.asIndexType());
}
}
throw new IllegalArgumentException("Not a valid schema element vertex: "+id);
}
示例9: addIndexKey
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
@Override
public void addIndexKey(final TitanGraphIndex index, final PropertyKey key, Parameter... parameters) {
Preconditions.checkArgument(index!=null && key!=null && index instanceof TitanGraphIndexWrapper
&& !(key instanceof BaseKey),"Need to provide valid index and key");
if (parameters==null) parameters=new Parameter[0];
IndexType indexType = ((TitanGraphIndexWrapper)index).getBaseIndex();
Preconditions.checkArgument(indexType instanceof MixedIndexType,"Can only add keys to an external index, not %s",index.getName());
Preconditions.checkArgument(indexType instanceof IndexTypeWrapper && key instanceof TitanSchemaVertex
&& ((IndexTypeWrapper)indexType).getSchemaBase() instanceof TitanSchemaVertex);
Preconditions.checkArgument(key.getCardinality()==Cardinality.SINGLE || indexType.getElement()!=ElementCategory.VERTEX,
"Can only index single-valued property keys on vertices [%s]",key);
TitanSchemaVertex indexVertex = (TitanSchemaVertex)((IndexTypeWrapper)indexType).getSchemaBase();
for (IndexField field : indexType.getFieldKeys())
Preconditions.checkArgument(!field.getFieldKey().equals(key),"Key [%s] has already been added to index %s",key.getName(),index.getName());
//Assemble parameters
boolean addMappingParameter = !ParameterType.MAPPED_NAME.hasParameter(parameters);
Parameter[] extendedParas = new Parameter[parameters.length+1+(addMappingParameter?1:0)];
System.arraycopy(parameters,0,extendedParas,0,parameters.length);
int arrPosition = parameters.length;
if (addMappingParameter) extendedParas[arrPosition++] = ParameterType.MAPPED_NAME.getParameter(
graph.getIndexSerializer().getDefaultFieldName(key,parameters,indexType.getBackingIndexName()));
extendedParas[arrPosition++] = ParameterType.STATUS.getParameter(key.isNew()?SchemaStatus.ENABLED:SchemaStatus.INSTALLED);
addSchemaEdge(indexVertex, key, TypeDefinitionCategory.INDEX_FIELD, extendedParas);
updateSchemaVertex(indexVertex);
indexType.resetCache();
try {
IndexSerializer.register((MixedIndexType) indexType,key,transaction.getTxHandle());
} catch (BackendException e) {
throw new TitanException("Could not register new index field with index backend",e);
}
if (!indexVertex.isNew()) updatedTypes.add(indexVertex);
if (!key.isNew()) updateIndex(index, SchemaAction.REGISTER_INDEX);
}
示例10: createCompositeIndex
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
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.getCardinality()!=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;
}
示例11: read
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
@Override
public TypeDefinitionDescription read(ScanBuffer buffer) {
TypeDefinitionCategory defCategory = serializer.readObjectNotNull(buffer, TypeDefinitionCategory.class);
Object modifier = serializer.readClassAndObject(buffer);
return new TypeDefinitionDescription(defCategory,modifier);
}
示例12: StandardSerializer
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
public StandardSerializer() {
handlers = new HashMap<>(60);
registrations = HashBiMap.create(60);
//Setup
registerClassInternal(1, Object.class, new ObjectSerializer());
//Primitive data types
registerClassInternal(10, Byte.class, new ByteSerializer());
registerClassInternal(11,Short.class, new ShortSerializer());
registerClassInternal(12,Integer.class, new IntegerSerializer());
registerClassInternal(13,Long.class, new LongSerializer());
registerClassInternal(14,Character.class, new CharacterSerializer());
registerClassInternal(15,Boolean.class, new BooleanSerializer());
registerClassInternal(16,Date.class, new DateSerializer());
registerClassInternal(17,Geoshape.class, new Geoshape.GeoshapeSerializer());
registerClassInternal(18,String.class, new StringSerializer()); //supports null serialization
registerClassInternal(19,Float.class, new FloatSerializer());
registerClassInternal(20,Double.class, new DoubleSerializer());
registerClassInternal(21,UUID.class, new UUIDSerializer());
//Arrays (support null serialization)
registerClassInternal(22,byte[].class, new ByteArraySerializer());
registerClassInternal(23,short[].class, new ShortArraySerializer());
registerClassInternal(24,int[].class, new IntArraySerializer());
registerClassInternal(25,long[].class, new LongArraySerializer());
registerClassInternal(26,float[].class, new FloatArraySerializer());
registerClassInternal(27,double[].class, new DoubleArraySerializer());
registerClassInternal(28,char[].class, new CharArraySerializer());
registerClassInternal(29,boolean[].class, new BooleanArraySerializer());
registerClassInternal(30, String[].class, new StringArraySerializer());
//Needed by Titan
registerClassInternal(41,TypeDefinitionCategory.class, new EnumSerializer<>(TypeDefinitionCategory.class));
registerClassInternal(42,TitanSchemaCategory.class, new EnumSerializer<>(TitanSchemaCategory.class));
registerClassInternal(43,ParameterType.class, new EnumSerializer<>(ParameterType.class));
registerClassInternal(44,RelationCategory.class, new EnumSerializer<>(RelationCategory.class));
registerClassInternal(45,Order.class, new EnumSerializer<>(Order.class));
registerClassInternal(46,Multiplicity.class, new EnumSerializer<>(Multiplicity.class));
registerClassInternal(47,Cardinality.class, new EnumSerializer<>(Cardinality.class));
registerClassInternal(48,Direction.class, new EnumSerializer<>(Direction.class));
registerClassInternal(49,ElementCategory.class, new EnumSerializer<>(ElementCategory.class));
registerClassInternal(50,ConsistencyModifier.class, new EnumSerializer<>(ConsistencyModifier.class));
registerClassInternal(51,SchemaStatus.class, new EnumSerializer<>(SchemaStatus.class));
registerClassInternal(52,LogTxStatus.class, new EnumSerializer<>(LogTxStatus.class));
registerClassInternal(53,MgmtLogType.class, new EnumSerializer<>(MgmtLogType.class));
registerClassInternal(54,TimestampProviders.class, new EnumSerializer<>(TimestampProviders.class));
registerClassInternal(55,TimeUnit.class, new EnumSerializer<>(TimeUnit.class));
registerClassInternal(56,Mapping.class, new EnumSerializer<>(Mapping.class));
registerClassInternal(57,ConflictAvoidanceMode.class, new EnumSerializer<>(ConflictAvoidanceMode.class));
registerClassInternal(60,Class.class, new ClassSerializer());
registerClassInternal(61,Parameter.class, new ParameterSerializer());
registerClassInternal(62,Parameter[].class, new ParameterArraySerializer());
registerClassInternal(63,TypeDefinitionDescription.class, new TypeDefinitionDescriptionSerializer());
//Needed for configuration and transaction logging
registerClassInternal(64,Duration.class, new DurationSerializer());
registerClassInternal(65,Instant.class, new InstantSerializer());
registerClassInternal(66,StandardTransactionId.class, new StandardTransactionIdSerializer());
}
示例13: getElement
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
@Override
public ElementCategory getElement() {
return base.getDefinition().getValue(TypeDefinitionCategory.ELEMENT_CATEGORY,ElementCategory.class);
}
示例14: getBackingIndexName
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
@Override
public String getBackingIndexName() {
return base.getDefinition().getValue(TypeDefinitionCategory.BACKING_INDEX,String.class);
}
示例15: isUnidirected
import com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory; //导入依赖的package包/类
@Override
public boolean isUnidirected(Direction dir) {
return getDefinition().getValue(TypeDefinitionCategory.UNIDIRECTIONAL,Direction.class)==dir;
}