use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class HugeVertex method primaryValues.
@Watched(prefix = "vertex")
protected List<Object> primaryValues() {
E.checkArgument(this.label.idStrategy() == IdStrategy.PRIMARY_KEY, "The id strategy '%s' don't have primary keys", this.label.idStrategy());
List<Id> primaryKeys = this.label.primaryKeys();
E.checkArgument(!primaryKeys.isEmpty(), "Primary key can't be empty for id strategy '%s'", IdStrategy.PRIMARY_KEY);
boolean encodeNumber = this.graph().option(CoreOptions.VERTEX_ENCODE_PK_NUMBER);
List<Object> propValues = new ArrayList<>(primaryKeys.size());
for (Id pk : primaryKeys) {
HugeProperty<?> property = this.getProperty(pk);
E.checkState(property != null, "The value of primary key '%s' can't be null", this.graph().propertyKey(pk).name());
Object propValue = property.serialValue(encodeNumber);
if (Strings.EMPTY.equals(propValue)) {
propValue = ConditionQuery.INDEX_VALUE_EMPTY;
}
propValues.add(propValue);
}
return propValues;
}
use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class HugeVertex method remove.
@Watched(prefix = "vertex")
@Override
public void remove() {
this.removed(true);
/*
* Call by tx or by graph to remove vertex,
* call by tx if the vertex is new because the context is dependent
*/
GraphTransaction tx = this.tx();
if (tx != null) {
assert this.fresh();
tx.removeVertex(this);
} else {
assert !this.fresh();
this.graph().removeVertex(this);
}
}
use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class TestGraph method initClassicSchema.
@Watched
public void initClassicSchema(IdStrategy idStrategy) {
SchemaManager schema = this.graph.schema();
schema.propertyKey("id").asInt().ifNotExist().create();
schema.propertyKey("weight").asFloat().ifNotExist().create();
schema.propertyKey("name").ifNotExist().create();
schema.propertyKey("lang").ifNotExist().create();
schema.propertyKey("age").asInt().ifNotExist().create();
switch(idStrategy) {
case AUTOMATIC:
schema.vertexLabel("vertex").properties("id", "name", "age", "lang").nullableKeys("id", "name", "age", "lang").ifNotExist().create();
break;
case CUSTOMIZE_STRING:
schema.vertexLabel("vertex").properties("id", "name", "age", "lang").nullableKeys("id", "name", "age", "lang").useCustomizeStringId().ifNotExist().create();
break;
default:
throw new AssertionError(String.format("Id strategy must be customize or automatic"));
}
schema.edgeLabel("knows").link("vertex", "vertex").properties("weight").nullableKeys("weight").ifNotExist().create();
schema.edgeLabel("created").link("vertex", "vertex").properties("weight").nullableKeys("weight").ifNotExist().create();
schema.indexLabel("vertexByName").onV("vertex").by("name").secondary().ifNotExist().create();
schema.indexLabel("vertexByAge").onV("vertex").by("age").range().ifNotExist().create();
}
use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class TestGraph method initBackend.
@Watched
protected void initBackend() {
BackendStoreSystemInfo sysInfo = this.graph.backendStoreSystemInfo();
if (!sysInfo.exists()) {
this.graph.initBackend();
} else {
// May reopen a closed graph
assert sysInfo.exists() && !this.graph.closed();
}
Id id = IdGenerator.of("server-tinkerpop");
this.graph.serverStarted(id, NodeRole.MASTER);
this.initedBackend = true;
}
use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class TestGraph method clearSchema.
@Watched
protected void clearSchema() {
// Clear schema and graph data will be cleared at same time
SchemaManager schema = this.graph.schema();
schema.getIndexLabels().stream().forEach(elem -> {
schema.indexLabel(elem.name()).remove();
});
schema.getEdgeLabels().stream().forEach(elem -> {
schema.edgeLabel(elem.name()).remove();
});
schema.getVertexLabels().stream().forEach(elem -> {
schema.vertexLabel(elem.name()).remove();
});
schema.getPropertyKeys().stream().forEach(elem -> {
schema.propertyKey(elem.name()).remove();
});
TaskScheduler scheduler = this.graph.taskScheduler();
scheduler.tasks(null, -1, null).forEachRemaining(elem -> {
scheduler.delete(elem.id());
});
}
Aggregations