Search in sources :

Example 51 with AString

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

the class DatasourceAdapterTupleTranslator method createAdapterFromARecord.

private DatasourceAdapter createAdapterFromARecord(ARecord adapterRecord) {
    String dataverseName = ((AString) adapterRecord.getValueByPos(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_DATAVERSENAME_FIELD_INDEX)).getStringValue();
    String adapterName = ((AString) adapterRecord.getValueByPos(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_NAME_FIELD_INDEX)).getStringValue();
    String classname = ((AString) adapterRecord.getValueByPos(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_CLASSNAME_FIELD_INDEX)).getStringValue();
    IDataSourceAdapter.AdapterType adapterType = IDataSourceAdapter.AdapterType.valueOf(((AString) adapterRecord.getValueByPos(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_TYPE_FIELD_INDEX)).getStringValue());
    return new DatasourceAdapter(new AdapterIdentifier(dataverseName, adapterName), classname, adapterType);
}
Also used : IDataSourceAdapter(org.apache.asterix.external.api.IDataSourceAdapter) DatasourceAdapter(org.apache.asterix.metadata.entities.DatasourceAdapter) AdapterIdentifier(org.apache.asterix.external.dataset.adapter.AdapterIdentifier) AString(org.apache.asterix.om.base.AString) AString(org.apache.asterix.om.base.AString)

Example 52 with AString

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

the class FeedPolicyTupleTranslator method getTupleFromMetadataEntity.

@Override
public ITupleReference getTupleFromMetadataEntity(FeedPolicyEntity feedPolicy) throws HyracksDataException, MetadataException {
    // write the key in the first three fields of the tuple
    ArrayBackedValueStorage itemValue = new ArrayBackedValueStorage();
    tupleBuilder.reset();
    aString.setValue(feedPolicy.getDataverseName());
    stringSerde.serialize(aString, tupleBuilder.getDataOutput());
    tupleBuilder.addFieldEndOffset();
    aString.setValue(feedPolicy.getPolicyName());
    stringSerde.serialize(aString, tupleBuilder.getDataOutput());
    tupleBuilder.addFieldEndOffset();
    recordBuilder.reset(MetadataRecordTypes.FEED_POLICY_RECORDTYPE);
    // write field 0
    fieldValue.reset();
    aString.setValue(feedPolicy.getDataverseName());
    stringSerde.serialize(aString, fieldValue.getDataOutput());
    recordBuilder.addField(MetadataRecordTypes.FEED_POLICY_ARECORD_DATAVERSE_NAME_FIELD_INDEX, fieldValue);
    // write field 1
    fieldValue.reset();
    aString.setValue(feedPolicy.getPolicyName());
    stringSerde.serialize(aString, fieldValue.getDataOutput());
    recordBuilder.addField(MetadataRecordTypes.FEED_POLICY_ARECORD_POLICY_NAME_FIELD_INDEX, fieldValue);
    // write field 2
    fieldValue.reset();
    aString.setValue(feedPolicy.getDescription());
    stringSerde.serialize(aString, fieldValue.getDataOutput());
    recordBuilder.addField(MetadataRecordTypes.FEED_POLICY_ARECORD_POLICY_NAME_FIELD_INDEX, fieldValue);
    // write field 3 (properties)
    Map<String, String> properties = feedPolicy.getProperties();
    UnorderedListBuilder listBuilder = new UnorderedListBuilder();
    listBuilder.reset((AUnorderedListType) MetadataRecordTypes.FEED_POLICY_RECORDTYPE.getFieldTypes()[MetadataRecordTypes.FEED_POLICY_ARECORD_PROPERTIES_FIELD_INDEX]);
    for (Map.Entry<String, String> property : properties.entrySet()) {
        String name = property.getKey();
        String value = property.getValue();
        itemValue.reset();
        writePropertyTypeRecord(name, value, itemValue.getDataOutput());
        listBuilder.addItem(itemValue);
    }
    fieldValue.reset();
    listBuilder.write(fieldValue.getDataOutput(), true);
    recordBuilder.addField(MetadataRecordTypes.FEED_POLICY_ARECORD_PROPERTIES_FIELD_INDEX, fieldValue);
    // write record
    recordBuilder.write(tupleBuilder.getDataOutput(), true);
    tupleBuilder.addFieldEndOffset();
    tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
    return tuple;
}
Also used : ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) AString(org.apache.asterix.om.base.AString) AMutableString(org.apache.asterix.om.base.AMutableString) UnorderedListBuilder(org.apache.asterix.builders.UnorderedListBuilder) HashMap(java.util.HashMap) Map(java.util.Map)

Example 53 with AString

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

the class ExternalDatasetDetails method writeDatasetDetailsRecordType.

