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

reduce Extent serialization to 16 bytes #49611

Closed
Closed
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
34 changes: 28 additions & 6 deletions server/src/main/java/org/elasticsearch/common/geo/Extent.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* {@link GeometryTreeWriter} and {@link EdgeTreeWriter}.
*/
public class Extent implements Writeable {
static final int WRITEABLE_SIZE_IN_BYTES = 24;
static final int WRITEABLE_SIZE_IN_BYTES = 16;

public final int top;
public final int bottom;
Expand All @@ -49,7 +49,31 @@ public Extent(int top, int bottom, int negLeft, int negRight, int posLeft, int p
}

Extent(StreamInput input) throws IOException {
this(input.readInt(), input.readInt(), input.readInt(), input.readInt(), input.readInt(), input.readInt());
this.top = input.readInt();
this.bottom = input.readInt();

int left = input.readInt();
int right = input.readInt();

int negLeft = Integer.MAX_VALUE;
int negRight = Integer.MIN_VALUE;
int posLeft = Integer.MAX_VALUE;
int posRight = Integer.MIN_VALUE;
if (left < 0 && right < 0) {
negLeft = left;
negRight = right;
} else if (left < 0) {
negLeft = negRight = left;
posLeft = posRight = right;
} else {
posLeft = left;
posRight = right;
}

this.negLeft = negLeft;
this.negRight = negRight;
this.posLeft = posLeft;
this.posRight = posRight;
}

/**
Expand Down Expand Up @@ -128,10 +152,8 @@ public int maxX() {
public void writeTo(StreamOutput out) throws IOException {
out.writeInt(top);
out.writeInt(bottom);
out.writeInt(negLeft);
out.writeInt(negRight);
out.writeInt(posLeft);
out.writeInt(posRight);
out.writeInt(minX());
out.writeInt(maxX());
}

@Override
Expand Down