use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class GraphIndexTransaction method updateLabelIndex.
@Watched(prefix = "index")
public void updateLabelIndex(HugeElement element, boolean removed) {
if (element instanceof HugeVertex && ((HugeVertex) element).olap()) {
return;
}
if (!this.needIndexForLabel()) {
return;
}
// Don't update label index if it's not enabled
SchemaLabel label = element.schemaLabel();
if (!label.enableLabelIndex()) {
return;
}
// Update label index if backend store not supports label-query
HugeIndex index = new HugeIndex(this.graph(), IndexLabel.label(element.type()));
index.fieldValues(element.schemaLabel().id());
index.elementIds(element.id(), element.expiredTime());
if (removed) {
this.doEliminate(this.serializer.writeIndex(index));
} else {
this.doAppend(this.serializer.writeIndex(index));
}
}
use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class GraphIndexTransaction method doSingleOrCompositeIndex.
@Watched(prefix = "index")
private IdHolder doSingleOrCompositeIndex(IndexQueries queries) {
assert queries.size() == 1;
Map.Entry<IndexLabel, ConditionQuery> entry = queries.one();
IndexLabel indexLabel = entry.getKey();
ConditionQuery query = entry.getValue();
return this.doIndexQuery(indexLabel, query);
}
use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class SchemaTransaction method removeIndexLabelFromBaseLabel.
@Watched(prefix = "schema")
public void removeIndexLabelFromBaseLabel(IndexLabel indexLabel) {
HugeType baseType = indexLabel.baseType();
Id baseValue = indexLabel.baseValue();
SchemaLabel schemaLabel;
if (baseType == HugeType.VERTEX_LABEL) {
schemaLabel = this.getVertexLabel(baseValue);
} else {
assert baseType == HugeType.EDGE_LABEL;
schemaLabel = this.getEdgeLabel(baseValue);
}
if (schemaLabel == null) {
LOG.info("The base label '{}' of index label '{}' " + "may be deleted before", baseValue, indexLabel);
return;
}
if (schemaLabel.equals(VertexLabel.OLAP_VL)) {
return;
}
// FIXME: move schemaLabel update into updateSchema() lock block instead
synchronized (schemaLabel) {
schemaLabel.removeIndexLabel(indexLabel.id());
this.updateSchema(schemaLabel);
}
}
use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class SchemaTransaction method getNextSystemId.
@Watched(prefix = "schema")
public Id getNextSystemId() {
LOG.debug("SchemaTransaction get next system id");
Id id = this.store().nextId(HugeType.SYS_SCHEMA);
return IdGenerator.of(-id.asLong());
}
use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.
the class SchemaTransaction method removePropertyKey.
@Watched(prefix = "schema")
public Id removePropertyKey(Id id) {
LOG.debug("SchemaTransaction remove property key '{}'", id);
PropertyKey propertyKey = this.getPropertyKey(id);
// If the property key does not exist, return directly
if (propertyKey == null) {
return null;
}
List<VertexLabel> vertexLabels = this.getVertexLabels();
for (VertexLabel vertexLabel : vertexLabels) {
if (vertexLabel.properties().contains(id)) {
throw new NotAllowException("Not allowed to remove property key: '%s' " + "because the vertex label '%s' is still using it.", propertyKey, vertexLabel.name());
}
}
List<EdgeLabel> edgeLabels = this.getEdgeLabels();
for (EdgeLabel edgeLabel : edgeLabels) {
if (edgeLabel.properties().contains(id)) {
throw new NotAllowException("Not allowed to remove property key: '%s' " + "because the edge label '%s' is still using it.", propertyKey, edgeLabel.name());
}
}
if (propertyKey.oltp()) {
this.removeSchema(propertyKey);
return IdGenerator.ZERO;
} else {
return this.removeOlapPk(propertyKey);
}
}
Aggregations