@SuppressWarnings("unchecked")
@Override
public void writeDatasetDetailsRecordType(DataOutput out) throws HyracksDataException {
    IARecordBuilder externalRecordBuilder = new RecordBuilder();
    OrderedListBuilder listBuilder = new OrderedListBuilder();
    ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
    ArrayBackedValueStorage itemValue = new ArrayBackedValueStorage();
    externalRecordBuilder.reset(MetadataRecordTypes.EXTERNAL_DETAILS_RECORDTYPE);
    AMutableString aString = new AMutableString("");
    ISerializerDeserializer<AString> stringSerde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING);
    ISerializerDeserializer<ADateTime> dateTimeSerde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADATETIME);
    ISerializerDeserializer<AInt32> intSerde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT32);
    // write field 0
    fieldValue.reset();
    aString.setValue(this.getAdapter());
    stringSerde.serialize(aString, fieldValue.getDataOutput());
    externalRecordBuilder.addField(MetadataRecordTypes.EXTERNAL_DETAILS_ARECORD_DATASOURCE_ADAPTER_FIELD_INDEX, fieldValue);
    // write field 1
    listBuilder.reset((AOrderedListType) MetadataRecordTypes.EXTERNAL_DETAILS_RECORDTYPE.getFieldTypes()[1]);
    for (Map.Entry<String, String> property : this.properties.entrySet()) {
        String name = property.getKey();
        String value = property.getValue();
        itemValue.reset();
        DatasetUtil.writePropertyTypeRecord(name, value, itemValue.getDataOutput(), MetadataRecordTypes.DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE);
        listBuilder.addItem(itemValue);
    }
    fieldValue.reset();
    listBuilder.write(fieldValue.getDataOutput(), true);
    externalRecordBuilder.addField(MetadataRecordTypes.EXTERNAL_DETAILS_ARECORD_PROPERTIES_FIELD_INDEX, fieldValue);
    // write field 2
    fieldValue.reset();
    dateTimeSerde.serialize(new ADateTime(lastRefreshTime.getTime()), fieldValue.getDataOutput());
    externalRecordBuilder.addField(MetadataRecordTypes.EXTERNAL_DETAILS_ARECORD_LAST_REFRESH_TIME_FIELD_INDEX, fieldValue);
    // write field 3
    fieldValue.reset();
    intSerde.serialize(new AInt32(state.ordinal()), fieldValue.getDataOutput());
    externalRecordBuilder.addField(MetadataRecordTypes.EXTERNAL_DETAILS_ARECORD_TRANSACTION_STATE_FIELD_INDEX, fieldValue);
    externalRecordBuilder.write(out, true);
}
Also used : OrderedListBuilder(org.apache.asterix.builders.OrderedListBuilder) IARecordBuilder(org.apache.asterix.builders.IARecordBuilder) RecordBuilder(org.apache.asterix.builders.RecordBuilder) AMutableString(org.apache.asterix.om.base.AMutableString) ADateTime(org.apache.asterix.om.base.ADateTime) AString(org.apache.asterix.om.base.AString) AMutableString(org.apache.asterix.om.base.AMutableString) AInt32(org.apache.asterix.om.base.AInt32) ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) IARecordBuilder(org.apache.asterix.builders.IARecordBuilder) AString(org.apache.asterix.om.base.AString) HashMap(java.util.HashMap) Map(java.util.Map)

Example 54 with AString

use of org.apache.asterix.om.base.AString 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);
}
Also used : ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) IARecordBuilder(org.apache.asterix.builders.IARecordBuilder) IARecordBuilder(org.apache.asterix.builders.IARecordBuilder) RecordBuilder(org.apache.asterix.builders.RecordBuilder) AMutableString(org.apache.asterix.om.base.AMutableString) AString(org.apache.asterix.om.base.AString)

Example 55 with AString

use of org.apache.asterix.om.base.AString 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);
}
Also used : ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) IARecordBuilder(org.apache.asterix.builders.IARecordBuilder) IARecordBuilder(org.apache.asterix.builders.IARecordBuilder) RecordBuilder(org.apache.asterix.builders.RecordBuilder) AMutableString(org.apache.asterix.om.base.AMutableString) AString(org.apache.asterix.om.base.AString)

Aggregations

AString (org.apache.asterix.om.base.AString)58 AsterixConstantValue (org.apache.asterix.om.constants.AsterixConstantValue)21 ConstantExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression)20 ArrayList (java.util.ArrayList)19 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)18 AMutableString (org.apache.asterix.om.base.AMutableString)16 ArrayBackedValueStorage (org.apache.hyracks.data.std.util.ArrayBackedValueStorage)16 AOrderedList (org.apache.asterix.om.base.AOrderedList)13 Mutable (org.apache.commons.lang3.mutable.Mutable)12 RecordBuilder (org.apache.asterix.builders.RecordBuilder)11 AInt32 (org.apache.asterix.om.base.AInt32)11 ScalarFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)10 IARecordBuilder (org.apache.asterix.builders.IARecordBuilder)9 IACursor (org.apache.asterix.om.base.IACursor)9 IAObject (org.apache.asterix.om.base.IAObject)9 IAType (org.apache.asterix.om.types.IAType)9 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)9 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)9 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)9 ARecord (org.apache.asterix.om.base.ARecord)8