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

cleanup #6

Merged
merged 2 commits into from
Jan 28, 2024
Merged
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
21 changes: 3 additions & 18 deletions src/main/java/dev/morling/onebrc/CalculateAverage_bytesfellow.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ void processSlice(byte[] slice) {

scheduler.execute(() -> {
List<List<LineParams>> partitionedLines = new ArrayList<>(partitionsSize());
IntStream.range(0, partitionsSize()).forEach((p) -> partitionedLines.add(new ArrayList<>(slice.length / 116 / 2))); // 116 is the max line len incl new line char
// allocate some capacity, assuming that on average lines are half of the max (407 bytes) length
IntStream.range(0, partitionsSize()).forEach((p) -> partitionedLines.add(new ArrayList<>(slice.length / 407 / 2)));

int start = 0;
int i = 0;
Expand Down Expand Up @@ -264,17 +265,6 @@ public Station(Station from) {
this.hash = from.hash;
}

private int hashCode109() {
if (len == 0)
return 0;
int h = inputSlice[startIdx];
for (int i = startIdx + 1; i < startIdx + len; i++) {
h = (h << 7) + inputSlice[i];
}
h *= 109;
return h;
}

private int hashcodeFast() {
if (len == 0) {
return 0;
Expand Down Expand Up @@ -306,13 +296,8 @@ public boolean equals(Object o) {
if (len != station.len) {
return false;
}
for (int i = 0; i < len; i++) {
if (inputSlice[startIdx + i] != station.inputSlice[station.startIdx + i]) {
return false;
}
}

return true;
return Arrays.equals(inputSlice, startIdx, startIdx + len, station.inputSlice, station.startIdx, station.startIdx + len);
}

@Override
Expand Down