Skip to content
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

Refactor UpdateLog.LogPtr to a record #3166

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
43 changes: 8 additions & 35 deletions solr/core/src/java/org/apache/solr/update/UpdateLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,40 +268,13 @@ public String toString() {
protected Meter copyOverOldUpdatesMeter;
protected SolrMetricsContext solrMetricsContext;

public static class LogPtr {
final long pointer;
final long version;
// used for entries that are in-place updates and need a pointer to a previous update command
final long previousPointer;
Comment on lines -274 to -275
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was in here since when it first showed up like 10 years ago, and even then wasn't actually used. Populated but not referenced. CC @chatman


/**
* Creates an object that contains the position and version of an update. In this constructor,
* the effective value of the previousPointer is -1.
*
* @param pointer Position in the transaction log of an update
* @param version Version of the update at the given position
*/
public LogPtr(long pointer, long version) {
this(pointer, version, -1);
}

/**
* @param pointer Position in the transaction log of an update
* @param version Version of the update at the given position
* @param previousPointer Position, in the transaction log, of an update on which the current
* update depends
*/
public LogPtr(long pointer, long version, long previousPointer) {
this.pointer = pointer;
this.version = version;
this.previousPointer = previousPointer;
}

@Override
public String toString() {
return "LogPtr(" + pointer + ")";
}
}
/**
* Pointer into the log with a version.
*
* @param pointer Position in the transaction log of an update
* @param version Version of the update at the given position
*/
protected record LogPtr(long pointer, long version) {}

public long getTotalLogsSize() {
long size = 0;
Expand Down Expand Up @@ -778,7 +751,7 @@ public void add(AddUpdateCommand cmd, boolean clearCaches) {
if (!clearCaches) {
// TODO: in the future we could support a real position for a REPLAY update.
// Only currently would be useful for RTG while in recovery mode though.
LogPtr ptr = new LogPtr(pos, cmd.getVersion(), prevPointer);
LogPtr ptr = new LogPtr(pos, cmd.getVersion());

map.put(cmd.getIndexedId(), ptr);

Expand Down
Loading