|
16 | 16 | */
|
17 | 17 | package com.netflix.hollow.tools.history.keyindex;
|
18 | 18 |
|
| 19 | +import static com.netflix.hollow.core.HollowConstants.ORDINAL_NONE; |
| 20 | + |
19 | 21 | import com.netflix.hollow.core.index.key.PrimaryKey;
|
20 | 22 | import com.netflix.hollow.core.memory.encoding.HashCodes;
|
21 | 23 | import com.netflix.hollow.core.read.HollowReadFieldUtils;
|
22 | 24 | import com.netflix.hollow.core.read.engine.object.HollowObjectTypeReadState;
|
23 | 25 | import com.netflix.hollow.core.schema.HollowObjectSchema;
|
| 26 | +import com.netflix.hollow.core.schema.HollowObjectSchema.FieldType; |
24 | 27 | import com.netflix.hollow.core.util.IntList;
|
25 | 28 | import com.netflix.hollow.tools.util.ObjectInternPool;
|
26 |
| -import com.netflix.hollow.core.schema.HollowObjectSchema.FieldType; |
27 |
| - |
28 |
| -import static com.netflix.hollow.core.HollowConstants.ORDINAL_NONE; |
29 |
| - |
30 | 29 | import java.util.Arrays;
|
31 | 30 |
|
32 | 31 | public class HollowOrdinalMapper {
|
@@ -218,14 +217,17 @@ private void expandAndRehashTable() {
|
218 | 217 | if(ordinalList==null || ordinalList.size()==0)
|
219 | 218 | continue;
|
220 | 219 |
|
221 |
| - // Recompute original hash, based on the fact that all objects in this IntList have the same hash |
222 |
| - |
223 |
| - Object originalFieldObject = getFieldObject(ordinalList.get(0), fieldIdx, keyFieldTypes[fieldIdx]); |
224 |
| - |
225 |
| - int originalHash = hashObject(originalFieldObject); |
226 |
| - int newIndex = indexFromHash(originalHash, newTable.length); |
227 |
| - |
228 |
| - newFieldHashToOrdinal[fieldIdx][newIndex]=ordinalList; |
| 220 | + // Recompute original hash, objects in the IntList don't necessarily share the same hash (see indexFromHash) |
| 221 | + for (int i=0;i<ordinalList.size();i++) { |
| 222 | + int ordinal = ordinalList.get(i); |
| 223 | + Object originalFieldObject = getFieldObject(ordinal, fieldIdx, keyFieldTypes[fieldIdx]); |
| 224 | + int originalHash = hashObject(originalFieldObject); |
| 225 | + int newIndex = indexFromHash(originalHash, newTable.length); |
| 226 | + if (newFieldHashToOrdinal[fieldIdx][newIndex] == null) { |
| 227 | + newFieldHashToOrdinal[fieldIdx][newIndex] = new IntList(); |
| 228 | + } |
| 229 | + newFieldHashToOrdinal[fieldIdx][newIndex].add(ordinal); |
| 230 | + } |
229 | 231 | }
|
230 | 232 | }
|
231 | 233 |
|
|
0 commit comments