use of org.apache.asterix.om.types.AbstractCollectionType in project asterixdb by apache.
the class TypeResolverUtilTest method testUnorderedListType.
@Test
public void testUnorderedListType() {
// Constructs input types.
ARecordType leftRecordType = new ARecordType(null, new String[] { "a", "b" }, new IAType[] { BuiltinType.ASTRING, BuiltinType.AINT32 }, true, Collections.singleton("d"));
AUnorderedListType leftListType = new AUnorderedListType(leftRecordType, null);
AUnorderedListType rightListType = new AUnorderedListType(BuiltinType.ASTRING, null);
// Gets the actual resolved type.
List<IAType> inputTypes = new ArrayList<>();
inputTypes.add(leftListType);
inputTypes.add(rightListType);
AbstractCollectionType resolvedType = (AbstractCollectionType) TypeResolverUtil.resolve(inputTypes);
// Compares the resolved type and the expected type.
Assert.assertEquals(resolvedType, new AUnorderedListType(BuiltinType.ANY, null));
}
use of org.apache.asterix.om.types.AbstractCollectionType in project asterixdb by apache.
the class RecordFieldsUtil method processListValue.
public void processListValue(IValueReference listArg, IAType fieldType, DataOutput out, int level) throws AsterixException, IOException {
ArrayBackedValueStorage itemValue = getTempBuffer();
IARecordBuilder listRecordBuilder = getRecordBuilder();
AListPointable list = getListPointable();
list.set(listArg);
OrderedListBuilder innerListBuilder = getOrderedListBuilder();
innerListBuilder.reset(listType);
listRecordBuilder.reset(null);
AbstractCollectionType act = (AbstractCollectionType) fieldType;
int itemCount = list.getItemCount();
for (int l = 0; l < itemCount; l++) {
itemValue.reset();
listRecordBuilder.init();
byte tagId = list.getItemTag(act, l);
addFieldType(tagId, listRecordBuilder);
if (tagId == ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
ArrayBackedValueStorage tmpAbvs = getTempBuffer();
list.getItemValue(act, l, tmpAbvs.getDataOutput());
addNestedField(tmpAbvs, act.getItemType(), listRecordBuilder, level + 1);
}
listRecordBuilder.write(itemValue.getDataOutput(), true);
innerListBuilder.addItem(itemValue);
}
innerListBuilder.write(out, true);
}
Aggregations