Skip to content

Commit

Permalink
inherit directly
Browse files Browse the repository at this point in the history
* instead of indirect (temporary) inherit from name, inherit
  the already-converted document directly.
* keep schema order.
  • Loading branch information
arnej27959 committed Mar 11, 2022
1 parent 759f0f2 commit 7a8ad22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
import com.yahoo.vespa.documentmodel.SummaryField;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
Expand Down Expand Up @@ -122,6 +124,8 @@ public void convertTypes() {
typeConverter.convert(true);
}

private Map<String, SDDocumentType> convertedDocuments = new LinkedHashMap();

public List<Schema> convertToSchemas() {
typeConverter = new ConvertParsedTypes(orderedInput, docMan);
typeConverter.convert(false);
Expand Down Expand Up @@ -150,7 +154,9 @@ private void convertDocument(Schema schema, ParsedDocument parsed,
{
SDDocumentType document = new SDDocumentType(parsed.name());
for (String inherit : parsed.getInherited()) {
document.inherit(new DataTypeName(inherit));
var parent = convertedDocuments.get(inherit);
assert(parent != null);
document.inherit(parent);
}
for (var struct : parsed.getStructs()) {
var structProxy = fieldConverter.convertStructDeclaration(schema, struct);
Expand All @@ -165,6 +171,7 @@ private void convertDocument(Schema schema, ParsedDocument parsed,
document.setFieldId(sdf, field.idOverride());
}
}
convertedDocuments.put(parsed.name(), document);
schema.addDocument(document);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -27,7 +27,7 @@ public class IntermediateCollection {
private final DeployLogger deployLogger;
private final ModelContext.Properties modelProperties;

private Map<String, ParsedSchema> parsedSchemas = new HashMap<>();
private Map<String, ParsedSchema> parsedSchemas = new LinkedHashMap<>();

IntermediateCollection() {
this.deployLogger = new BaseDeployLogger();
Expand Down

0 comments on commit 7a8ad22

Please sign in to comment.