Пример #1
0
 public boolean equals(Tuple tuple) {
   for (int i = 0; i < keys.length; i++) {
     final int field = keyIndex[i];
     final boolean n1 = keys[i] == null;
     final boolean n2 = tuple.isBlankOrNull(field);
     if (n1 && n2) {
       continue;
     }
     if (n1 ^ n2) {
       return false;
     }
     switch (keyTypes[i]) {
       case BOOLEAN:
         if ((Boolean) keys[i] != tuple.getBool(field)) return false;
         continue;
       case BIT:
         if ((Byte) keys[i] != tuple.getByte(field)) return false;
         continue;
       case INT1:
       case INT2:
         if ((Short) keys[i] != tuple.getInt2(field)) return false;
         continue;
       case INT4:
       case DATE:
         if ((Integer) keys[i] != tuple.getInt4(field)) return false;
         continue;
       case INT8:
       case TIME:
       case TIMESTAMP:
         if ((Long) keys[i] != tuple.getInt8(field)) return false;
         continue;
       case FLOAT4:
         if ((Float) keys[i] != tuple.getFloat4(field)) return false;
         continue;
       case FLOAT8:
         if ((Double) keys[i] != tuple.getFloat8(field)) return false;
         continue;
       case TEXT:
       case CHAR:
       case BLOB:
         if (!Arrays.equals((byte[]) keys[i], tuple.getBytes(field))) return false;
         continue;
       case DATUM:
         if (!keys[i].equals(tuple.asDatum(field))) return false;
         continue;
     }
   }
   return true;
 }
Пример #2
0
  @Override
  public Datum eval(Tuple tuple) {
    Datum resultDatum;

    for (int i = 0; i < tuple.size(); i++) {
      params[i] = WritableTypeConverter.convertDatum2Writable(tuple.asDatum(i));
    }

    try {
      Writable result = (Writable) evalMethod.invoke(instance, params);
      resultDatum = WritableTypeConverter.convertWritable2Datum(result);
    } catch (Exception e) {
      throw new TajoInternalError(e);
    }

    return resultDatum;
  }
Пример #3
0
 public void set(Tuple tuple) {
   for (int i = 0; i < keyTypes.length; i++) {
     final int field = keyIndex[i];
     if (tuple.isBlankOrNull(field)) {
       keys[i] = null;
       continue;
     }
     switch (keyTypes[i]) {
       case BOOLEAN:
         keys[i] = tuple.getBool(field);
         break;
       case BIT:
         keys[i] = tuple.getByte(field);
         break;
       case INT1:
       case INT2:
         keys[i] = tuple.getInt2(field);
         break;
       case INT4:
       case DATE:
         keys[i] = tuple.getInt4(field);
         break;
       case INT8:
       case TIME:
       case TIMESTAMP:
         keys[i] = tuple.getInt8(field);
         break;
       case FLOAT4:
         keys[i] = tuple.getFloat4(field);
         break;
       case FLOAT8:
         keys[i] = tuple.getFloat8(field);
         break;
       case TEXT:
       case CHAR:
       case BLOB:
         keys[i] = tuple.getBytes(field);
         break;
       case DATUM:
         keys[i] = tuple.asDatum(field);
         break;
       default:
         throw new IllegalArgumentException();
     }
   }
 }