use of org.apache.hyracks.data.std.util.ArrayBackedValueStorage in project asterixdb by apache.
the class UUIDDescriptor method createEvaluatorFactory.
@Override
public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) {
return new IScalarEvaluatorFactory() {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
private final ISerializerDeserializer<AUUID> uuidSerDe = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AUUID);
@Override
public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
return new IScalarEvaluator() {
private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
private final DataOutput output = resultStorage.getDataOutput();
private final AGeneratedUUID uuid = new AGeneratedUUID();
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
uuid.nextUUID();
resultStorage.reset();
uuidSerDe.serialize(uuid, output);
result.set(resultStorage);
}
};
}
};
}
use of org.apache.hyracks.data.std.util.ArrayBackedValueStorage in project asterixdb by apache.
the class DateFromUnixTimeInDaysDescriptor method createEvaluatorFactory.
@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
return new IScalarEvaluatorFactory() {
private static final long serialVersionUID = 1L;
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
return new IScalarEvaluator() {
private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
private DataOutput out = resultStorage.getDataOutput();
private IPointable argPtr = new VoidPointable();
private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
private AMutableDate aDate = new AMutableDate(0);
// possible returning types
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADate> dateSerde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADATE);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
resultStorage.reset();
eval.evaluate(tuple, argPtr);
aDate.setValue(ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 0, argPtr.getByteArray(), argPtr.getStartOffset()));
dateSerde.serialize(aDate, out);
result.set(resultStorage);
}
};
}
};
}
use of org.apache.hyracks.data.std.util.ArrayBackedValueStorage in project asterixdb by apache.
the class RecordFieldsUtil method addIsOpenField.
public void addIsOpenField(boolean isOpen, IARecordBuilder fieldRecordBuilder) throws HyracksDataException, AsterixException {
ArrayBackedValueStorage fieldAbvs = getTempBuffer();
ArrayBackedValueStorage valueAbvs = getTempBuffer();
// Name
fieldAbvs.reset();
stringSerde.serialize(isOpenName, fieldAbvs.getDataOutput());
// Value
valueAbvs.reset();
if (isOpen) {
booleanSerde.serialize(ABoolean.TRUE, valueAbvs.getDataOutput());
} else {
booleanSerde.serialize(ABoolean.FALSE, valueAbvs.getDataOutput());
}
fieldRecordBuilder.addField(fieldAbvs, valueAbvs);
}
use of org.apache.hyracks.data.std.util.ArrayBackedValueStorage in project asterixdb by apache.
the class IDataParser method writeRecord.
/*
* The following two static methods are expensive. right now, they are used by RSSFeeds and
* Twitter feed
* TODO: Get rid of them
*/
public static void writeRecord(AMutableRecord record, DataOutput dataOutput, IARecordBuilder recordBuilder) throws HyracksDataException {
ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
int numFields = record.getType().getFieldNames().length;
for (int pos = 0; pos < numFields; pos++) {
fieldValue.reset();
IAObject obj = record.getValueByPos(pos);
IDataParser.writeObject(obj, fieldValue.getDataOutput());
recordBuilder.addField(pos, fieldValue);
}
recordBuilder.write(dataOutput, true);
}
use of org.apache.hyracks.data.std.util.ArrayBackedValueStorage in project asterixdb by apache.
the class FirstElementEvalFactory method createAggregateEvaluator.
@Override
public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
return new IAggregateEvaluator() {
private boolean first = true;
// Needs to copy the bytes from inputVal to outputVal because the byte space of inputVal could be re-used
// by consequent tuples.
private ArrayBackedValueStorage outputVal = new ArrayBackedValueStorage();
private IPointable inputVal = new VoidPointable();
private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
private final byte[] nullBytes = new byte[] { ATypeTag.SERIALIZED_NULL_TYPE_TAG };
private final byte[] systemNullBytes = new byte[] { ATypeTag.SERIALIZED_SYSTEM_NULL_TYPE_TAG };
@Override
public void init() throws HyracksDataException {
first = true;
}
@Override
public void step(IFrameTupleReference tuple) throws HyracksDataException {
if (!first) {
return;
}
eval.evaluate(tuple, inputVal);
byte typeTagByte = inputVal.getByteArray()[inputVal.getStartOffset()];
if (typeTagByte == ATypeTag.SERIALIZED_SYSTEM_NULL_TYPE_TAG) {
// Ignores SYSTEM_NULLs generated by local-first-element.
return;
}
outputVal.assign(inputVal);
first = false;
}
@Override
public void finish(IPointable result) throws HyracksDataException {
if (first) {
result.set(isLocal ? systemNullBytes : nullBytes, 0, 1);
return;
}
result.set(outputVal);
}
@Override
public void finishPartial(IPointable result) throws HyracksDataException {
finish(result);
}
};
}
Aggregations