use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class HugeEdge method onUpdateProperty.
@Watched(prefix = "edge")
@Override
protected <V> void onUpdateProperty(Cardinality cardinality, HugeProperty<V> prop) {
if (prop != null) {
assert prop instanceof HugeEdgeProperty;
HugeEdgeProperty<V> edgeProp = (HugeEdgeProperty<V>) prop;
GraphTransaction tx = this.tx();
if (tx != null) {
assert this.fresh();
tx.addEdgeProperty(edgeProp);
} else {
this.graph().addEdgeProperty(edgeProp);
}
}
}
use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class HugeEdge method ensureFilledProperties.
@Watched(prefix = "edge")
@Override
protected boolean ensureFilledProperties(boolean throwIfNotExist) {
if (this.isPropLoaded()) {
this.updateToDefaultValueIfNone();
return true;
}
// Skip query if there is no any property key in schema
if (this.schemaLabel().properties().isEmpty()) {
this.propLoaded();
return true;
}
// Seems there is no scene to be here
Iterator<Edge> edges = this.graph().edges(this.id());
Edge edge = QueryResults.one(edges);
if (edge == null && !throwIfNotExist) {
return false;
}
E.checkState(edge != null, "Edge '%s' does not exist", this.id);
this.copyProperties((HugeEdge) edge);
this.updateToDefaultValueIfNone();
return true;
}
use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class HugeElement method setProperty.
@Watched(prefix = "element")
public <V> HugeProperty<?> setProperty(HugeProperty<V> prop) {
if (this.properties == EMPTY_MAP) {
this.properties = CollectionFactory.newIntObjectMap();
}
PropertyKey pkey = prop.propertyKey();
E.checkArgument(this.properties.containsKey(intFromId(pkey.id())) || this.properties.size() < MAX_PROPERTIES, "Exceeded the maximum number of properties");
return this.properties.put(intFromId(pkey.id()), prop);
}
use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class HugeVertex method edges.
@Watched(prefix = "vertex")
@Override
public Iterator<Edge> edges(Direction tinkerpopDir, String... edgeLabels) {
Directions direction = Directions.convert(tinkerpopDir);
// NOTE: get edges from memory if load all edges when loading vertex.
if (this.existsEdges()) {
return this.getEdges(direction, edgeLabels);
}
Id[] edgeLabelIds = this.graph().mapElName2Id(edgeLabels);
Query query = GraphTransaction.constructEdgesQuery(this.id(), direction, edgeLabelIds);
return this.graph().edges(query);
}
use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class HugeVertex method properties.
@Watched(prefix = "vertex")
// (VertexProperty<V>) prop
@SuppressWarnings("unchecked")
@Override
public <V> Iterator<VertexProperty<V>> properties(String... keys) {
// TODO: Compatible with TinkerPop properties() (HugeGraph-742)
this.ensureFilledProperties(true);
// Capacity should be about the following size
int propsCapacity = keys.length == 0 ? this.sizeOfProperties() : keys.length;
List<VertexProperty<V>> props = new ArrayList<>(propsCapacity);
if (keys.length == 0) {
for (HugeProperty<?> prop : this.getProperties()) {
assert prop instanceof VertexProperty;
props.add((VertexProperty<V>) prop);
}
} else {
for (String key : keys) {
Id pkeyId;
try {
pkeyId = this.graph().propertyKey(key).id();
} catch (IllegalArgumentException ignored) {
continue;
}
HugeProperty<?> prop = this.getProperty(pkeyId);
if (prop == null) {
// Not found
continue;
}
assert prop instanceof VertexProperty;
props.add((VertexProperty<V>) prop);
}
}
return props.iterator();
}
Aggregations