use of org.apache.asterix.builders.RecordBuilder in project asterixdb by apache.
the class FeedPolicyTupleTranslator method writePropertyTypeRecord.
public void writePropertyTypeRecord(String name, String value, DataOutput out) throws HyracksDataException {
IARecordBuilder propertyRecordBuilder = new RecordBuilder();
ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
propertyRecordBuilder.reset(MetadataRecordTypes.POLICY_PARAMS_RECORDTYPE);
AMutableString aString = new AMutableString("");
ISerializerDeserializer<AString> stringSerde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING);
// write field 0
fieldValue.reset();
aString.setValue(name);
stringSerde.serialize(aString, fieldValue.getDataOutput());
propertyRecordBuilder.addField(0, fieldValue);
// write field 1
fieldValue.reset();
aString.setValue(value);
stringSerde.serialize(aString, fieldValue.getDataOutput());
propertyRecordBuilder.addField(1, fieldValue);
propertyRecordBuilder.write(out, true);
}
use of org.apache.asterix.builders.RecordBuilder in project asterixdb by apache.
the class FeedTupleTranslator method writePropertyTypeRecord.
@SuppressWarnings("unchecked")
public void writePropertyTypeRecord(String name, String value, DataOutput out) throws HyracksDataException {
IARecordBuilder propertyRecordBuilder = new RecordBuilder();
ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
propertyRecordBuilder.reset(MetadataRecordTypes.DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE);
AMutableString aString = new AMutableString("");
ISerializerDeserializer<AString> stringSerde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING);
// write field 0
fieldValue.reset();
aString.setValue(name);
stringSerde.serialize(aString, fieldValue.getDataOutput());
propertyRecordBuilder.addField(0, fieldValue);
// write field 1
fieldValue.reset();
aString.setValue(value);
stringSerde.serialize(aString, fieldValue.getDataOutput());
propertyRecordBuilder.addField(1, fieldValue);
propertyRecordBuilder.write(out, true);
}
use of org.apache.asterix.builders.RecordBuilder in project asterixdb by apache.
the class DatatypeTupleTranslator method writeDerivedTypeRecord.
private void writeDerivedTypeRecord(Datatype type, AbstractComplexType derivedDatatype, DataOutput out) throws HyracksDataException {
DerivedTypeTag tag = null;
IARecordBuilder derivedRecordBuilder = new RecordBuilder();
ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
switch(derivedDatatype.getTypeTag()) {
case ARRAY:
tag = DerivedTypeTag.ORDEREDLIST;
break;
case MULTISET:
tag = DerivedTypeTag.UNORDEREDLIST;
break;
case OBJECT:
tag = DerivedTypeTag.RECORD;
break;
default:
throw new UnsupportedOperationException("No metadata record Type for " + derivedDatatype.getDisplayName());
}
derivedRecordBuilder.reset(MetadataRecordTypes.DERIVEDTYPE_RECORDTYPE);
// write field 0
fieldValue.reset();
aString.setValue(tag.toString());
stringSerde.serialize(aString, fieldValue.getDataOutput());
derivedRecordBuilder.addField(MetadataRecordTypes.DERIVEDTYPE_ARECORD_TAG_FIELD_INDEX, fieldValue);
// write field 1
fieldValue.reset();
booleanSerde.serialize(type.getIsAnonymous() ? ABoolean.TRUE : ABoolean.FALSE, fieldValue.getDataOutput());
derivedRecordBuilder.addField(MetadataRecordTypes.DERIVEDTYPE_ARECORD_ISANONYMOUS_FIELD_INDEX, fieldValue);
switch(tag) {
case RECORD:
fieldValue.reset();
writeRecordType(type, derivedDatatype, fieldValue.getDataOutput());
derivedRecordBuilder.addField(MetadataRecordTypes.DERIVEDTYPE_ARECORD_RECORD_FIELD_INDEX, fieldValue);
break;
case UNORDEREDLIST:
fieldValue.reset();
writeCollectionType(type, derivedDatatype, fieldValue.getDataOutput());
derivedRecordBuilder.addField(MetadataRecordTypes.DERIVEDTYPE_ARECORD_UNORDEREDLIST_FIELD_INDEX, fieldValue);
break;
case ORDEREDLIST:
fieldValue.reset();
writeCollectionType(type, derivedDatatype, fieldValue.getDataOutput());
derivedRecordBuilder.addField(MetadataRecordTypes.DERIVEDTYPE_ARECORD_ORDEREDLIST_FIELD_INDEX, fieldValue);
break;
}
derivedRecordBuilder.write(out, true);
}
Aggregations