@Override
    public IJObject access(IVisitablePointable pointable, IObjectPool<IJObject, IAType> objectPool)
        throws HyracksDataException {
      IJObject jObject = objectPool.allocate(BuiltinType.ASTRING);

      try {
        byte byteArray[] = pointable.getByteArray();
        int len = pointable.getLength() - 3;
        int off = pointable.getStartOffset() + 3;
        baaos.reset();
        if (off >= 0 && off <= byteArray.length && len >= 0 && off + len - byteArray.length <= 0) {
          baaos.write(byteArray, off, len);
          ((JString) jObject).setValue(JObjectUtil.getNormalizedString(baaos.toString("UTF-8")));
        } else {
          ((JString) jObject).setValue("");
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
      return jObject;
    }
 protected void finishPartialResults() throws AlgebricksException {
   try {
     // Double check that count 0 is accounted
     if (aggType == ATypeTag.SYSTEM_NULL) {
       if (GlobalConfig.DEBUG) {
         GlobalConfig.ASTERIX_LOGGER.finest("AVG aggregate ran over empty input.");
       }
       out.writeByte(ATypeTag.SYSTEM_NULL.serialize());
     } else if (aggType == ATypeTag.NULL) {
       out.writeByte(ATypeTag.NULL.serialize());
     } else {
       sumBytes.reset();
       aDouble.setValue(sum);
       doubleSerde.serialize(aDouble, sumBytesOutput);
       countBytes.reset();
       aInt64.setValue(count);
       longSerde.serialize(aInt64, countBytesOutput);
       recordEval.evaluate(null);
     }
   } catch (IOException e) {
     throw new AlgebricksException(e);
   }
 }