Exemple #1
0
  @Override
  public Datum eval(Tuple params) {
    if (params.isBlankOrNull(0)) {
      return NullDatum.get();
    }

    int value = params.getInt4(0);
    if (value <= 0 || value > 65525) {
      return NullDatum.get();
    } else {
      return DatumFactory.createText(String.valueOf((char) value));
    }
  }
Exemple #2
0
  @Override
  public Datum eval(Tuple params) {
    Datum datum = params.get(0);
    if (datum instanceof NullDatum) return NullDatum.get();

    return DatumFactory.createInt4(datum.asByteArray().length * 8);
  }
Exemple #3
0
  @Override
  public Datum eval(Tuple params) {

    if (params.isBlankOrNull(0) || params.isBlankOrNull(1)) {
      return NullDatum.get();
    }

    String fillText;
    if (hasFillCharacters) {
      fillText = params.getText(2);
    } else {
      fillText = " ";
    }

    String input = params.getText(0);
    int expected = params.getInt4(1);

    int templen = expected - params.size(0);

    if (templen <= 0) {
      return DatumFactory.createText(input.substring(0, expected));
    } else {
      return DatumFactory.createText(StringUtils.leftPad(input, expected, fillText));
    }
  }
Exemple #4
0
  @Override
  public Datum eval(Tuple params) {
    if (params.isBlankOrNull(0)) {
      return NullDatum.get();
    }

    return DatumFactory.createFloat8(Math.asin(params.getFloat8(0)));
  }
Exemple #5
0
  @Override
  public Datum eval(Tuple params) {
    if (params.isBlankOrNull(0)) {
      return NullDatum.get();
    }

    String ipstr = params.getText(0);

    return new Int4Datum(IPconvertUtil.ipstr2int(ipstr));
  }
 /** Called after all fields have been processed. */
 @Override
 public void end() {
   for (int i = 0; i < projectionMap.length; ++i) {
     final int projectionIndex = projectionMap[i];
     Column column = tajoReadSchema.getColumn(projectionIndex);
     if (column.getDataType().getType() == TajoDataTypes.Type.NULL_TYPE
         || currentTuple.isBlankOrNull(i)) {
       set(projectionIndex, NullDatum.get());
     }
   }
 }
 public Datum toDatum(int i) {
   if (keys[i] == null) {
     return NullDatum.get();
   }
   switch (keyTypes[i]) {
     case NULL_TYPE:
       return NullDatum.get();
     case BOOLEAN:
       return DatumFactory.createBool((Boolean) keys[i]);
     case BIT:
       return DatumFactory.createBit((Byte) keys[i]);
     case INT1:
     case INT2:
       return DatumFactory.createInt2((Short) keys[i]);
     case INT4:
       return DatumFactory.createInt4((Integer) keys[i]);
     case DATE:
       return DatumFactory.createDate((Integer) keys[i]);
     case INT8:
       return DatumFactory.createInt8((Long) keys[i]);
     case TIME:
       return DatumFactory.createTime((Long) keys[i]);
     case TIMESTAMP:
       return DatumFactory.createTimestamp((Long) keys[i]);
     case FLOAT4:
       return DatumFactory.createFloat4((Float) keys[i]);
     case FLOAT8:
       return DatumFactory.createFloat8((Double) keys[i]);
     case TEXT:
       return DatumFactory.createText((byte[]) keys[i]);
     case CHAR:
       return DatumFactory.createChar((byte[]) keys[i]);
     case BLOB:
       return DatumFactory.createBlob((byte[]) keys[i]);
     case DATUM:
       return (Datum) keys[i];
     default:
       throw new IllegalArgumentException();
   }
 }
Exemple #8
0
  @Override
  public Datum eval(Tuple params) {
    if (params.isBlankOrNull(0) || params.isBlankOrNull(1)) {
      return NullDatum.get();
    }

    String value = params.getText(0);
    String pattern = params.getText(1);

    TimeMeta tm = DateTimeFormat.parseDateTime(value, pattern);

    return new DateDatum(tm);
  }