Skip to content

Commit

Permalink
Added in patches from Sunjeet
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenewald committed Aug 12, 2023
1 parent e6cb925 commit 5a13cd1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -73,6 +82,7 @@ public void indexTypeField(String type, String keyFieldPath) {
typeKeyIndexes.get(type).addFieldIndex(keyFieldPath, history.getLatestState());
}


public void indexTypeField(PrimaryKey primaryKey) {
indexTypeField(primaryKey, history.getLatestState());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,24 @@ 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);
}

public boolean[] getKeyFieldIsIndexed() {
return keyFieldIsIndexed;
}

private void initializeKeyParts(HollowDataset dataModel) {
Expand Down

0 comments on commit 5a13cd1

Please sign in to comment.