Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .asf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
github:
features:
issues: true
# Enable wiki for documentation
wiki: true
# Enable projects for project management boards
# Enable projects for project (task)management boards
projects: true
discussions: true
description: A graph database that supports more than 100+ billion data, high performance and scalability (Include OLTP Engine & REST-API & Backends)
Expand All @@ -46,11 +45,12 @@ github:
required_pull_request_reviews:
dismiss_stale_reviews: true
require_code_owner_reviews: false
required_approving_review_count: 2
required_approving_review_count: 1
# (for non-committer): assign/edit/close issues & PR, without write access to the code
collaborators:
- Pengzna
- haohao0103
- kenssa4eedfd
- Tsukilc

# refer https://cwiki.apache.org/confluence/display/INFRA/Git+-+.asf.yaml+features#Git.asf.yamlfeatures-Notificationsettingsforrepositories
notifications:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,15 @@ public class ServerOptions extends OptionHolder {
"batch.max_vertices_per_batch",
"The maximum number of vertices submitted per batch.",
positiveInt(),
500
2500
);

public static final ConfigOption<Integer> MAX_EDGES_PER_BATCH =
new ConfigOption<>(
"batch.max_edges_per_batch",
"The maximum number of edges submitted per batch.",
positiveInt(),
500
2500
);

public static final ConfigOption<Integer> MAX_WRITE_RATIO =
Expand All @@ -406,7 +406,7 @@ public class ServerOptions extends OptionHolder {
"The maximum thread ratio for batch writing, " +
"only take effect if the batch.max_write_threads is 0.",
rangeInt(0, 100),
50
70
);

