use of com.baidu.hugegraph.type.HugeType in project incubator-hugegraph by apache.
the class EdgeLabelBuilder method create.
@Override
public EdgeLabel create() {
HugeType type = HugeType.EDGE_LABEL;
this.checkSchemaName(this.name);
return this.lockCheckAndCreateSchema(type, this.name, name -> {
EdgeLabel edgeLabel = this.edgeLabelOrNull(this.name);
if (edgeLabel != null) {
if (this.checkExist || !hasSameProperties(edgeLabel)) {
throw new ExistedException(type, this.name);
}
return edgeLabel;
}
this.checkSchemaIdIfRestoringMode(type, this.id);
// These methods will check params and fill to member variables
this.checkRelation();
this.checkProperties(Action.INSERT);
this.checkSortKeys();
this.checkNullableKeys(Action.INSERT);
Userdata.check(this.userdata, Action.INSERT);
this.checkTtl();
this.checkUserdata(Action.INSERT);
edgeLabel = this.build();
assert edgeLabel.name().equals(name);
this.graph().addEdgeLabel(edgeLabel);
return edgeLabel;
});
}
use of com.baidu.hugegraph.type.HugeType in project incubator-hugegraph by apache.
the class PropertyKeyBuilder method createWithTask.
@Override
public SchemaElement.TaskWithSchema createWithTask() {
HugeType type = HugeType.PROPERTY_KEY;
this.checkSchemaName(this.name);
return this.lockCheckAndCreateSchema(type, this.name, name -> {
PropertyKey propertyKey = this.propertyKeyOrNull(name);
if (propertyKey != null) {
if (this.checkExist || !hasSameProperties(propertyKey)) {
throw new ExistedException(type, name);
}
return new SchemaElement.TaskWithSchema(propertyKey, IdGenerator.ZERO);
}
this.checkSchemaIdIfRestoringMode(type, this.id);
Userdata.check(this.userdata, Action.INSERT);
this.checkAggregateType();
this.checkOlap();
propertyKey = this.build();
assert propertyKey.name().equals(name);
Id id = this.graph().addPropertyKey(propertyKey);
return new SchemaElement.TaskWithSchema(propertyKey, id);
});
}
use of com.baidu.hugegraph.type.HugeType in project incubator-hugegraph by apache.
the class VertexLabelBuilder method create.
@Override
public VertexLabel create() {
HugeType type = HugeType.VERTEX_LABEL;
this.checkSchemaName(this.name);
return this.lockCheckAndCreateSchema(type, this.name, name -> {
VertexLabel vertexLabel = this.vertexLabelOrNull(name);
if (vertexLabel != null) {
if (this.checkExist || !hasSameProperties(vertexLabel)) {
throw new ExistedException(type, name);
}
return vertexLabel;
}
this.checkSchemaIdIfRestoringMode(type, this.id);
this.checkProperties(Action.INSERT);
this.checkIdStrategy();
this.checkNullableKeys(Action.INSERT);
Userdata.check(this.userdata, Action.INSERT);
this.checkTtl();
this.checkUserdata(Action.INSERT);
vertexLabel = this.build();
assert vertexLabel.name().equals(name);
this.graph().addVertexLabel(vertexLabel);
return vertexLabel;
});
}
use of com.baidu.hugegraph.type.HugeType in project incubator-hugegraph by apache.
the class MysqlEntryIterator method row2Entry.
private MysqlBackendEntry row2Entry(ResultSet result) throws SQLException {
HugeType type = this.query.resultType();
MysqlBackendEntry entry = new MysqlBackendEntry(type);
ResultSetMetaData metaData = result.getMetaData();
for (int i = 1; i <= metaData.getColumnCount(); i++) {
String name = metaData.getColumnLabel(i);
HugeKeys key = MysqlTable.parseKey(name);
Object value = result.getObject(i);
if (value == null) {
assert key == HugeKeys.EXPIRED_TIME;
continue;
}
entry.column(key, value);
}
return entry;
}
use of com.baidu.hugegraph.type.HugeType in project incubator-hugegraph by apache.
the class RocksDBStore method queryNumber.
@Override
public Number queryNumber(Query query) {
Lock readLock = this.storeLock.readLock();
readLock.lock();
try {
this.checkOpened();
HugeType tableType = RocksDBTable.tableType(query);
RocksDBTable table = this.table(tableType);
return table.queryNumber(this.session(tableType), query);
} finally {
readLock.unlock();
}
}
Aggregations