use of org.apache.asterix.om.base.AMutableString in project asterixdb by apache.
the class FunctionalTester method read_line_stdin.
/*********************************************************************
* Function: read_line_stdin
* Purpose:
*
* @throws IOException
*********************************************************************/
public static boolean read_line_stdin(AMutableString line, State state, Parameters parameters) throws IOException {
System.out.print("> ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line_segment = br.readLine();
if (line_segment.length() == 0 || line_segment.equalsIgnoreCase("q")) {
line.setValue("");
return false;
}
if (line_is_comment(line_segment)) {
// ignore comments, should we read another line?
line.setValue("");
return true;
} else {
line.setValue(line.getStringValue() + line_segment);
state.lineNumber++;
return true;
}
}
use of org.apache.asterix.om.base.AMutableString 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);
}
use of org.apache.asterix.om.base.AMutableString 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.om.base.AMutableString 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.om.base.AMutableString in project asterixdb by apache.
the class LangRecordParseUtil method parseRecord.
public static void parseRecord(RecordConstructor recordValue, ArrayBackedValueStorage serialized, boolean tagged, List<Pair<String, String>> defaults) throws HyracksDataException {
AMutableString fieldNameString = new AMutableString(null);
ArrayBackedValueStorage fieldName = new ArrayBackedValueStorage();
ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
RecordBuilder recordBuilder = new RecordBuilder();
recordBuilder.reset(RecordUtil.FULLY_OPEN_RECORD_TYPE);
recordBuilder.init();
List<FieldBinding> fbList = recordValue.getFbList();
HashSet<String> fieldNames = new HashSet<>();
for (FieldBinding fb : fbList) {
fieldName.reset();
fieldValue.reset();
// get key
fieldNameString.setValue(exprToStringLiteral(fb.getLeftExpr()).getStringValue());
if (!fieldNames.add(fieldNameString.getStringValue())) {
throw new HyracksDataException("Field " + fieldNameString.getStringValue() + " was specified multiple times");
}
stringSerde.serialize(fieldNameString, fieldName.getDataOutput());
// get value
parseExpression(fb.getRightExpr(), fieldValue);
recordBuilder.addField(fieldName, fieldValue);
}
// defaults
for (Pair<String, String> kv : defaults) {
if (!fieldNames.contains(kv.first)) {
fieldName.reset();
fieldValue.reset();
stringSerde.serialize(new AString(kv.first), fieldName.getDataOutput());
stringSerde.serialize(new AString(kv.second), fieldValue.getDataOutput());
recordBuilder.addField(fieldName, fieldValue);
}
}
recordBuilder.write(serialized.getDataOutput(), tagged);
}
Aggregations