use of org.apache.asterix.om.types.ARecordType in project asterixdb by apache.
the class ARecordSerializerDeserializerTest method test.
@Test
public void test() {
// Generates types.
ARecordType addrRecordType = SerializerDeserializerTestUtils.generateAddressRecordType();
ARecordType employeeType = SerializerDeserializerTestUtils.generateEmployeeRecordType(addrRecordType);
//Generates records.
ARecord[] records = SerializerDeserializerTestUtils.generateRecords(addrRecordType, employeeType);
ARecordSerializerDeserializer serde = new ARecordSerializerDeserializer(employeeType);
// Run four test threads to serialize/deserialize records concurrently.
SerializerDeserializerTestUtils.concurrentSerDeTestRun(serde, records);
}
use of org.apache.asterix.om.types.ARecordType 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.ARecordType in project asterixdb by apache.
the class TypeResolverUtilTest method testNullType.
@Test
public void testNullType() {
ARecordType leftRecordType = new ARecordType(null, new String[] { "a", "b" }, new IAType[] { BuiltinType.ASTRING, BuiltinType.AINT32 }, false, null);
List<IAType> inputTypes = new ArrayList<>();
inputTypes.add(leftRecordType);
inputTypes.add(BuiltinType.ANULL);
IAType resolvedType = TypeResolverUtil.resolve(inputTypes);
Assert.assertEquals(resolvedType, AUnionType.createUnknownableType(leftRecordType));
}
use of org.apache.asterix.om.types.ARecordType in project asterixdb by apache.
the class TypeResolverUtilTest method testNestedRecordType.
@Test
public void testNestedRecordType() {
// Constructs input types.
ARecordType leftRecordType = new ARecordType("null", new String[] { "a", "b" }, new IAType[] { BuiltinType.ASTRING, new ARecordType(null, new String[] { "c", "d" }, new IAType[] { BuiltinType.ASTRING, BuiltinType.AINT32 }, false, null) }, false, null);
ARecordType rightRecordType = new ARecordType("null", new String[] { "a", "b" }, new IAType[] { BuiltinType.ASTRING, new ARecordType(null, new String[] { "d", "e" }, new IAType[] { BuiltinType.AINT32, BuiltinType.AINT32 }, false, null) }, false, null);
// Resolves input types to a generalized type.
List<IAType> inputTypes = new ArrayList<>();
inputTypes.add(leftRecordType);
inputTypes.add(rightRecordType);
ARecordType resolvedType = (ARecordType) TypeResolverUtil.resolve(inputTypes);
ARecordType nestedRecordType = (ARecordType) resolvedType.getFieldType("b");
// Constructs the expected type.
Set<String> nestedPossibleAdditionalFields = new HashSet<>();
nestedPossibleAdditionalFields.add("c");
nestedPossibleAdditionalFields.add("e");
ARecordType expectedType = new ARecordType(null, new String[] { "a", "b" }, new IAType[] { BuiltinType.ASTRING, new ARecordType(null, new String[] { "d" }, new IAType[] { BuiltinType.AINT32 }, true, nestedPossibleAdditionalFields) }, false, null);
// Compares the resolved type with the expected type.
Assert.assertEquals(expectedType, resolvedType);
Assert.assertEquals(nestedRecordType.getAllPossibleAdditonalFieldNames(), nestedPossibleAdditionalFields);
}
use of org.apache.asterix.om.types.ARecordType in project asterixdb by apache.
the class TypeResolverUtilTest method testRecordType.
@Test
public void testRecordType() {
// Constructs input types.
ARecordType leftRecordType = new ARecordType(null, new String[] { "a", "b" }, new IAType[] { BuiltinType.ASTRING, BuiltinType.AINT32 }, false, null);
ARecordType rightRecordType = new ARecordType(null, new String[] { "b", "c" }, new IAType[] { BuiltinType.AINT32, BuiltinType.ABINARY }, false, null);
// Resolves input types to a generalized type.
List<IAType> inputTypes = new ArrayList<>();
inputTypes.add(leftRecordType);
inputTypes.add(rightRecordType);
ARecordType resolvedType = (ARecordType) TypeResolverUtil.resolve(inputTypes);
// Constructs the expected type.
Set<String> possibleAdditionalFields = new HashSet<>();
possibleAdditionalFields.add("a");
possibleAdditionalFields.add("c");
ARecordType expectedType = new ARecordType(null, new String[] { "b" }, new IAType[] { BuiltinType.AINT32 }, true, possibleAdditionalFields);
// Compares the resolved type with the expected type.
Assert.assertEquals(resolvedType, expectedType);
Assert.assertEquals(resolvedType.getAllPossibleAdditonalFieldNames(), expectedType.getAllPossibleAdditonalFieldNames());
}
Aggregations