Search in sources :

Example 26 with Watched

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));
    }
}
Also used : SchemaLabel(com.baidu.hugegraph.schema.SchemaLabel) HugeIndex(com.baidu.hugegraph.structure.HugeIndex) HugeVertex(com.baidu.hugegraph.structure.HugeVertex) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 27 with Watched

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);
}
Also used : ConditionQuery(com.baidu.hugegraph.backend.query.ConditionQuery) IndexLabel(com.baidu.hugegraph.schema.IndexLabel) Map(java.util.Map) HashMap(java.util.HashMap) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 28 with Watched

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);
    }
}
Also used : SchemaLabel(com.baidu.hugegraph.schema.SchemaLabel) Id(com.baidu.hugegraph.backend.id.Id) HugeType(com.baidu.hugegraph.type.HugeType) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 29 with Watched

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());
}
Also used : Id(com.baidu.hugegraph.backend.id.Id) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 30 with Watched

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);
    }
}
Also used : VertexLabel(com.baidu.hugegraph.schema.VertexLabel) EdgeLabel(com.baidu.hugegraph.schema.EdgeLabel) NotAllowException(com.baidu.hugegraph.exception.NotAllowException) PropertyKey(com.baidu.hugegraph.schema.PropertyKey) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Aggregations

Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)65 Id (com.baidu.hugegraph.backend.id.Id)30 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)9 EdgeId (com.baidu.hugegraph.backend.id.EdgeId)8 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)8 SchemaManager (com.baidu.hugegraph.schema.SchemaManager)7 ArrayList (java.util.ArrayList)7 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)6 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)6 BatchIdHolder (com.baidu.hugegraph.backend.page.IdHolder.BatchIdHolder)5 HugeIndex (com.baidu.hugegraph.structure.HugeIndex)5 IdHolder (com.baidu.hugegraph.backend.page.IdHolder)4 FixedIdHolder (com.baidu.hugegraph.backend.page.IdHolder.FixedIdHolder)4 PagingIdHolder (com.baidu.hugegraph.backend.page.IdHolder.PagingIdHolder)4 IdQuery (com.baidu.hugegraph.backend.query.IdQuery)4 Query (com.baidu.hugegraph.backend.query.Query)4 SchemaJob (com.baidu.hugegraph.job.schema.SchemaJob)4 SchemaLabel (com.baidu.hugegraph.schema.SchemaLabel)4 VertexLabel (com.baidu.hugegraph.schema.VertexLabel)4 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)4