@Override public IJObject access(IVisitablePointable pointable, IObjectPool<IJObject, IAType> objectPool) throws HyracksDataException { byte[] b = pointable.getByteArray(); int s = pointable.getStartOffset(); short i = AInt16SerializerDeserializer.getShort(b, s + 1); IJObject jObject = objectPool.allocate(BuiltinType.AINT16); ((JInt) jObject).setValue(i); return null; }
protected void processDataValues(IFrameTupleReference tuple) throws AlgebricksException { if (skipStep()) { return; } inputVal.reset(); eval.evaluate(tuple); ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputVal.getByteArray()[0]); if (typeTag == ATypeTag.NULL) { processNull(); return; } else if (aggType == ATypeTag.SYSTEM_NULL) { aggType = typeTag; } else if (typeTag != ATypeTag.SYSTEM_NULL && !ATypeHierarchy.isCompatible(typeTag, aggType)) { throw new AlgebricksException( "Unexpected type " + typeTag + " in aggregation input stream. Expected type " + aggType + "."); } else if (ATypeHierarchy.canPromote(aggType, typeTag)) { aggType = typeTag; } ++count; switch (typeTag) { case INT8: { byte val = AInt8SerializerDeserializer.getByte(inputVal.getByteArray(), 1); sum += val; break; } case INT16: { short val = AInt16SerializerDeserializer.getShort(inputVal.getByteArray(), 1); sum += val; break; } case INT32: { int val = AInt32SerializerDeserializer.getInt(inputVal.getByteArray(), 1); sum += val; break; } case INT64: { long val = AInt64SerializerDeserializer.getLong(inputVal.getByteArray(), 1); sum += val; break; } case FLOAT: { float val = AFloatSerializerDeserializer.getFloat(inputVal.getByteArray(), 1); sum += val; break; } case DOUBLE: { double val = ADoubleSerializerDeserializer.getDouble(inputVal.getByteArray(), 1); sum += val; break; } default: { throw new NotImplementedException("Cannot compute AVG for values of type " + typeTag); } } inputVal.reset(); }