-
Notifications
You must be signed in to change notification settings - Fork 525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refact(core): optimized batch removal of remaining indices consumed by a single consumer #2203
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d837517
chore: single task and batch consume remove left index task
zyxxoo e29bcdd
improve code
zyxxoo ec857a3
improve
zyxxoo 134cd52
improve
zyxxoo 616c64d
improve
zyxxoo d834204
improve
zyxxoo 83923bb
improve
zyxxoo a124f30
fix: rocksdb
zyxxoo 64cf79e
improve
zyxxoo 8ed14d8
improve
zyxxoo df28ad9
improve
zyxxoo d087eca
improve
zyxxoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
import org.apache.hugegraph.backend.page.PageState; | ||
import org.apache.hugegraph.backend.store.BackendEntry; | ||
import org.apache.hugegraph.backend.store.BackendStore; | ||
import org.apache.hugegraph.task.EphemeralJobQueue; | ||
import org.apache.tinkerpop.gremlin.structure.Edge; | ||
import org.apache.tinkerpop.gremlin.structure.Vertex; | ||
import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator; | ||
|
@@ -69,7 +70,6 @@ | |
import org.apache.hugegraph.exception.NotSupportException; | ||
import org.apache.hugegraph.iterator.Metadatable; | ||
import org.apache.hugegraph.job.EphemeralJob; | ||
import org.apache.hugegraph.job.EphemeralJobBuilder; | ||
import org.apache.hugegraph.job.system.DeleteExpiredJob; | ||
import org.apache.hugegraph.perf.PerfUtil.Watched; | ||
import org.apache.hugegraph.schema.IndexLabel; | ||
|
@@ -81,7 +81,6 @@ | |
import org.apache.hugegraph.structure.HugeIndex.IdWithExpiredTime; | ||
import org.apache.hugegraph.structure.HugeProperty; | ||
import org.apache.hugegraph.structure.HugeVertex; | ||
import org.apache.hugegraph.task.HugeTask; | ||
import org.apache.hugegraph.type.HugeType; | ||
import org.apache.hugegraph.type.define.Action; | ||
import org.apache.hugegraph.type.define.HugeKeys; | ||
|
@@ -115,15 +114,11 @@ public GraphIndexTransaction(HugeGraphParams graph, BackendStore store) { | |
conf.get(CoreOptions.QUERY_INDEX_INTERSECT_THRESHOLD); | ||
} | ||
|
||
protected Id asyncRemoveIndexLeft(ConditionQuery query, | ||
HugeElement element) { | ||
protected void asyncRemoveIndexLeft(ConditionQuery query, | ||
HugeElement element) { | ||
LOG.info("Remove left index: {}, query: {}", element, query); | ||
RemoveLeftIndexJob job = new RemoveLeftIndexJob(query, element); | ||
HugeTask<?> task = EphemeralJobBuilder.of(this.graph()) | ||
.name(element.id().asString()) | ||
.job(job) | ||
.schedule(); | ||
return task.id(); | ||
this.params().submitEphemeralJob(job); | ||
} | ||
|
||
@Watched(prefix = "index") | ||
|
@@ -1717,7 +1712,8 @@ private static Query parent(Collection<Query> queries) { | |
} | ||
} | ||
|
||
public static class RemoveLeftIndexJob extends EphemeralJob<Object> { | ||
public static class RemoveLeftIndexJob extends EphemeralJob<Long> | ||
zyxxoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
implements EphemeralJobQueue.Reduce<Long> { | ||
|
||
private static final String REMOVE_LEFT_INDEX = "remove_left_index"; | ||
|
||
|
@@ -1741,7 +1737,7 @@ public String type() { | |
} | ||
|
||
@Override | ||
public Object execute() { | ||
public Long execute() { | ||
this.tx = this.element.schemaLabel().system() ? | ||
this.params().systemTransaction().indexTransaction() : | ||
this.params().graphTransaction().indexTransaction(); | ||
|
@@ -1780,7 +1776,6 @@ protected long removeIndexLeft(ConditionQuery query, | |
// Process secondary index or search index | ||
sCount += this.processSecondaryOrSearchIndexLeft(cq, element); | ||
} | ||
this.tx.commit(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so we don't support auto commit anymore? |
||
return rCount + sCount; | ||
} | ||
|
||
|
@@ -1808,7 +1803,6 @@ private long processRangeIndexLeft(ConditionQuery query, | |
} | ||
// Remove LeftIndex after constructing remove job | ||
this.query.removeElementLeftIndex(element.id()); | ||
this.tx.commit(); | ||
return count; | ||
} | ||
|
||
|
@@ -1873,11 +1867,9 @@ private long processSecondaryOrSearchIndexLeft(ConditionQuery query, | |
*/ | ||
this.tx.updateIndex(il.id(), element, false); | ||
} | ||
this.tx.commit(); | ||
if (this.deletedByError(element, incorrectIndexFields, | ||
incorrectPKs)) { | ||
this.tx.updateIndex(il.id(), deletion, false); | ||
this.tx.commit(); | ||
} else { | ||
count++; | ||
} | ||
|
@@ -1949,5 +1941,18 @@ private HugeElement newestElement(HugeElement element) { | |
return (HugeEdge) QueryResults.one(iter); | ||
} | ||
} | ||
|
||
@Override | ||
public Long reduce(Long t1, Long t2) { | ||
if (t1 == null) { | ||
return t2; | ||
} | ||
|
||
if (t2 == null) { | ||
return t1; | ||
} | ||
|
||
return t1 + t2; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better to use
/* */
next time