use of org.apache.asterix.om.base.AUnorderedList in project asterixdb by apache.
the class AUnorderedListSerializerDeserializerTest method test.
@Test
public void test() {
// Generates types.
ARecordType addrRecordType = SerializerDeserializerTestUtils.generateAddressRecordType();
ARecordType employeeType = SerializerDeserializerTestUtils.generateEmployeeRecordType(addrRecordType);
AUnorderedListType employeeListType = new AUnorderedListType(employeeType, "employee_list");
//Generates records.
ARecord[] records = SerializerDeserializerTestUtils.generateRecords(addrRecordType, employeeType);
// Generates lists
AUnorderedList[] lists = new AUnorderedList[4];
for (int index = 0; index < lists.length; ++index) {
lists[index] = new AUnorderedList(employeeListType, Arrays.asList(records));
}
AUnorderedListSerializerDeserializer serde = new AUnorderedListSerializerDeserializer(employeeListType);
// Run four test threads to serialize/deserialize lists concurrently.
SerializerDeserializerTestUtils.concurrentSerDeTestRun(serde, lists);
}
use of org.apache.asterix.om.base.AUnorderedList in project asterixdb by apache.
the class FeedTupleTranslator method createFeedFromARecord.
private Feed createFeedFromARecord(ARecord feedRecord) {
Feed feed;
String dataverseName = ((AString) feedRecord.getValueByPos(MetadataRecordTypes.FEED_ARECORD_DATAVERSE_NAME_FIELD_INDEX)).getStringValue();
String feedName = ((AString) feedRecord.getValueByPos(MetadataRecordTypes.FEED_ARECORD_FEED_NAME_FIELD_INDEX)).getStringValue();
AUnorderedList feedConfig = (AUnorderedList) feedRecord.getValueByPos(MetadataRecordTypes.FEED_ARECORD_ADAPTOR_CONFIG_INDEX);
String adapterName = ((AString) feedRecord.getValueByPos(MetadataRecordTypes.FEED_ARECORD_ADAPTOR_NAME_INDEX)).getStringValue();
IACursor cursor = feedConfig.getCursor();
// restore configurations
String key;
String value;
Map<String, String> adaptorConfiguration = new HashMap<>();
while (cursor.next()) {
ARecord field = (ARecord) cursor.get();
key = ((AString) field.getValueByPos(MetadataRecordTypes.PROPERTIES_NAME_FIELD_INDEX)).getStringValue();
value = ((AString) field.getValueByPos(MetadataRecordTypes.PROPERTIES_VALUE_FIELD_INDEX)).getStringValue();
adaptorConfiguration.put(key, value);
}
feed = new Feed(dataverseName, feedName, adapterName, adaptorConfiguration);
return feed;
}
use of org.apache.asterix.om.base.AUnorderedList in project asterixdb by apache.
the class FeedPolicyTupleTranslator method createFeedPolicyFromARecord.
private FeedPolicyEntity createFeedPolicyFromARecord(ARecord feedPolicyRecord) {
FeedPolicyEntity feedPolicy = null;
String dataverseName = ((AString) feedPolicyRecord.getValueByPos(MetadataRecordTypes.FEED_POLICY_ARECORD_DATAVERSE_NAME_FIELD_INDEX)).getStringValue();
String policyName = ((AString) feedPolicyRecord.getValueByPos(MetadataRecordTypes.FEED_POLICY_ARECORD_POLICY_NAME_FIELD_INDEX)).getStringValue();
String description = ((AString) feedPolicyRecord.getValueByPos(MetadataRecordTypes.FEED_POLICY_ARECORD_DESCRIPTION_FIELD_INDEX)).getStringValue();
IACursor cursor = ((AUnorderedList) feedPolicyRecord.getValueByPos(MetadataRecordTypes.FEED_POLICY_ARECORD_PROPERTIES_FIELD_INDEX)).getCursor();
Map<String, String> policyParamters = new HashMap<>();
String key;
String value;
while (cursor.next()) {
ARecord field = (ARecord) cursor.get();
key = ((AString) field.getValueByPos(MetadataRecordTypes.PROPERTIES_NAME_FIELD_INDEX)).getStringValue();
value = ((AString) field.getValueByPos(MetadataRecordTypes.PROPERTIES_VALUE_FIELD_INDEX)).getStringValue();
policyParamters.put(key, value);
}
feedPolicy = new FeedPolicyEntity(dataverseName, policyName, description, policyParamters);
return feedPolicy;
}
use of org.apache.asterix.om.base.AUnorderedList in project asterixdb by apache.
the class AUnorderedListSerializerDeserializer method deserialize.
@Override
public AUnorderedList deserialize(DataInput in) throws HyracksDataException {
// TODO: schemaless unordered list deserializer
try {
ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(in.readByte());
IAType currentItemType = itemType;
@SuppressWarnings("rawtypes") ISerializerDeserializer currentDeserializer = deserializer;
if (itemType.getTypeTag() == ATypeTag.ANY && typeTag != ATypeTag.ANY) {
currentItemType = TypeTagUtil.getBuiltinTypeByTag(typeTag);
currentDeserializer = SerializerDeserializerProvider.INSTANCE.getNonTaggedSerializerDeserializer(currentItemType);
}
// list size
in.readInt();
int numberOfitems;
numberOfitems = in.readInt();
ArrayList<IAObject> items = new ArrayList<IAObject>();
if (numberOfitems > 0) {
if (!NonTaggedFormatUtil.isFixedSizedCollection(currentItemType)) {
for (int i = 0; i < numberOfitems; i++) in.readInt();
}
for (int i = 0; i < numberOfitems; i++) {
items.add((IAObject) currentDeserializer.deserialize(in));
}
}
AUnorderedListType type = new AUnorderedListType(currentItemType, "unorderedlist");
return new AUnorderedList(type, items);
} catch (Exception e) {
throw new HyracksDataException(e);
}
}
use of org.apache.asterix.om.base.AUnorderedList in project asterixdb by apache.
the class NodeGroupTupleTranslator method getMetadataEntityFromTuple.
@Override
public NodeGroup getMetadataEntityFromTuple(ITupleReference frameTuple) throws HyracksDataException {
byte[] serRecord = frameTuple.getFieldData(NODEGROUP_PAYLOAD_TUPLE_FIELD_INDEX);
int recordStartOffset = frameTuple.getFieldStart(NODEGROUP_PAYLOAD_TUPLE_FIELD_INDEX);
int recordLength = frameTuple.getFieldLength(NODEGROUP_PAYLOAD_TUPLE_FIELD_INDEX);
ByteArrayInputStream stream = new ByteArrayInputStream(serRecord, recordStartOffset, recordLength);
DataInput in = new DataInputStream(stream);
ARecord nodeGroupRecord = recordSerDes.deserialize(in);
String gpName = ((AString) nodeGroupRecord.getValueByPos(MetadataRecordTypes.NODEGROUP_ARECORD_GROUPNAME_FIELD_INDEX)).getStringValue();
IACursor cursor = ((AUnorderedList) nodeGroupRecord.getValueByPos(MetadataRecordTypes.NODEGROUP_ARECORD_NODENAMES_FIELD_INDEX)).getCursor();
List<String> nodeNames = new ArrayList<>();
while (cursor.next()) {
nodeNames.add(((AString) cursor.get()).getStringValue());
}
return new NodeGroup(gpName, nodeNames);
}
Aggregations