@Override protected void register(DocumentTypeManager manager, List<DataType> seenTypes) { seenTypes.add(this); if (!seenTypes.contains(getNestedType())) { //we haven't seen this one before, register it: getNestedType().register(manager, seenTypes); } super.register(manager, seenTypes); }
public ArrayDataType clone() { return (ArrayDataType) super.clone(); }
private void replaceTemporaryTypesInCollection(CollectionDataType collectionDataType, List<DataType> seenStructs) { if (collectionDataType.getNestedType() instanceof TemporaryDataType) { collectionDataType.setNestedType(getDataType(collectionDataType.getNestedType().getCode(), "")); } else { replaceTemporaryTypes(collectionDataType.getNestedType(), seenStructs); } }
} else if (dataType instanceof CollectionDataType) { CollectionDataType lstType = (CollectionDataType)dataType; DataType nestedType = specialHandleAnnotationReferenceRecurse(docType, fieldName, lstType.getNestedType()); if (nestedType == null) { return null; lstType = lstType.clone(); lstType.setNestedType(nestedType); addType(docType, lstType); return lstType;
public static int classId = registerClass(Ids.document + 53, CollectionDataType.class);
@Override public boolean isValueCompatible(FieldValue value) { if (!(value instanceof CollectionFieldValue)) { return false; } CollectionFieldValue cfv = (CollectionFieldValue) value; if (equals(cfv.getDataType())) { //the field value if of this type: return true; } return false; }
@Override public void visitMembers(ObjectVisitor visitor) { super.visitMembers(visitor); visitor.visit("removeIfZero", removeIfZero); visitor.visit("createIfNonExistent", createIfNonExistent); }
private static DataType valueTypeForMapUpdate(DataType parentType) { if (parentType instanceof WeightedSetDataType) { return DataType.INT; } else if (parentType instanceof CollectionDataType) { return ((CollectionDataType) parentType).getNestedType(); } else if (parentType instanceof MapDataType) { return ((MapDataType) parentType).getValueType(); } else { throw new UnsupportedOperationException("Unexpected parent type: " + parentType); } }
} else if (type instanceof CollectionDataType) { CollectionDataType t = (CollectionDataType) type; t.setNestedType(resolveTemporariesRecurse(t.getNestedType(), repo, docs)); } else if (type instanceof ReferenceDataType) { ReferenceDataType t = (ReferenceDataType) type;
@Override public WeightedSetDataType clone() { return (WeightedSetDataType) super.clone(); }
public DataType getFirstStructOrMapRecursive() { DataType dataType = getDataType(); while (dataType instanceof CollectionDataType) { // Currently no nesting of collections dataType = ((CollectionDataType)dataType).getNestedType(); } return (dataType instanceof StructDataType || dataType instanceof MapDataType) ? dataType : null; }
public void verifyElementCompatibility(T o) { if (!getDataType().getNestedType().isValueCompatible(o)) { throw new IllegalArgumentException( "Incompatible data types. Got " + o.getDataType() + ", expected " + getDataType().getNestedType()); } }
private void validateDataTypeForCollectionField(SDField field) { if (((CollectionDataType)field.getDataType()).getNestedType() instanceof TensorDataType) fail(search, field, "A field with collection type of tensor is not supported. Use simple type 'tensor' instead."); }
@Override public void write(RemoveValueUpdate update, DataType superType) { writeValue(this, ((CollectionDataType)superType).getNestedType(), update.getValue()); }
@Override public void write(RemoveValueUpdate update, DataType superType) { writeValue(this, ((CollectionDataType)superType).getNestedType(), update.getValue()); }
public StructDataType getFirstStructRecursive() { DataType dataType = getDataType(); while (true) { // Currently no nesting of collections if (dataType instanceof CollectionDataType) { dataType = ((CollectionDataType)dataType).getNestedType(); } else if (dataType instanceof MapDataType) { dataType = ((MapDataType)dataType).getValueType(); } else { break; } } return (dataType instanceof StructDataType) ? (StructDataType)dataType : null; }
/** Sets the right index type from a field type */ public static Type convertType(DataType fieldType) { FieldValue fval = fieldType.createFieldValue(); if (fieldType instanceof NumericDataType) { return Type.INT64; } else if (fval instanceof StringFieldValue) { return Type.TEXT; } else if (fval instanceof Raw) { return Type.BOOLEANTREE; } else if (fval instanceof PredicateFieldValue) { return Type.BOOLEANTREE; } else if (fieldType instanceof CollectionDataType) { return convertType(((CollectionDataType) fieldType).getNestedType()); } else { throw new IllegalArgumentException("Don't know which index type to " + "convert " + fieldType + " to"); } } }
/** * Utility function to wrap primitives. * * @see Array.ListWrapper */ protected FieldValue createFieldValue(Object o) { if (o instanceof FieldValue) { if (!getDataType().getNestedType().isValueCompatible((FieldValue) o)) { throw new IllegalArgumentException( "Incompatible data types. Got " + ((FieldValue)o).getDataType() + ", expected " + getDataType().getNestedType()); } return (FieldValue) o; } else { FieldValue fval = getDataType().getNestedType().createFieldValue(); fval.assign(o); return fval; } }
private boolean doCheck(SDField field) { if (field.getDataType() instanceof NumericDataType) return true; if (field.getDataType() instanceof CollectionDataType) { if (((CollectionDataType)field.getDataType()).getNestedType() instanceof NumericDataType) { return true; } } return false; } }
private boolean isUriField(ImmutableSDField field) { DataType fieldType = field.getDataType(); if (DataType.URI.equals(fieldType)) { return true; } if (fieldType instanceof CollectionDataType && DataType.URI.equals(((CollectionDataType)fieldType).getNestedType())) { return true; } return false; }