Skip to content

Commit

Permalink
Patch primary key field path parsing e.g. id.value
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunjeet committed Jul 20, 2023
1 parent 1df2e1d commit f42eb1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static com.netflix.hollow.core.HollowConstants.ORDINAL_NONE;
import static com.netflix.hollow.tools.util.SearchUtils.MULTI_FIELD_KEY_DELIMITER;

import com.netflix.hollow.Hollow;
import com.netflix.hollow.core.HollowDataset;
import com.netflix.hollow.core.index.key.PrimaryKey;
import com.netflix.hollow.core.memory.encoding.HashCodes;
Expand Down Expand Up @@ -97,18 +96,20 @@ public void initializeKeySchema(HollowObjectTypeReadState initialTypeState) {
if (isInitialized) return;
HollowObjectSchema schema = initialTypeState.getSchema();

for (String[] keyFieldPart : keyFieldNames) addSchemaField(schema, keyFieldPart, 0);
for (int i= 0; i < keyFieldNames.length; i ++) {
String[] keyFieldPart = keyFieldNames[i];
fieldTypes[i] = addSchemaField(schema, keyFieldPart, 0);
}
isInitialized = true;
}

private void addSchemaField(HollowObjectSchema schema, String[] keyFieldNames, int keyFieldPartPosition) {
private FieldType addSchemaField(HollowObjectSchema schema, String[] keyFieldNames, int keyFieldPartPosition) {
int schemaPosition = schema.getPosition(keyFieldNames[keyFieldPartPosition]);
if (keyFieldPartPosition < keyFieldNames.length - 1) {
HollowObjectSchema nextPartSchema = (HollowObjectSchema) schema.getReferencedTypeState(schemaPosition).getSchema();
addSchemaField(nextPartSchema, keyFieldNames, keyFieldPartPosition + 1);
} else {
fieldTypes[keyFieldPartPosition] = schema.getFieldType(schemaPosition);
return addSchemaField(nextPartSchema, keyFieldNames, keyFieldPartPosition + 1);
}
return schema.getFieldType(schemaPosition);
}

private void initializeKeyParts(HollowDataset dataModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*/
package com.netflix.hollow.tools.history.keyindex;

import static com.netflix.hollow.core.HollowConstants.ORDINAL_NONE;

import com.netflix.hollow.core.index.key.PrimaryKey;
import com.netflix.hollow.core.memory.encoding.HashCodes;
import com.netflix.hollow.core.read.HollowReadFieldUtils;
import com.netflix.hollow.core.read.engine.object.HollowObjectTypeReadState;
import com.netflix.hollow.core.schema.HollowObjectSchema;
import com.netflix.hollow.tools.util.ObjectInternPool;

import static com.netflix.hollow.core.HollowConstants.ORDINAL_NONE;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
Expand Down

0 comments on commit f42eb1a

Please sign in to comment.