Search in sources :

Example 16 with AString

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

the class FunctionTupleTranslator method createFunctionFromARecord.

private Function createFunctionFromARecord(ARecord functionRecord) {
    String dataverseName = ((AString) functionRecord.getValueByPos(MetadataRecordTypes.FUNCTION_ARECORD_DATAVERSENAME_FIELD_INDEX)).getStringValue();
    String functionName = ((AString) functionRecord.getValueByPos(MetadataRecordTypes.FUNCTION_ARECORD_FUNCTIONNAME_FIELD_INDEX)).getStringValue();
    String arity = ((AString) functionRecord.getValueByPos(MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_ARITY_FIELD_INDEX)).getStringValue();
    IACursor cursor = ((AOrderedList) functionRecord.getValueByPos(MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_PARAM_LIST_FIELD_INDEX)).getCursor();
    List<String> params = new ArrayList<>();
    while (cursor.next()) {
        params.add(((AString) cursor.get()).getStringValue());
    }
    String returnType = ((AString) functionRecord.getValueByPos(MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_RETURN_TYPE_FIELD_INDEX)).getStringValue();
    String definition = ((AString) functionRecord.getValueByPos(MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_DEFINITION_FIELD_INDEX)).getStringValue();
    String language = ((AString) functionRecord.getValueByPos(MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_LANGUAGE_FIELD_INDEX)).getStringValue();
    String functionKind = ((AString) functionRecord.getValueByPos(MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_KIND_FIELD_INDEX)).getStringValue();
    String referenceCount = ((AString) functionRecord.getValueByPos(MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_REFERENCE_COUNT_INDEX)).getStringValue();
    return new Function(dataverseName, functionName, Integer.parseInt(arity), params, returnType, definition, language, functionKind, Integer.parseInt(referenceCount));
}
Also used : Function(org.apache.asterix.metadata.entities.Function) AOrderedList(org.apache.asterix.om.base.AOrderedList) ArrayList(java.util.ArrayList) AString(org.apache.asterix.om.base.AString) IACursor(org.apache.asterix.om.base.IACursor) AString(org.apache.asterix.om.base.AString)

Example 17 with AString

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

the class DatasetUtil method writePropertyTypeRecord.

