@SuppressWarnings("unchecked") public void writePropertyTypeRecord(String name, String value, DataOutput out) throws HyracksDataException { IARecordBuilder propertyRecordBuilder = new RecordBuilder(); ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage(); propertyRecordBuilder.reset(MetadataRecordTypes.FEED_ADAPTER_CONFIGURATION_RECORDTYPE); AMutableString aString = new AMutableString(""); ISerializerDeserializer<AString> stringSerde = AqlSerializerDeserializerProvider.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); try { propertyRecordBuilder.write(out, true); } catch (IOException | AsterixException e) { throw new HyracksDataException(e); } }
public static void parse(String point, DataOutput out) throws HyracksDataException { try { aPoint.setValue( Double.parseDouble(point.substring(0, point.indexOf(','))), Double.parseDouble(point.substring(point.indexOf(',') + 1, point.length()))); pointSerde.serialize(aPoint, out); } catch (HyracksDataException e) { throw new HyracksDataException(point + " can not be an instance of point"); } }
@Override public Function getMetadataEntityFromTuple(ITupleReference frameTuple) throws IOException { byte[] serRecord = frameTuple.getFieldData(FUNCTION_PAYLOAD_TUPLE_FIELD_INDEX); int recordStartOffset = frameTuple.getFieldStart(FUNCTION_PAYLOAD_TUPLE_FIELD_INDEX); int recordLength = frameTuple.getFieldLength(FUNCTION_PAYLOAD_TUPLE_FIELD_INDEX); ByteArrayInputStream stream = new ByteArrayInputStream(serRecord, recordStartOffset, recordLength); DataInput in = new DataInputStream(stream); ARecord functionRecord = (ARecord) recordSerDes.deserialize(in); return createFunctionFromARecord(functionRecord); }
@SuppressWarnings("unchecked") private void writeFeedTypeDetailsRecordType( IARecordBuilder recordBuilder, Feed feed, ArrayBackedValueStorage fieldValue) throws HyracksDataException { switch (feed.getFeedType()) { case PRIMARY: { PrimaryFeed primaryFeed = (PrimaryFeed) feed; IARecordBuilder primaryDetailsRecordBuilder = new RecordBuilder(); OrderedListBuilder listBuilder = new OrderedListBuilder(); ArrayBackedValueStorage primaryRecordfieldValue = new ArrayBackedValueStorage(); ArrayBackedValueStorage primaryRecordItemValue = new ArrayBackedValueStorage(); primaryDetailsRecordBuilder.reset(MetadataRecordTypes.PRIMARY_FEED_DETAILS_RECORDTYPE); AMutableString aString = new AMutableString(""); ISerializerDeserializer<AString> stringSerde = AqlSerializerDeserializerProvider.INSTANCE.getSerializerDeserializer( BuiltinType.ASTRING); // write field 0 fieldValue.reset(); aString.setValue(primaryFeed.getAdaptorName()); stringSerde.serialize(aString, primaryRecordfieldValue.getDataOutput()); primaryDetailsRecordBuilder.addField( MetadataRecordTypes.FEED_ARECORD_PRIMARY_FIELD_DETAILS_ADAPTOR_NAME_FIELD_INDEX, primaryRecordfieldValue); // write field 1 listBuilder.reset( (AUnorderedListType) MetadataRecordTypes.PRIMARY_FEED_DETAILS_RECORDTYPE .getFieldTypes()[ MetadataRecordTypes .FEED_ARECORD_PRIMARY_FIELD_DETAILS_ADAPTOR_CONFIGURATION_FIELD_INDEX]); for (Map.Entry<String, String> property : primaryFeed.getAdaptorConfiguration().entrySet()) { String name = property.getKey(); String value = property.getValue(); primaryRecordItemValue.reset(); writePropertyTypeRecord(name, value, primaryRecordItemValue.getDataOutput()); listBuilder.addItem(primaryRecordItemValue); } primaryRecordfieldValue.reset(); listBuilder.write(primaryRecordfieldValue.getDataOutput(), true); primaryDetailsRecordBuilder.addField( MetadataRecordTypes .FEED_ARECORD_PRIMARY_FIELD_DETAILS_ADAPTOR_CONFIGURATION_FIELD_INDEX, primaryRecordfieldValue); try { primaryDetailsRecordBuilder.write(fieldValue.getDataOutput(), true); } catch (IOException | AsterixException e) { throw new HyracksDataException(e); } recordBuilder.addField( MetadataRecordTypes.FEED_ARECORD_PRIMARY_TYPE_DETAILS_FIELD_INDEX, fieldValue); } break; case SECONDARY: SecondaryFeed secondaryFeed = (SecondaryFeed) feed; IARecordBuilder secondaryDetailsRecordBuilder = new RecordBuilder(); ArrayBackedValueStorage secondaryFieldValue = new ArrayBackedValueStorage(); secondaryDetailsRecordBuilder.reset(MetadataRecordTypes.SECONDARY_FEED_DETAILS_RECORDTYPE); // write field 0 fieldValue.reset(); aString.setValue(secondaryFeed.getSourceFeedName()); stringSerde.serialize(aString, secondaryFieldValue.getDataOutput()); secondaryDetailsRecordBuilder.addField( MetadataRecordTypes.FEED_ARECORD_SECONDARY_FIELD_DETAILS_SOURCE_FEED_NAME_FIELD_INDEX, secondaryFieldValue); try { secondaryDetailsRecordBuilder.write(fieldValue.getDataOutput(), true); } catch (IOException | AsterixException e) { throw new HyracksDataException(e); } recordBuilder.addField( MetadataRecordTypes.FEED_ARECORD_SECONDARY_TYPE_DETAILS_FIELD_INDEX, fieldValue); break; } }