result += BigintOperators.add(leftOperand0, rightOperand0); result += BigintOperators.add(leftOperand1, rightOperand0); result += BigintOperators.add(leftOperand2, rightOperand0); result += BigintOperators.add(leftOperand3, rightOperand0); result += BigintOperators.add(leftOperand4, rightOperand0); result += BigintOperators.add(leftOperand0, rightOperand1); result += BigintOperators.add(leftOperand1, rightOperand1); result += BigintOperators.add(leftOperand2, rightOperand1); result += BigintOperators.add(leftOperand3, rightOperand1); result += BigintOperators.add(leftOperand4, rightOperand1); result += BigintOperators.add(leftOperand0, rightOperand2); result += BigintOperators.add(leftOperand1, rightOperand2); result += BigintOperators.add(leftOperand2, rightOperand2); result += BigintOperators.add(leftOperand3, rightOperand2); result += BigintOperators.add(leftOperand4, rightOperand2); result += BigintOperators.add(leftOperand0, rightOperand3); result += BigintOperators.add(leftOperand1, rightOperand3); result += BigintOperators.add(leftOperand2, rightOperand3); result += BigintOperators.add(leftOperand3, rightOperand3); result += BigintOperators.add(leftOperand4, rightOperand3); result += BigintOperators.add(leftOperand0, rightOperand4); result += BigintOperators.add(leftOperand1, rightOperand4); result += BigintOperators.add(leftOperand2, rightOperand4); result += BigintOperators.add(leftOperand3, rightOperand4); result += BigintOperators.add(leftOperand4, rightOperand4); return result;
public static Boolean currentTokenAsBoolean(JsonParser parser) throws IOException { switch (parser.currentToken()) { case VALUE_NULL: return null; case VALUE_STRING: case FIELD_NAME: return VarcharOperators.castToBoolean(Slices.utf8Slice(parser.getText())); case VALUE_NUMBER_FLOAT: return DoubleOperators.castToBoolean(parser.getDoubleValue()); case VALUE_NUMBER_INT: return BigintOperators.castToBoolean(parser.getLongValue()); case VALUE_TRUE: return true; case VALUE_FALSE: return false; default: throw new JsonCastException(format("Unexpected token when cast to %s: %s", StandardTypes.BOOLEAN, parser.getText())); } }
result += BigintOperators.divide(leftOperand0, rightOperand0); result += BigintOperators.divide(leftOperand1, rightOperand0); result += BigintOperators.divide(leftOperand2, rightOperand0); result += BigintOperators.divide(leftOperand3, rightOperand0); result += BigintOperators.divide(leftOperand4, rightOperand0); result += BigintOperators.divide(leftOperand0, rightOperand1); result += BigintOperators.divide(leftOperand1, rightOperand1); result += BigintOperators.divide(leftOperand2, rightOperand1); result += BigintOperators.divide(leftOperand3, rightOperand1); result += BigintOperators.divide(leftOperand4, rightOperand1); result += BigintOperators.divide(leftOperand0, rightOperand2); result += BigintOperators.divide(leftOperand1, rightOperand2); result += BigintOperators.divide(leftOperand2, rightOperand2); result += BigintOperators.divide(leftOperand3, rightOperand2); result += BigintOperators.divide(leftOperand4, rightOperand2); result += BigintOperators.divide(leftOperand0, rightOperand3); result += BigintOperators.divide(leftOperand1, rightOperand3); result += BigintOperators.divide(leftOperand2, rightOperand3); result += BigintOperators.divide(leftOperand3, rightOperand3); result += BigintOperators.divide(leftOperand4, rightOperand3); result += BigintOperators.divide(leftOperand0, rightOperand4); result += BigintOperators.divide(leftOperand1, rightOperand4); result += BigintOperators.divide(leftOperand2, rightOperand4); result += BigintOperators.divide(leftOperand3, rightOperand4); result += BigintOperators.divide(leftOperand4, rightOperand4); return result;
@Override public void appendValuesTo(int groupId, PageBuilder pageBuilder, int outputChannelOffset) { checkArgument(groupId >= 0, "groupId is negative"); BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(outputChannelOffset); if (groupId == nullGroupId) { blockBuilder.appendNull(); } else { BIGINT.writeLong(blockBuilder, valuesByGroupId.get(groupId)); } if (outputRawHash) { BlockBuilder hashBlockBuilder = pageBuilder.getBlockBuilder(outputChannelOffset + 1); if (groupId == nullGroupId) { BIGINT.writeLong(hashBlockBuilder, NULL_HASH_CODE); } else { BIGINT.writeLong(hashBlockBuilder, BigintOperators.hashCode(valuesByGroupId.get(groupId))); } } }
@SqlType(StandardTypes.BOOLEAN) public static boolean isDistinctFrom( @SqlType(StandardTypes.BIGINT) long left, @IsNull boolean leftNull, @SqlType(StandardTypes.BIGINT) long right, @IsNull boolean rightNull) { if (leftNull != rightNull) { return true; } if (leftNull) { return false; } return notEqual(left, right); }
@Benchmark public Object overflowChecksNegate() { long result = 0; result += BigintOperators.negate(leftOperand0); result += BigintOperators.negate(leftOperand1); result += BigintOperators.negate(leftOperand2); result += BigintOperators.negate(leftOperand3); result += BigintOperators.negate(leftOperand4); result += BigintOperators.negate(rightOperand0); result += BigintOperators.negate(rightOperand1); result += BigintOperators.negate(rightOperand2); result += BigintOperators.negate(rightOperand3); result += BigintOperators.negate(rightOperand4); return result; }
result += BigintOperators.multiply(leftOperand0, rightOperand0); result += BigintOperators.multiply(leftOperand1, rightOperand0); result += BigintOperators.multiply(leftOperand2, rightOperand0); result += BigintOperators.multiply(leftOperand3, rightOperand0); result += BigintOperators.multiply(leftOperand4, rightOperand0); result += BigintOperators.multiply(leftOperand0, rightOperand1); result += BigintOperators.multiply(leftOperand1, rightOperand1); result += BigintOperators.multiply(leftOperand2, rightOperand1); result += BigintOperators.multiply(leftOperand3, rightOperand1); result += BigintOperators.multiply(leftOperand4, rightOperand1); result += BigintOperators.multiply(leftOperand0, rightOperand2); result += BigintOperators.multiply(leftOperand1, rightOperand2); result += BigintOperators.multiply(leftOperand2, rightOperand2); result += BigintOperators.multiply(leftOperand3, rightOperand2); result += BigintOperators.multiply(leftOperand4, rightOperand2); result += BigintOperators.multiply(leftOperand0, rightOperand3); result += BigintOperators.multiply(leftOperand1, rightOperand3); result += BigintOperators.multiply(leftOperand2, rightOperand3); result += BigintOperators.multiply(leftOperand3, rightOperand3); result += BigintOperators.multiply(leftOperand4, rightOperand3); result += BigintOperators.multiply(leftOperand0, rightOperand4); result += BigintOperators.multiply(leftOperand1, rightOperand4); result += BigintOperators.multiply(leftOperand2, rightOperand4); result += BigintOperators.multiply(leftOperand3, rightOperand4); result += BigintOperators.multiply(leftOperand4, rightOperand4); return result;
private static List<Page> createBigintPages(int positionCount, int groupCount, int channelCount, boolean hashEnabled) { List<Type> types = Collections.nCopies(channelCount, BIGINT); ImmutableList.Builder<Page> pages = ImmutableList.builder(); if (hashEnabled) { types = ImmutableList.copyOf(Iterables.concat(types, ImmutableList.of(BIGINT))); } PageBuilder pageBuilder = new PageBuilder(types); for (int position = 0; position < positionCount; position++) { int rand = ThreadLocalRandom.current().nextInt(groupCount); pageBuilder.declarePosition(); for (int numChannel = 0; numChannel < channelCount; numChannel++) { BIGINT.writeLong(pageBuilder.getBlockBuilder(numChannel), rand); } if (hashEnabled) { BIGINT.writeLong(pageBuilder.getBlockBuilder(channelCount), BigintOperators.hashCode(rand)); } if (pageBuilder.isFull()) { pages.add(pageBuilder.build()); pageBuilder.reset(); } } pages.add(pageBuilder.build()); return pages.build(); }
@SqlType(StandardTypes.BOOLEAN) public static boolean isDistinctFrom( @BlockPosition @SqlType(value = StandardTypes.BIGINT, nativeContainerType = long.class) Block left, @BlockIndex int leftPosition, @BlockPosition @SqlType(value = StandardTypes.BIGINT, nativeContainerType = long.class) Block right, @BlockIndex int rightPosition) { if (left.isNull(leftPosition) != right.isNull(rightPosition)) { return true; } if (left.isNull(leftPosition)) { return false; } return notEqual(BIGINT.getLong(left, leftPosition), BIGINT.getLong(right, rightPosition)); } }
@Override public void appendValuesTo(int groupId, PageBuilder pageBuilder, int outputChannelOffset) { checkArgument(groupId >= 0, "groupId is negative"); BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(outputChannelOffset); if (groupId == nullGroupId) { blockBuilder.appendNull(); } else { BIGINT.writeLong(blockBuilder, valuesByGroupId.get(groupId)); } if (outputRawHash) { BlockBuilder hashBlockBuilder = pageBuilder.getBlockBuilder(outputChannelOffset + 1); if (groupId == nullGroupId) { BIGINT.writeLong(hashBlockBuilder, NULL_HASH_CODE); } else { BIGINT.writeLong(hashBlockBuilder, BigintOperators.hashCode(valuesByGroupId.get(groupId))); } } }
@InputFunction public static void sum(NullableLongState state, @SqlType(INTERVAL_YEAR_TO_MONTH) long value) { state.setNull(false); state.setLong(BigintOperators.add(state.getLong(), value)); }
break; case VALUE_NUMBER_INT: result = BigintOperators.castToBoolean(parser.getLongValue()); break; case VALUE_TRUE:
private static List<Page> createPages(int positionCount, int groupCount, List<Type> types, boolean hashEnabled) { int channelCount = types.size(); ImmutableList.Builder<Page> pages = ImmutableList.builder(); if (hashEnabled) { types = ImmutableList.copyOf(Iterables.concat(types, ImmutableList.of(BIGINT))); } PageBuilder pageBuilder = new PageBuilder(types); for (int position = 0; position < positionCount; position++) { int rand = ThreadLocalRandom.current().nextInt(groupCount); pageBuilder.declarePosition(); for (int numChannel = 0; numChannel < channelCount; numChannel++) { BIGINT.writeLong(pageBuilder.getBlockBuilder(numChannel), rand); } if (hashEnabled) { BIGINT.writeLong(pageBuilder.getBlockBuilder(channelCount), BigintOperators.hashCode(rand)); } if (pageBuilder.isFull()) { pages.add(pageBuilder.build()); pageBuilder.reset(); } } pages.add(pageBuilder.build()); return pages.build(); }
@InputFunction public static void sum(NullableLongState state, @SqlType(INTERVAL_DAY_TO_SECOND) long value) { state.setNull(false); state.setLong(BigintOperators.add(state.getLong(), value)); }
int rawHash = (int) BigintOperators.hashCode(i);
@InputFunction public static void sum(@AggregationState NullableLongState state, @SqlType(StandardTypes.BIGINT) long value) { state.setNull(false); state.setLong(BigintOperators.add(state.getLong(), value)); }
int rawHash = (int) BigintOperators.hashCode(i);
@CombineFunction public static void combine(NullableLongState state, NullableLongState otherState) { if (state.isNull()) { state.setNull(false); state.setLong(otherState.getLong()); return; } state.setLong(BigintOperators.add(state.getLong(), otherState.getLong())); }
@CombineFunction public static void combine(NullableLongState state, NullableLongState otherState) { if (state.isNull()) { state.setNull(false); state.setLong(otherState.getLong()); return; } state.setLong(BigintOperators.add(state.getLong(), otherState.getLong())); }
@CombineFunction public static void combine(@AggregationState NullableLongState state, @AggregationState NullableLongState otherState) { if (state.isNull()) { state.setNull(false); state.setLong(otherState.getLong()); return; } state.setLong(BigintOperators.add(state.getLong(), otherState.getLong())); }