@Override public boolean apply(@Nullable TitanVertexProperty titanProperty) { return titanProperty.propertyKey().equals(key); } });
@Override public synchronized Iterable<TitanVertexProperty> get(final Object value, final PropertyKey key) { List<TitanVertexProperty> result = new ArrayList<TitanVertexProperty>(4); for (TitanVertexProperty p : map.get(value)) { if (p.propertyKey().equals(key)) result.add(p); } return result; } }
public static boolean hasSimpleInternalVertexKeyIndex(TitanVertexProperty prop) { return hasSimpleInternalVertexKeyIndex(prop.propertyKey()); }
public static Set<String> getPropertyKeys(TitanVertex v) { final Set<String> s = new HashSet<>(); v.query().properties().forEach( p -> s.add(p.propertyKey().name())); return s; }
public boolean matchesConstraint(TitanSchemaType type, TitanElement element) { Preconditions.checkArgument(type != null && element!=null); assert isInstance(element); assert isValidConstraint(type); switch(this) { case VERTEX: return ((TitanVertex)element).vertexLabel().equals(type); case EDGE: return ((TitanEdge)element).edgeLabel().equals(type); case PROPERTY: return ((TitanVertexProperty)element).propertyKey().equals(type); default: throw new IllegalArgumentException(); } }
private RecordEntry(TitanVertexProperty property) { this(property.longId(),property.value(),property.propertyKey()); } }
public Collection<IndexUpdate> getIndexUpdates(InternalVertex vertex, Collection<InternalRelation> updatedProperties) { if (updatedProperties.isEmpty()) return Collections.EMPTY_LIST; Set<IndexUpdate> updates = Sets.newHashSet(); for (InternalRelation rel : updatedProperties) { assert rel.isProperty(); TitanVertexProperty p = (TitanVertexProperty)rel; assert rel.isNew() || rel.isRemoved(); assert rel.getVertex(0).equals(vertex); IndexUpdate.Type updateType = getUpateType(rel); for (IndexType index : ((InternalRelationType)p.propertyKey()).getKeyIndexes()) { if (!indexAppliesTo(index,vertex)) continue; if (index.isCompositeIndex()) { //Gather composite indexes CompositeIndexType cIndex = (CompositeIndexType)index; IndexRecords updateRecords = indexMatches(vertex,cIndex,updateType==IndexUpdate.Type.DELETE,p.propertyKey(),new RecordEntry(p)); for (RecordEntry[] record : updateRecords) { IndexUpdate update = new IndexUpdate<StaticBuffer,Entry>(cIndex,updateType,getIndexKey(cIndex,record),getIndexEntry(cIndex,record,vertex), vertex); int ttl = getIndexTTL(vertex,getKeysOfRecords(record)); if (ttl>0 && updateType== IndexUpdate.Type.ADD) update.setTTL(ttl); updates.add(update); } } else { //Update mixed indexes if (((MixedIndexType)index).getField(p.propertyKey()).getStatus()== SchemaStatus.DISABLED) continue; IndexUpdate update = getMixedIndexUpdate(vertex, p.propertyKey(), p.value(), (MixedIndexType) index, updateType); int ttl = getIndexTTL(vertex,p.propertyKey()); if (ttl>0 && updateType== IndexUpdate.Type.ADD) update.setTTL(ttl); updates.add(update); } } } return updates; }
@Override public boolean apply(@Nullable TitanVertexProperty titanProperty) { return titanProperty.propertyKey().equals(key); } });
@Override public synchronized Iterable<TitanVertexProperty> get(final Object value, final PropertyKey key) { List<TitanVertexProperty> result = new ArrayList<TitanVertexProperty>(4); for (TitanVertexProperty p : map.get(value)) { if (p.propertyKey().equals(key)) result.add(p); } return result; } }
public static boolean hasSimpleInternalVertexKeyIndex(TitanVertexProperty prop) { return hasSimpleInternalVertexKeyIndex(prop.propertyKey()); }
public static Set<String> getPropertyKeys(TitanVertex v) { final Set<String> s = new HashSet<>(); v.query().properties().forEach( p -> s.add(p.propertyKey().name())); return s; }
public boolean matchesConstraint(TitanSchemaType type, TitanElement element) { Preconditions.checkArgument(type != null && element!=null); assert isInstance(element); assert isValidConstraint(type); switch(this) { case VERTEX: return ((TitanVertex)element).vertexLabel().equals(type); case EDGE: return ((TitanEdge)element).edgeLabel().equals(type); case PROPERTY: return ((TitanVertexProperty)element).propertyKey().equals(type); default: throw new IllegalArgumentException(); } }
private RecordEntry(TitanVertexProperty property) { this(property.longId(),property.value(),property.propertyKey()); } }
public Collection<IndexUpdate> getIndexUpdates(InternalVertex vertex, Collection<InternalRelation> updatedProperties) { if (updatedProperties.isEmpty()) return Collections.EMPTY_LIST; Set<IndexUpdate> updates = Sets.newHashSet(); for (InternalRelation rel : updatedProperties) { assert rel.isProperty(); TitanVertexProperty p = (TitanVertexProperty)rel; assert rel.isNew() || rel.isRemoved(); assert rel.getVertex(0).equals(vertex); IndexUpdate.Type updateType = getUpateType(rel); for (IndexType index : ((InternalRelationType)p.propertyKey()).getKeyIndexes()) { if (!indexAppliesTo(index,vertex)) continue; if (index.isCompositeIndex()) { //Gather composite indexes CompositeIndexType cIndex = (CompositeIndexType)index; IndexRecords updateRecords = indexMatches(vertex,cIndex,updateType==IndexUpdate.Type.DELETE,p.propertyKey(),new RecordEntry(p)); for (RecordEntry[] record : updateRecords) { IndexUpdate update = new IndexUpdate<StaticBuffer,Entry>(cIndex,updateType,getIndexKey(cIndex,record),getIndexEntry(cIndex,record,vertex), vertex); int ttl = getIndexTTL(vertex,getKeysOfRecords(record)); if (ttl>0 && updateType== IndexUpdate.Type.ADD) update.setTTL(ttl); updates.add(update); } } else { //Update mixed indexes if (((MixedIndexType)index).getField(p.propertyKey()).getStatus()== SchemaStatus.DISABLED) continue; IndexUpdate update = getMixedIndexUpdate(vertex, p.propertyKey(), p.value(), (MixedIndexType) index, updateType); int ttl = getIndexTTL(vertex,p.propertyKey()); if (ttl>0 && updateType== IndexUpdate.Type.ADD) update.setTTL(ttl); updates.add(update); } } } return updates; }