use of org.apache.asterix.om.base.IACursor 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));
}
use of org.apache.asterix.om.base.IACursor 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);
}
use of org.apache.asterix.om.base.IACursor 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.IACursor in project asterixdb by apache.
the class AccessMethodUtils method checkFTSearchConstantExpression.
// Checks whether a proper constant expression is in place for the full-text search.
// A proper constant expression in the full-text search should be among string, string type (Un)ordered list.
public static void checkFTSearchConstantExpression(ILogicalExpression constExpression) throws AlgebricksException {
IAObject objectFromExpr = ConstantExpressionUtil.getConstantIaObject(constExpression, null);
String arg2Value;
IACursor oListCursor;
switch(objectFromExpr.getType().getTypeTag()) {
case STRING:
arg2Value = ConstantExpressionUtil.getStringConstant(objectFromExpr);
checkAndGenerateFTSearchExceptionForStringPhrase(arg2Value);
break;
case ARRAY:
oListCursor = ConstantExpressionUtil.getOrderedListConstant(objectFromExpr).getCursor();
checkEachElementInFTSearchListPredicate(oListCursor);
break;
case MULTISET:
oListCursor = ConstantExpressionUtil.getUnorderedListConstant(objectFromExpr).getCursor();
checkEachElementInFTSearchListPredicate(oListCursor);
break;
default:
throw new CompilationException(ErrorCode.COMPILATION_TYPE_UNSUPPORTED, BuiltinFunctions.FULLTEXT_CONTAINS.getName(), objectFromExpr.getType().getTypeTag());
}
}
use of org.apache.asterix.om.base.IACursor in project asterixdb by apache.
the class AUnorderedListSerializerDeserializer method serialize.
@SuppressWarnings("unchecked")
@Override
public void serialize(AUnorderedList instance, DataOutput out) throws HyracksDataException {
// TODO: schemaless ordered list serializer
UnorderedListBuilder listBuilder = new UnorderedListBuilder();
ArrayBackedValueStorage itemValue = new ArrayBackedValueStorage();
listBuilder.reset(unorderedlistType);
IACursor cursor = instance.getCursor();
while (cursor.next()) {
itemValue.reset();
serializer.serialize(cursor.get(), itemValue.getDataOutput());
listBuilder.addItem(itemValue);
}
listBuilder.write(out, false);
}
Aggregations