-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from lbooker42/nightly/DH-18265-lab-kohash-bugfix
fix: DH-18265 - correct bugs in `replace()` function
- Loading branch information
Showing
10 changed files
with
709 additions
and
11 deletions.
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
93 changes: 93 additions & 0 deletions
93
src/test/java/io/deephaven/hash/KeyedDoubleTestObject.java
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 |
---|---|---|
@@ -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 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.