Exemplo n.º 1
0
  static {
    declare(AggregateFcts.countRowsFunction);
    declare(TimeFcts.nowFct);
    declare(TimeFcts.minTimeuuidFct);
    declare(TimeFcts.maxTimeuuidFct);
    declare(TimeFcts.dateOfFct);
    declare(TimeFcts.unixTimestampOfFct);
    declare(TimeFcts.timeUuidtoDate);
    declare(TimeFcts.timeUuidToTimestamp);
    declare(TimeFcts.timeUuidToUnixTimestamp);
    declare(TimeFcts.timestampToDate);
    declare(TimeFcts.timestampToUnixTimestamp);
    declare(TimeFcts.dateToTimestamp);
    declare(TimeFcts.dateToUnixTimestamp);
    declare(UuidFcts.uuidFct);

    for (CQL3Type type : CQL3Type.Native.values()) {
      // Note: because text and varchar ends up being synonymous, our automatic makeToBlobFunction
      // doesn't work
      // for varchar, so we special case it below. We also skip blob for obvious reasons.
      if (type != CQL3Type.Native.VARCHAR && type != CQL3Type.Native.BLOB) {
        declare(BytesConversionFcts.makeToBlobFunction(type.getType()));
        declare(BytesConversionFcts.makeFromBlobFunction(type.getType()));
      }
    }
    declare(BytesConversionFcts.VarcharAsBlobFct);
    declare(BytesConversionFcts.BlobAsVarcharFact);

    for (CQL3Type type : CQL3Type.Native.values()) {
      // special case varchar to avoid duplicating functions for UTF8Type
      if (type != CQL3Type.Native.VARCHAR) {
        declare(AggregateFcts.makeCountFunction(type.getType()));
        declare(AggregateFcts.makeMaxFunction(type.getType()));
        declare(AggregateFcts.makeMinFunction(type.getType()));
      }
    }
    declare(AggregateFcts.sumFunctionForByte);
    declare(AggregateFcts.sumFunctionForShort);
    declare(AggregateFcts.sumFunctionForInt32);
    declare(AggregateFcts.sumFunctionForLong);
    declare(AggregateFcts.sumFunctionForFloat);
    declare(AggregateFcts.sumFunctionForDouble);
    declare(AggregateFcts.sumFunctionForDecimal);
    declare(AggregateFcts.sumFunctionForVarint);
    declare(AggregateFcts.sumFunctionForCounter);
    declare(AggregateFcts.avgFunctionForByte);
    declare(AggregateFcts.avgFunctionForShort);
    declare(AggregateFcts.avgFunctionForInt32);
    declare(AggregateFcts.avgFunctionForLong);
    declare(AggregateFcts.avgFunctionForFloat);
    declare(AggregateFcts.avgFunctionForDouble);
    declare(AggregateFcts.avgFunctionForVarint);
    declare(AggregateFcts.avgFunctionForDecimal);
    declare(AggregateFcts.avgFunctionForCounter);

    declare(RangeAggregateFcts.rangeAggregationFunctionForTimestampToDouble);

    MigrationManager.instance.register(new FunctionsMigrationListener());
  }
Exemplo n.º 2
0
  public static Collection<AggregateFunction> all() {
    Collection<AggregateFunction> functions = new ArrayList<>();

    functions.add(countRowsFunction);

    // sum for primitives
    functions.add(sumFunctionForByte);
    functions.add(sumFunctionForShort);
    functions.add(sumFunctionForInt32);
    functions.add(sumFunctionForLong);
    functions.add(sumFunctionForFloat);
    functions.add(sumFunctionForDouble);
    functions.add(sumFunctionForDecimal);
    functions.add(sumFunctionForVarint);

    // avg for primitives
    functions.add(avgFunctionForByte);
    functions.add(avgFunctionForShort);
    functions.add(avgFunctionForInt32);
    functions.add(avgFunctionForLong);
    functions.add(avgFunctionForFloat);
    functions.add(avgFunctionForDouble);
    functions.add(avgFunctionForDecimal);
    functions.add(avgFunctionForVarint);

    // count, max, and min for all standard types
    for (CQL3Type type : CQL3Type.Native.values()) {
      if (type != CQL3Type.Native.VARCHAR) // varchar and text both mapping to UTF8Type
      {
        functions.add(AggregateFcts.makeCountFunction(type.getType()));
        functions.add(AggregateFcts.makeMaxFunction(type.getType()));
        functions.add(AggregateFcts.makeMinFunction(type.getType()));
      }
    }

    return functions;
  }