use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class AbstractTransaction method injectOlapPkIfNeeded.
private void injectOlapPkIfNeeded(Query query) {
if (!query.resultType().isVertex() || !this.graph.readMode().showOlap()) {
return;
}
/*
* Control olap access by auth, only accessible olap property key
* will be queried
*/
Set<Id> olapPks = new IdSet(CollectionType.EC);
for (PropertyKey propertyKey : this.graph.graph().propertyKeys()) {
if (propertyKey.olap()) {
olapPks.add(propertyKey.id());
}
}
query.olapPks(olapPks);
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class IndexLabelBuilder method build.
@Override
public IndexLabel build() {
Id id = this.validOrGenerateId(HugeType.INDEX_LABEL, this.id, this.name);
this.checkBaseType();
this.checkIndexType();
HugeGraph graph = this.graph();
this.checkFields4Range();
IndexLabel indexLabel = new IndexLabel(graph, id, this.name);
indexLabel.baseType(this.baseType);
SchemaLabel schemaLabel = this.loadBaseLabel();
indexLabel.baseValue(schemaLabel.id());
indexLabel.indexType(this.indexType);
for (String field : this.indexFields) {
PropertyKey propertyKey = graph.propertyKey(field);
indexLabel.indexField(propertyKey.id());
}
indexLabel.userdata(this.userdata);
return indexLabel;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class IndexLabelBuilder method hasSameProperties.
/**
* Check whether this has same properties with existedIndexLabel.
* Only baseType, baseValue, indexType, indexFields are checked.
* The id, checkExist, userdata are not checked.
* @param existedIndexLabel to be compared with
* @return true if this has same properties with existedIndexLabel
*/
private boolean hasSameProperties(IndexLabel existedIndexLabel) {
// baseType is null, it means HugeType.SYS_SCHEMA
if ((this.baseType == null && existedIndexLabel.baseType() != HugeType.SYS_SCHEMA) || (this.baseType != null && this.baseType != existedIndexLabel.baseType())) {
return false;
}
SchemaLabel schemaLabel = this.loadBaseLabel();
if (!schemaLabel.id().equals(existedIndexLabel.baseValue())) {
return false;
}
if (this.indexType == null) {
// The default index type is SECONDARY
if (existedIndexLabel.indexType() != IndexType.SECONDARY) {
return false;
}
} else {
// NOTE: IndexType.RANGE.isRange() return false
if (this.indexType == IndexType.RANGE) {
// existedIndexLabel index type format: RANGE_INT, RANGE_LONG
if (!existedIndexLabel.indexType().isRange()) {
return false;
}
} else if (this.indexType != existedIndexLabel.indexType()) {
return false;
}
}
List<Id> existedIndexFieldIds = existedIndexLabel.indexFields();
if (this.indexFields.size() != existedIndexFieldIds.size()) {
return false;
}
for (String field : this.indexFields) {
PropertyKey propertyKey = graph().propertyKey(field);
if (!existedIndexFieldIds.contains(propertyKey.id())) {
return false;
}
}
// all properties are same, return true.
return true;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class IndexLabelBuilder method allStringIndex.
private boolean allStringIndex(List<?> fields) {
for (Object field : fields) {
PropertyKey pk = field instanceof Id ? this.graph().propertyKey((Id) field) : this.graph().propertyKey((String) field);
DataType dataType = pk.dataType();
if (dataType.isNumber() || dataType.isDate()) {
return false;
}
}
return true;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class EdgeLabelBuilder method hasSameProperties.
/**
* Check whether this has same properties with existedEdgeLabel.
* Only sourceId, targetId, frequency, enableLabelIndex, properties, sortKeys,
* nullableKeys are checked.
* The id, ttl, ttlStartTime, userdata are not checked.
* @param existedEdgeLabel to be compared with
* @return true if this has same properties with existedVertexLabel
*/
private boolean hasSameProperties(EdgeLabel existedEdgeLabel) {
HugeGraph graph = this.graph();
Id sourceId = graph.vertexLabel(this.sourceLabel).id();
if (!existedEdgeLabel.sourceLabel().equals(sourceId)) {
return false;
}
Id targetId = graph.vertexLabel(this.targetLabel).id();
if (!existedEdgeLabel.targetLabel().equals(targetId)) {
return false;
}
if ((this.frequency == Frequency.DEFAULT && existedEdgeLabel.frequency() != Frequency.SINGLE) || (this.frequency != Frequency.DEFAULT && this.frequency != existedEdgeLabel.frequency())) {
return false;
}
// this.enableLabelIndex == null, it means true.
if (this.enableLabelIndex == null || this.enableLabelIndex) {
if (!existedEdgeLabel.enableLabelIndex()) {
return false;
}
} else {
// this false
if (existedEdgeLabel.enableLabelIndex()) {
return false;
}
}
Set<Id> existedProperties = existedEdgeLabel.properties();
if (this.properties.size() != existedProperties.size()) {
return false;
}
for (String key : this.properties) {
PropertyKey propertyKey = graph.propertyKey(key);
if (!existedProperties.contains(propertyKey.id())) {
return false;
}
}
List<Id> existedSortKeys = existedEdgeLabel.sortKeys();
if (this.sortKeys.size() != existedSortKeys.size()) {
return false;
}
for (String key : this.sortKeys) {
PropertyKey propertyKey = graph.propertyKey(key);
if (!existedSortKeys.contains(propertyKey.id())) {
return false;
}
}
Set<Id> existedNullableKeys = existedEdgeLabel.nullableKeys();
if (this.nullableKeys.size() != existedNullableKeys.size()) {
return false;
}
for (String nullableKeyName : this.nullableKeys) {
PropertyKey nullableKey = graph.propertyKey(nullableKeyName);
if (!existedNullableKeys.contains(nullableKey.id())) {
return false;
}
}
return true;
}
Aggregations