Search in sources :

Example 1 with AInterval

use of org.apache.asterix.om.base.AInterval in project asterixdb by apache.

the class SerializerDeserializerTestUtils method generateRecords.

public static ARecord[] generateRecords(ARecordType addrRecordType, ARecordType employeeType) {
    AOrderedListType addrListType = new AOrderedListType(addrRecordType, "address_history");
    ARecord addr11 = new ARecord(addrRecordType, new IAObject[] { new AString("120 San Raman Street"), new AString("Irvine"), new AString("CA"), new AInt16((short) 95051), new AInterval(0, 100, (byte) 0) });
    ARecord addr12 = new ARecord(addrRecordType, new IAObject[] { new AString("210 University Drive"), new AString("Philadelphia"), new AString("PA"), new AInt16((short) 10086), new AInterval(100, 300, (byte) 0) });
    ARecord addr21 = new ARecord(addrRecordType, new IAObject[] { new AString("1 College Street"), new AString("Seattle"), new AString("WA"), new AInt16((short) 20012), new AInterval(400, 500, (byte) 0) });
    ARecord addr22 = new ARecord(addrRecordType, new IAObject[] { new AString("20 Lindsay Avenue"), new AString("Columbus"), new AString("OH"), new AInt16((short) 30120), new AInterval(600, 900, (byte) 0) });
    ARecord addr31 = new ARecord(addrRecordType, new IAObject[] { new AString("200 14th Avenue"), new AString("Long Island"), new AString("NY"), new AInt16((short) 95011), new AInterval(12000, 14000, (byte) 0) });
    // With nested open field addr31.
    ARecord addr32 = new ARecord(addrRecordType, new IAObject[] { new AString("51 8th Street"), new AString("Orlando"), new AString("FL"), new AInt16((short) 49045), new AInterval(190000, 200000, (byte) 0) });
    ARecord record1 = new ARecord(employeeType, new IAObject[] { new AInt64(0L), new AString("Tom"), new AOrderedList(addrListType, Arrays.asList(new IAObject[] { addr11, addr12 })) });
    ARecord record2 = new ARecord(employeeType, new IAObject[] { new AInt64(1L), new AString("John"), new AOrderedList(addrListType, Arrays.asList(new IAObject[] { addr21, addr22 })) });
    ARecord record3 = new ARecord(employeeType, new IAObject[] { new AInt64(2L), new AString("Lindsay"), new AOrderedList(addrListType, Arrays.asList(new IAObject[] { addr31, addr32 })) });
    // With nested open field addr41.
    ARecord record4 = new ARecord(employeeType, new IAObject[] { new AInt64(3L), new AString("Joshua"), new AOrderedList(addrListType, Arrays.asList(new IAObject[] {})) });
    ARecord[] records = new ARecord[] { record1, record2, record3, record4 };
    return records;
}
Also used : AInt16(org.apache.asterix.om.base.AInt16) ARecord(org.apache.asterix.om.base.ARecord) AOrderedList(org.apache.asterix.om.base.AOrderedList) AOrderedListType(org.apache.asterix.om.types.AOrderedListType) AInterval(org.apache.asterix.om.base.AInterval) AString(org.apache.asterix.om.base.AString) AInt64(org.apache.asterix.om.base.AInt64)

Example 2 with AInterval

use of org.apache.asterix.om.base.AInterval in project asterixdb by apache.

the class AIntervalSerializerDeserializer method deserialize.

@Override
public AInterval deserialize(DataInput in) throws HyracksDataException {
    try {
        byte tag = in.readByte();
        long start = 0, end = 0;
        if (tag == ATypeTag.DATETIME.serialize()) {
            start = in.readLong();
            end = in.readLong();
        } else {
            start = in.readInt();
            end = in.readInt();
        }
        return new AInterval(start, end, tag);
    } catch (IOException e) {
        throw new HyracksDataException(e);
    }
}
Also used : IOException(java.io.IOException) AInterval(org.apache.asterix.om.base.AInterval) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Aggregations

AInterval (org.apache.asterix.om.base.AInterval)2 IOException (java.io.IOException)1 AInt16 (org.apache.asterix.om.base.AInt16)1 AInt64 (org.apache.asterix.om.base.AInt64)1 AOrderedList (org.apache.asterix.om.base.AOrderedList)1 ARecord (org.apache.asterix.om.base.ARecord)1 AString (org.apache.asterix.om.base.AString)1 AOrderedListType (org.apache.asterix.om.types.AOrderedListType)1 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1