private static StructDataType handleStruct(NewDocumentType dt, StructDataType s) { for (Field f : s.getFieldsThisTypeOnly()) { specialHandleAnnotationReference(dt, f); } extractNestedTypes(dt, s); addType(dt, s); return s; } private static boolean anyParentsHavePayLoad(SDAnnotationType sa, SDDocumentType sdoc) {
@SuppressWarnings("deprecation") private void replaceTemporaryTypesInStruct(StructDataType structDataType, List<DataType> seenStructs) { seenStructs.add(structDataType); for (Field field : structDataType.getFieldsThisTypeOnly()) { DataType fieldType = field.getDataType(); if (fieldType instanceof TemporaryDataType) { field.setDataType(getDataType(fieldType.getCode(), ((TemporaryDataType)fieldType).getDetailedType())); } else { if (!seenStructs.contains(fieldType)) { replaceTemporaryTypes(fieldType, seenStructs); } } } }
private static void extractNestedTypes(NewDocumentType dt, DataType type) { if (type instanceof StructDataType) { StructDataType tmp = (StructDataType) type; extractDataTypesFromFields(dt, tmp.getFieldsThisTypeOnly()); } else if (type instanceof DocumentType) { throw new IllegalArgumentException("Can not handle nested document definitions. In document type '" + dt.getName().toString() + "', we can not define document type '" + type.toString()); } else if (type instanceof CollectionDataType) { CollectionDataType tmp = (CollectionDataType) type; extractNestedTypes(dt, tmp.getNestedType()); addType(dt, tmp.getNestedType()); } else if (type instanceof MapDataType) { MapDataType tmp = (MapDataType) type; extractNestedTypes(dt, tmp.getKeyType()); extractNestedTypes(dt, tmp.getValueType()); addType(dt, tmp.getKeyType()); addType(dt, tmp.getValueType()); } else if (type instanceof TemporaryAnnotationReferenceDataType) { throw new IllegalArgumentException(type.toString()); } } private static boolean testAddType(NewDocumentType dt, DataType type) { return internalAddType(dt, type, true); }
private static StructDataType handleStruct(NewDocumentType dt, SDDocumentType type) { StructDataType s = new StructDataType(type.getName()); for (Field f : type.getDocumentType().contentStruct().getFieldsThisTypeOnly()) { specialHandleAnnotationReference(dt, f); s.addField(f); } for (StructDataType inherited : type.getDocumentType().contentStruct().getInheritedTypes()) { s.inherit(inherited); } extractNestedTypes(dt, s); addType(dt, s); return s; }
compressminsize((int)structType.getCompressionConfig().minsize); for (com.yahoo.document.Field field : structType.getFieldsThisTypeOnly()) { Datatype.Structtype.Field.Builder fieldBuilder = new Datatype.Structtype.Field.Builder(); structBuilder.field(fieldBuilder);