@SuppressWarnings("unchecked")
public static void writePropertyTypeRecord(String name, String value, DataOutput out, ARecordType recordType) throws HyracksDataException {
    IARecordBuilder propertyRecordBuilder = new RecordBuilder();
    ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
    propertyRecordBuilder.reset(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 18 with AString

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

the class ExternalFileTupleTranslator method createExternalFileFromARecord.

private ExternalFile createExternalFileFromARecord(ARecord externalFileRecord) {
    String dataverseName = ((AString) externalFileRecord.getValueByPos(MetadataRecordTypes.EXTERNAL_FILE_ARECORD_DATAVERSENAME_FIELD_INDEX)).getStringValue();
    String datasetName = ((AString) externalFileRecord.getValueByPos(MetadataRecordTypes.EXTERNAL_FILE_ARECORD_DATASET_NAME_FIELD_INDEX)).getStringValue();
    int fileNumber = ((AInt32) externalFileRecord.getValueByPos(MetadataRecordTypes.EXTERNAL_FILE_ARECORD_FILE_NUMBER_FIELD_INDEX)).getIntegerValue();
    String fileName = ((AString) externalFileRecord.getValueByPos(MetadataRecordTypes.EXTERNAL_FILE_ARECORD_FILE_NAME_FIELD_INDEX)).getStringValue();
    long fileSize = ((AInt64) externalFileRecord.getValueByPos(MetadataRecordTypes.EXTERNAL_FILE_ARECORD_FILE_SIZE_FIELD_INDEX)).getLongValue();
    Date lastMoDifiedDate = new Date(((ADateTime) externalFileRecord.getValueByPos(MetadataRecordTypes.EXTERNAL_FILE_ARECORD_FILE_MOD_DATE_FIELD_INDEX)).getChrononTime());
    ExternalFilePendingOp pendingOp = ExternalFilePendingOp.values()[((AInt32) externalFileRecord.getValueByPos(MetadataRecordTypes.EXTERNAL_FILE_ARECORD_FILE_PENDING_OP_FIELD_INDEX)).getIntegerValue()];
    return new ExternalFile(dataverseName, datasetName, fileNumber, fileName, lastMoDifiedDate, fileSize, pendingOp);
}
Also used : ExternalFilePendingOp(org.apache.asterix.common.config.DatasetConfig.ExternalFilePendingOp) AString(org.apache.asterix.om.base.AString) AString(org.apache.asterix.om.base.AString) AInt32(org.apache.asterix.om.base.AInt32) Date(java.util.Date) ExternalFile(org.apache.asterix.external.indexing.ExternalFile) AInt64(org.apache.asterix.om.base.AInt64)

Example 19 with AString

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

the class FeedConnectionTupleTranslator method createFeedConnFromRecord.

private FeedConnection createFeedConnFromRecord(ARecord feedConnRecord) {
    String dataverseName = ((AString) feedConnRecord.getValueByPos(MetadataRecordTypes.FEED_CONN_DATAVERSE_NAME_FIELD_INDEX)).getStringValue();
    String feedName = ((AString) feedConnRecord.getValueByPos(MetadataRecordTypes.FEED_CONN_FEED_NAME_FIELD_INDEX)).getStringValue();
    String datasetName = ((AString) feedConnRecord.getValueByPos(MetadataRecordTypes.FEED_CONN_DATASET_NAME_FIELD_INDEX)).getStringValue();
    String outputType = ((AString) feedConnRecord.getValueByPos(MetadataRecordTypes.FEED_CONN_OUTPUT_TYPE_INDEX)).getStringValue();
    String policyName = ((AString) feedConnRecord.getValueByPos(MetadataRecordTypes.FEED_CONN_POLICY_FIELD_INDEX)).getStringValue();
    ArrayList<FunctionSignature> appliedFunctions = null;
    Object o = feedConnRecord.getValueByPos(MetadataRecordTypes.FEED_CONN_APPLIED_FUNCTIONS_FIELD_INDEX);
    IACursor cursor;
    if (!(o instanceof ANull) && !(o instanceof AMissing)) {
        appliedFunctions = new ArrayList<>();
        FunctionSignature functionSignature;
        cursor = ((AUnorderedList) feedConnRecord.getValueByPos(MetadataRecordTypes.FEED_CONN_APPLIED_FUNCTIONS_FIELD_INDEX)).getCursor();
        while (cursor.next()) {
            //TODO: allow different arity
            functionSignature = new FunctionSignature(dataverseName, ((AString) cursor.get()).getStringValue(), 1);
            appliedFunctions.add(functionSignature);
        }
    }
    return new FeedConnection(dataverseName, feedName, datasetName, appliedFunctions, policyName, outputType);
}
Also used : ANull(org.apache.asterix.om.base.ANull) FeedConnection(org.apache.asterix.metadata.entities.FeedConnection) AMissing(org.apache.asterix.om.base.AMissing) AString(org.apache.asterix.om.base.AString) IACursor(org.apache.asterix.om.base.IACursor) AString(org.apache.asterix.om.base.AString) FunctionSignature(org.apache.asterix.common.functions.FunctionSignature)

Example 20 with AString

use of org.apache.asterix.om.base.AString 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;
}
Also used : ARecord(org.apache.asterix.om.base.ARecord) FeedPolicyEntity(org.apache.asterix.metadata.entities.FeedPolicyEntity) HashMap(java.util.HashMap) AUnorderedList(org.apache.asterix.om.base.AUnorderedList) AString(org.apache.asterix.om.base.AString) AMutableString(org.apache.asterix.om.base.AMutableString) IACursor(org.apache.asterix.om.base.IACursor) 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