public static final ConfigOption<Integer> MAX_WRITE_THREADS =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class EdgeLabelBuilder extends AbstractBuilder
private Set<String> properties;
private List<String> sortKeys;
private Set<String> nullableKeys;
private long ttl;
private Long ttl;
private String ttlStartTime;
private Boolean enableLabelIndex;
private Userdata userdata;
Expand All @@ -80,7 +80,7 @@ public EdgeLabelBuilder(ISchemaTransaction transaction,
this.properties = new HashSet<>();
this.sortKeys = new ArrayList<>();
this.nullableKeys = new HashSet<>();
this.ttl = 0L;
this.ttl = null;
this.ttlStartTime = null;
this.enableLabelIndex = null;
this.userdata = new Userdata();
Expand Down Expand Up @@ -122,11 +122,7 @@ public EdgeLabel build() {
}
edgeLabel.frequency(this.frequency == Frequency.DEFAULT ?
Frequency.SINGLE : this.frequency);
edgeLabel.ttl(this.ttl);
if (this.ttlStartTime != null) {
edgeLabel.ttlStartTime(this.graph().propertyKey(
this.ttlStartTime).id());
}
this.updateTTL(edgeLabel);
edgeLabel.enableLabelIndex(this.enableLabelIndex == null ||
this.enableLabelIndex);
for (String key : this.properties) {
Expand Down Expand Up @@ -209,7 +205,7 @@ public EdgeLabel create() {
this.checkSortKeys();
this.checkNullableKeys(Action.INSERT);
Userdata.check(this.userdata, Action.INSERT);
this.checkTtl();
this.checkTTL();
this.checkUserdata(Action.INSERT);

edgeLabel = this.build();
Expand Down Expand Up @@ -312,6 +308,7 @@ public EdgeLabel append() {
PropertyKey propertyKey = this.graph().propertyKey(key);
edgeLabel.nullableKey(propertyKey.id());
}
this.updateTTL(edgeLabel);
edgeLabel.userdata(this.userdata);
this.graph().updateEdgeLabel(edgeLabel);
return edgeLabel;
Expand Down Expand Up @@ -670,7 +667,35 @@ private void checkStableVars() {
}
}

private void checkTtl() {
/**
* Update TTL in two cases:
* 1) ttl > 0L: set or change a positive TTL
* 2) ttl == 0L and existing ttl > 0L: explicitly clear an existing TTL
* This allows removing TTL from a label that previously had TTL configured.
* Note: ttl == null means not set, so we skip the update.
*/
private void updateTTL(EdgeLabel edgeLabel) {
if (this.ttl == null) {
return;
}
if (this.ttl > 0L) {
edgeLabel.ttl(this.ttl);
if (this.ttlStartTime != null) {
edgeLabel.ttlStartTime(this.graph().propertyKey(this.ttlStartTime).id());
}
} else if (this.ttl == 0L && edgeLabel.ttl() > 0L) {
// Clear TTL and ttlStartTime
edgeLabel.ttl(0L);
edgeLabel.ttlStartTime(IdGenerator.ZERO);
}
}

private void checkTTL() {
if (this.ttl == null) {
E.checkArgument(this.ttlStartTime == null,
"Can't set ttl start time if ttl is not set");
return;
}
E.checkArgument(this.ttl >= 0,
"The ttl must be >= 0, but got: %s", this.ttl);
if (this.ttl == 0L) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class VertexLabelBuilder extends AbstractBuilder implements VertexLabel.B
private final Set<String> properties;
private final List<String> primaryKeys;
private final Set<String> nullableKeys;
private long ttl;
private Long ttl;
private String ttlStartTime;
private Boolean enableLabelIndex;
private final Userdata userdata;
Expand All @@ -68,7 +68,7 @@ public VertexLabelBuilder(ISchemaTransaction transaction,
this.properties = new HashSet<>();
this.primaryKeys = new ArrayList<>();
this.nullableKeys = new HashSet<>();
this.ttl = 0L;
this.ttl = null;
this.ttlStartTime = null;
this.enableLabelIndex = null;
this.userdata = new Userdata();
Expand Down Expand Up @@ -99,13 +99,8 @@ public VertexLabel build() {
this.id, this.name);
VertexLabel vertexLabel = new VertexLabel(this.graph(), id, this.name);
vertexLabel.idStrategy(this.idStrategy);
vertexLabel.enableLabelIndex(this.enableLabelIndex == null ||
this.enableLabelIndex);
vertexLabel.ttl(this.ttl);
if (this.ttlStartTime != null) {
vertexLabel.ttlStartTime(this.graph().propertyKey(
this.ttlStartTime).id());
}
vertexLabel.enableLabelIndex(this.enableLabelIndex == null || this.enableLabelIndex);
this.updateTTL(vertexLabel);
// Assign properties
for (String key : this.properties) {
PropertyKey propertyKey = this.graph().propertyKey(key);
Expand Down Expand Up @@ -142,7 +137,7 @@ public VertexLabel create() {
this.checkIdStrategy();
this.checkNullableKeys(Action.INSERT);
Userdata.check(this.userdata, Action.INSERT);
this.checkTtl();
this.checkTTL();
this.checkUserdata(Action.INSERT);

vertexLabel = this.build();
Expand Down Expand Up @@ -225,6 +220,7 @@ public VertexLabel append() {
PropertyKey propertyKey = this.graph().propertyKey(key);
vertexLabel.nullableKey(propertyKey.id());
}
this.updateTTL(vertexLabel);
vertexLabel.userdata(this.userdata);
this.graph().updateVertexLabel(vertexLabel);
return vertexLabel;
Expand Down Expand Up @@ -276,8 +272,7 @@ public VertexLabelBuilder id(long id) {

@Override
public VertexLabelBuilder idStrategy(IdStrategy idStrategy) {
E.checkArgument(this.idStrategy == IdStrategy.DEFAULT ||
this.idStrategy == idStrategy,
E.checkArgument(this.idStrategy == IdStrategy.DEFAULT || this.idStrategy == idStrategy,
"Not allowed to change id strategy for " +
"vertex label '%s'", this.name);
this.idStrategy = idStrategy;
Expand Down Expand Up @@ -434,18 +429,15 @@ private void checkNullableKeys(Action action) {
if (action == Action.ELIMINATE) {
if (!this.nullableKeys.isEmpty()) {
throw new NotAllowException(
"Not support to eliminate nullableKeys " +
"for vertex label currently");
"Not support to eliminate nullableKeys for vertex label currently");
}
return;
}

VertexLabel vertexLabel = this.vertexLabelOrNull(this.name);
// The originProps is empty when firstly create vertex label
List<String> originProps = vertexLabel == null ?
ImmutableList.of() :
this.graph()
.mapPkId2Name(vertexLabel.properties());
List<String> originProps = vertexLabel == null ? ImmutableList.of() :
this.graph().mapPkId2Name(vertexLabel.properties());
Set<String> appendProps = this.properties;

E.checkArgument(CollectionUtil.union(originProps, appendProps)
Expand All @@ -454,22 +446,18 @@ private void checkNullableKeys(Action action) {
"must belong to the origin/new properties: %s/%s",
this.nullableKeys, originProps, appendProps);

List<String> primaryKeys = vertexLabel == null ?
this.primaryKeys :
this.graph()
.mapPkId2Name(vertexLabel.primaryKeys());
List<String> primaryKeys = vertexLabel == null ? this.primaryKeys :
this.graph().mapPkId2Name(vertexLabel.primaryKeys());
E.checkArgument(!CollectionUtil.hasIntersection(primaryKeys,
this.nullableKeys),
"The nullableKeys: %s are not allowed to " +
"belong to primaryKeys: %s of vertex label '%s'",
this.nullableKeys, primaryKeys, this.name);

if (action == Action.APPEND) {
Collection<String> newAddedProps = CollectionUtils.subtract(
appendProps, originProps);
Collection<String> newAddedProps = CollectionUtils.subtract(appendProps, originProps);
E.checkArgument(this.nullableKeys.containsAll(newAddedProps),
"The new added properties: %s must be nullable",
newAddedProps);
"The new added properties: %s must be nullable", newAddedProps);
}
}

Expand Down Expand Up @@ -498,8 +486,7 @@ private void checkIdStrategy() {
"when using '%s' id strategy", strategy);
break;
default:
throw new AssertionError(String.format(
"Unknown id strategy '%s'", strategy));
throw new AssertionError(String.format("Unknown id strategy '%s'", strategy));
}
if (this.idStrategy == IdStrategy.PRIMARY_KEY) {
this.checkPrimaryKeys();
Expand Down Expand Up @@ -546,7 +533,35 @@ private void checkStableVars() {
}
}

private void checkTtl() {
/**
* Update TTL in two cases:
* 1) ttl > 0L: set or change a positive TTL
* 2) ttl == 0L and existing ttl > 0L: explicitly clear an existing TTL
* This allows removing TTL from a label that previously had TTL configured.
* Note: ttl == null means not set, so we skip the update.
*/
private void updateTTL(VertexLabel vertexLabel) {
if (this.ttl == null) {
return;
}
if (this.ttl > 0L) {
vertexLabel.ttl(this.ttl);
if (this.ttlStartTime != null) {
vertexLabel.ttlStartTime(this.graph().propertyKey(this.ttlStartTime).id());
}
} else if (this.ttl == 0L && vertexLabel.ttl() > 0L) {
// Clear TTL and ttlStartTime
vertexLabel.ttl(0L);
vertexLabel.ttlStartTime(IdGenerator.ZERO);
}
}

private void checkTTL() {
if (this.ttl == null) {
E.checkArgument(this.ttlStartTime == null,
"Can't set ttl start time if ttl is not set");
return;
}
E.checkArgument(this.ttl >= 0,
"The ttl must be >= 0, but got: %s", this.ttl);
if (this.ttl == 0L) {
Expand Down Expand Up @@ -588,8 +603,7 @@ private void checkUserdata(Action action) {
// pass
break;
default:
throw new AssertionError(String.format(
"Unknown schema action '%s'", action));
throw new AssertionError(String.format("Unknown schema action '%s'", action));
}
}

Expand Down
Loading
Loading