From 861304252f8923f4365b32a0234f0659d7d34e81 Mon Sep 17 00:00:00 2001 From: Drew Koszewnik Date: Wed, 28 Apr 2021 10:19:55 -0700 Subject: [PATCH] Allow loading of states on consumers where non-loaded types are defined in hash keys of loaded types. --- .../java/com/netflix/hollow/core/index/FieldPaths.java | 2 +- .../core/read/engine/map/HollowMapTypeReadState.java | 10 ++++++++-- .../core/read/engine/set/HollowSetTypeReadState.java | 10 ++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/hollow/src/main/java/com/netflix/hollow/core/index/FieldPaths.java b/hollow/src/main/java/com/netflix/hollow/core/index/FieldPaths.java index a6b5cb1a46..1e2f90fc59 100644 --- a/hollow/src/main/java/com/netflix/hollow/core/index/FieldPaths.java +++ b/hollow/src/main/java/com/netflix/hollow/core/index/FieldPaths.java @@ -227,7 +227,7 @@ static FieldPath createFieldPath( /** * An exception contain structured information when a field path cannot be bound. */ - static final class FieldPathException extends IllegalArgumentException { + public static final class FieldPathException extends IllegalArgumentException { enum ErrorKind { NOT_BINDABLE, NOT_FOUND, diff --git a/hollow/src/main/java/com/netflix/hollow/core/read/engine/map/HollowMapTypeReadState.java b/hollow/src/main/java/com/netflix/hollow/core/read/engine/map/HollowMapTypeReadState.java index 256de5f91a..d7d0220b78 100644 --- a/hollow/src/main/java/com/netflix/hollow/core/read/engine/map/HollowMapTypeReadState.java +++ b/hollow/src/main/java/com/netflix/hollow/core/read/engine/map/HollowMapTypeReadState.java @@ -22,6 +22,7 @@ import com.netflix.hollow.api.sampling.HollowMapSampler; import com.netflix.hollow.api.sampling.HollowSampler; import com.netflix.hollow.api.sampling.HollowSamplingDirector; +import com.netflix.hollow.core.index.FieldPaths.FieldPathException; import com.netflix.hollow.core.index.key.HollowPrimaryKeyValueDeriver; import com.netflix.hollow.core.memory.MemoryMode; import com.netflix.hollow.core.memory.encoding.VarInt; @@ -300,8 +301,13 @@ public HollowPrimaryKeyValueDeriver getKeyDeriver() { } public void buildKeyDeriver() { - if(getSchema().getHashKey() != null) - this.keyDeriver = new HollowPrimaryKeyValueDeriver(getSchema().getHashKey(), getStateEngine()); + if(getSchema().getHashKey() != null) { + try { + this.keyDeriver = new HollowPrimaryKeyValueDeriver(getSchema().getHashKey(), getStateEngine()); + } catch(FieldPathException ex) { + ex.printStackTrace(); + } + } for(int i=0; i