-
Notifications
You must be signed in to change notification settings - Fork 1
fix: DH-18265 - correct bugs in replace() function
#2
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
Merged
devinrsmith
merged 6 commits into
deephaven:main
from
lbooker42:nightly/DH-18265-lab-kohash-bugfix
Jan 28, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3086ee0
Initial commit of bug-fix and tests.
lbooker42 5f8ffd7
Correct accidental edit.
lbooker42 daa0b1c
Add exception for replace() with oldValue==null
lbooker42 517c4da
Spotless applied
lbooker42 15188b8
Implemented correction to Double variant, added double to existing te…
lbooker42 7a2fbaa
Fix test failure
lbooker42 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
93 changes: 93 additions & 0 deletions
93
src/test/java/io/deephaven/hash/KeyedDoubleTestObject.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /* | ||
| Copyright (C) 2021 Deephaven Data Labs (https://deephaven.io). | ||
|
|
||
| This program is free software: you can redistribute it and/or modify it under the terms of the | ||
| GNU Lesser General Public License as published by the Free Software Foundation, either version 3 | ||
| of the License, or (at your option) any later version. | ||
|
|
||
| This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
| without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU Lesser General Public License for more details. | ||
| */ | ||
| package io.deephaven.hash; | ||
|
|
||
| /** Test class. */ | ||
| class KeyedDoubleTestObject { | ||
| private final double id; | ||
|
|
||
| public KeyedDoubleTestObject(double id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public double getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public boolean equals(Object other) { | ||
| return other instanceof KeyedDoubleTestObject && id == ((KeyedDoubleTestObject) other).id; | ||
| } | ||
|
|
||
| public int hashCode() { | ||
| return ~Double.hashCode(id); // do something different that gnu.trove.HashFunctions.hash(double) | ||
| } | ||
|
|
||
| public String toString() { | ||
| return "[KeyedDoubleTestObject:" + id + "]"; | ||
| } | ||
|
|
||
| public static final KeyedDoubleObjectKey<KeyedDoubleTestObject> keyDef = | ||
| new KeyedDoubleObjectKey<KeyedDoubleTestObject>() { | ||
| public Double getKey(KeyedDoubleTestObject v) { | ||
| return v.getId(); | ||
| } | ||
|
|
||
| public double getDoubleKey(KeyedDoubleTestObject v) { | ||
| return v.getId(); | ||
| } | ||
|
|
||
| public int hashKey(Double k) { | ||
| return k.hashCode(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equalKey(Double k, KeyedDoubleTestObject v) { | ||
| return v.getId() == k; | ||
| } | ||
|
|
||
| public int hashDoubleKey(double k) { | ||
| return Double.hashCode(k); | ||
| } | ||
|
|
||
| public boolean equalDoubleKey(double k, KeyedDoubleTestObject v) { | ||
| return v.getId() == k; | ||
| } | ||
| }; | ||
|
|
||
| public static final KeyedIntObjectHash.ValueFactory<KeyedDoubleTestObject> factory = | ||
| new KeyedIntObjectHash.ValueFactory<KeyedDoubleTestObject>() { | ||
| public KeyedDoubleTestObject newValue(Integer key) { | ||
| return new KeyedDoubleTestObject(key); | ||
| } | ||
|
|
||
| public KeyedDoubleTestObject newValue(int key) { | ||
| return new KeyedDoubleTestObject(key); | ||
| } | ||
| }; | ||
|
|
||
| // for intrusive chained maps | ||
|
|
||
| private KeyedDoubleTestObject next; | ||
|
|
||
| public static final IntrusiveChainedHashAdapter<KeyedDoubleTestObject> adapter = | ||
| new IntrusiveChainedHashAdapter<KeyedDoubleTestObject>() { | ||
| @Override | ||
| public KeyedDoubleTestObject getNext(KeyedDoubleTestObject self) { | ||
| return self.next; | ||
| } | ||
|
|
||
| @Override | ||
| public void setNext(KeyedDoubleTestObject self, KeyedDoubleTestObject next) { | ||
| self.next = next; | ||
| } | ||
| }; | ||
| } |
31 changes: 31 additions & 0 deletions
31
src/test/java/io/deephaven/hash/KeyedDoubleTestObjectMap.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| Copyright (C) 2021 Deephaven Data Labs (https://deephaven.io). | ||
|
|
||
| This program is free software: you can redistribute it and/or modify it under the terms of the | ||
| GNU Lesser General Public License as published by the Free Software Foundation, either version 3 | ||
| of the License, or (at your option) any later version. | ||
|
|
||
| This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
| without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU Lesser General Public License for more details. | ||
| */ | ||
| package io.deephaven.hash; | ||
|
|
||
| /** Instantiation of KeyedDoubleObjectHashMap on the test class. */ | ||
| class KeyedDoubleTestObjectMap extends KeyedDoubleObjectHashMap<KeyedDoubleTestObject> { | ||
| public KeyedDoubleTestObjectMap() { | ||
| super(KeyedDoubleTestObject.keyDef); | ||
| } | ||
|
|
||
| public KeyedDoubleTestObjectMap(int initialCapacity) { | ||
| super(initialCapacity, KeyedDoubleTestObject.keyDef); | ||
| } | ||
|
|
||
| public KeyedDoubleTestObjectMap(int initialCapacity, float loadFactor) { | ||
| super(initialCapacity, loadFactor, KeyedDoubleTestObject.keyDef); | ||
| } | ||
|
|
||
| public final double getId(KeyedDoubleTestObject obj) { | ||
| return obj.getId(); | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.