From 1df2e1de7ef15fc75dcb90cac8f06786bcd96172 Mon Sep 17 00:00:00 2001 From: Sunjeet Singh Date: Wed, 28 Jun 2023 11:06:12 -0700 Subject: [PATCH] Patch for preserving addTypeIndex's additive behavior --- .../tools/history/keyindex/HollowHistoryKeyIndex.java | 9 +++++++++ .../history/keyindex/HollowHistoryTypeKeyIndex.java | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryKeyIndex.java b/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryKeyIndex.java index 1f163308ab..5cf315573e 100644 --- a/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryKeyIndex.java +++ b/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryKeyIndex.java @@ -64,7 +64,16 @@ public void addTypeIndex(PrimaryKey primaryKey) { } public HollowHistoryTypeKeyIndex addTypeIndex(PrimaryKey primaryKey, HollowDataset dataModel) { + HollowHistoryTypeKeyIndex prevKeyIdx = typeKeyIndexes.get(primaryKey.getType()); HollowHistoryTypeKeyIndex keyIdx = new HollowHistoryTypeKeyIndex(primaryKey, dataModel); + // retain any previous indexed fields + if (prevKeyIdx != null) { + for (int i = 0; i < prevKeyIdx.getKeyFields().length; i++) { + if (prevKeyIdx.getKeyFieldIsIndexed()[i]) { + keyIdx.addFieldIndex(prevKeyIdx.getKeyFields()[i], dataModel); + } + } + } typeKeyIndexes.put(primaryKey.getType(), keyIdx); return keyIdx; } diff --git a/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryTypeKeyIndex.java b/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryTypeKeyIndex.java index 314b65ff04..d6852bcb67 100644 --- a/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryTypeKeyIndex.java +++ b/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryTypeKeyIndex.java @@ -78,6 +78,10 @@ public String[] getKeyFields() { return primaryKey.getFieldPaths(); } + public boolean[] getKeyFieldIsIndexed() { + return keyFieldIsIndexed; + } + public void addFieldIndex(String fieldName, HollowDataset dataModel) { String[] fieldPathParts = PrimaryKey.getCompleteFieldPathParts(dataModel, primaryKey.getType(), fieldName); for (int i = 0; i < primaryKey.numFields(); i++) {