@Override protected boolean evaluateInteger(long lhs, long rhs, AMutableInt64 result) throws HyracksDataException { if (rhs == 0) { return false; // result = NULL } long res = lhs % rhs; result.setValue(res); return true; }
@Override protected void processInt64(long arg, IPointable resultPointable) throws HyracksDataException { aInt64.setValue(-arg); serialize(aInt64, int64Serde, resultPointable); }
public boolean isIntegerValue(AMutableInt64 i) { if (valueType == ValueType.INTEGER_VALUE) { i.setValue(longVal); return true; } return false; }
@Override protected boolean evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime, boolean isTimeOnly, AMutableInt64 result) throws HyracksDataException { long res = DurationArithmeticOperations.addDuration(chronon, -1 * yearMonth, -1 * dayTime, isTimeOnly); result.setValue(res); return true; }
@Override protected boolean evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime, boolean isTimeOnly, AMutableInt64 result) throws HyracksDataException { long res = DurationArithmeticOperations.addDuration(chronon, yearMonth, dayTime, isTimeOnly); result.setValue(res); return true; }
protected void computeResult(DataOutput out) throws HyracksDataException { aInt64.setValue(rank); serde.serialize(aInt64, out); } }
protected void writeResult(int ed) throws IOException { aInt64.setValue(ed); int64Serde.serialize(aInt64, out); } }
public void setMetadata(final int index, final long value) throws IOException { fieldValueBufferOutputs[index].writeByte(fieldTypeTags[index]); mutableLong.setValue(value); IDataParser.toBytes(mutableLong, fieldValueBuffers[index], int64Serde); }
@Override protected void processInt64(long arg, IPointable resultPointable) throws HyracksDataException { if (arg >= 0) { resultPointable.set(argPtr); return; } aInt64.setValue(0L - arg); serialize(aInt64, int64Serde, resultPointable); }
@Override protected boolean evaluateInteger(long lhs, long rhs, AMutableInt64 result) throws HyracksDataException { if (rhs == 0) { return false; // result = NULL } if ((lhs == Long.MIN_VALUE) && (rhs == -1L)) { throw new OverflowException(sourceLoc, getIdentifier()); } long res = lhs / rhs; result.setValue(res); return true; }
@Override protected boolean evaluateInteger(long x, long y, AMutableInt64 result) throws HyracksDataException { try { long res = Math.addExact(x, y); result.setValue(res); return true; } catch (ArithmeticException e) { throw new OverflowException(sourceLoc, getIdentifier()); } }
@Override public void initPartition(long partitionLength) throws HyracksDataException { resultStorage.reset(); aInt64.setValue(partitionLength); serde.serialize(aInt64, resultStorage.getDataOutput()); }
@Override protected boolean evaluateInteger(long lhs, long rhs, AMutableInt64 result) throws HyracksDataException { try { long res = Math.multiplyExact(lhs, rhs); result.setValue(res); return true; } catch (ArithmeticException e) { throw new OverflowException(sourceLoc, getIdentifier()); } }
@Override protected boolean evaluateInteger(long lhs, long rhs, AMutableInt64 result) throws HyracksDataException { try { long res = Math.subtractExact(lhs, rhs); result.setValue(res); return true; } catch (ArithmeticException e) { throw new OverflowException(sourceLoc, getIdentifier()); } }
@Override public void index(ArrayTupleBuilder tb) throws HyracksDataException { try { tb.addField(intSerde, fileNumber); tb.addField(longSerde, offset); // Get position for next index(tb) call offset.setValue(recordReader.getPos()); } catch (IOException e) { throw HyracksDataException.create(e); } }
@Override public void step(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { resultValue++; resultStorage.reset(); aInt64.setValue(resultValue); serde.serialize(aInt64, resultStorage.getDataOutput()); result.set(resultStorage); } }
@Override public void finish(IPointable resultPointable) throws HyracksDataException { resultStorage.reset(); try { result.setValue(cnt); int64Serde.serialize(result, resultStorage.getDataOutput()); } catch (IOException e) { throw HyracksDataException.create(e); } resultPointable.set(resultStorage); }
@Override public void reset(IIndexingDatasource dataSource) throws HyracksDataException { try { //TODO: Make it more generic since we can't assume it is always going to be HDFS records fileNumber.setValue(dataSource.getSnapshot().get(dataSource.getCurrentSplitIndex()).getFileNumber()); recordReader = dataSource.getReader(); offset.setValue(recordReader.getPos()); } catch (IOException e) { throw HyracksDataException.create(e); } }
@Override protected boolean evaluateInteger(long lhs, long rhs, AMutableInt64 result) throws HyracksDataException { if (rhs > Integer.MAX_VALUE) { throw new OverflowException(sourceLoc, getIdentifier()); } try { long res = LongMath.checkedPow(lhs, (int) rhs); result.setValue(res); return true; } catch (ArithmeticException e) { throw new OverflowException(sourceLoc, getIdentifier()); } }
private void writeRebalanceCount(Dataset dataset) throws HyracksDataException { if (dataset.getRebalanceCount() > 0) { // Adds the field rebalanceCount. fieldName.reset(); aString.setValue(MetadataRecordTypes.DATASET_ARECORD_REBALANCE_FIELD_NAME); stringSerde.serialize(aString, fieldName.getDataOutput()); fieldValue.reset(); aBigInt.setValue(dataset.getRebalanceCount()); aBigIntSerde.serialize(aBigInt, fieldValue.getDataOutput()); recordBuilder.addField(fieldName, fieldValue); } }