@Override public void copy(int inputIdx, int count, int outputIdx) { // Date is given as number of days, we store as millis final long[] input = inputVector.vector; if (inputVector.isRepeating) { if (inputVector.isNull[0]) { return; // If all repeating values are null, then there is no need to write anything to vector } final long value = input[0] * MILLIS_PER_DAY; for (int i = 0; i < count; i++, outputIdx++) { outputVector.set(outputIdx, value); } } else if (inputVector.noNulls) { for (int i = 0; i < count; i++, inputIdx++, outputIdx++) { outputVector.set(outputIdx, input[inputIdx] * MILLIS_PER_DAY); } } else { final boolean isNull[] = inputVector.isNull; for (int i = 0; i < count; i++, inputIdx++, outputIdx++) { if (!isNull[inputIdx]) { outputVector.set(outputIdx, input[inputIdx] * MILLIS_PER_DAY); } } } } }
private static Pair<DateMilliVector, ResultVerifier> testDateMilliVector(final int startIndexInCurrentOutput, final int startIndexInJob) { DateMilliVector colDateV = new DateMilliVector("colDate", allocator); colDateV.allocateNew(5); colDateV.set(0, 234); colDateV.set(1, -2342); colDateV.setNull(2); colDateV.set(3, 384928359245L); colDateV.set(4, 2342893433L); ResultVerifier verifier = new ResultVerifier() { @Override public void verify(DataPOJO output) { int index = startIndexInCurrentOutput; assertEquals("1970-01-01", output.extractValue("colDate", index++)); assertEquals("1969-12-31", output.extractValue("colDate", index++)); assertNull(output.extractValue("colDate", index++)); assertEquals("1982-03-14", output.extractValue("colDate", index++)); assertEquals("1970-01-28", output.extractValue("colDate", index++)); } }; return Pair.of(colDateV, verifier); }
/** * Same as {@link #set(int, DateMilliHolder)} except that it handles the * case when index is greater than or equal to existing * value capacity {@link #getValueCapacity()}. * * @param index position of element * @param holder data holder for value of element */ public void setSafe(int index, DateMilliHolder holder) { handleSafe(index); set(index, holder); }
/** * Same as {@link #set(int, long)} except that it handles the * case when index is greater than or equal to existing * value capacity {@link #getValueCapacity()}. * * @param index position of element * @param value value of element */ public void setSafe(int index, long value) { handleSafe(index); set(index, value); }
/** * Same as {@link #set(int, NullableDateMilliHolder)} except that it handles the * case when index is greater than or equal to existing * value capacity {@link #getValueCapacity()}. * * @param index position of element * @param holder nullable data holder for value of element */ public void setSafe(int index, NullableDateMilliHolder holder) throws IllegalArgumentException { handleSafe(index); set(index, holder); }
/** * Same as {@link #set(int, int, long)} except that it handles the case * when index is greater than or equal to current value capacity of the * vector. * * @param index position of the new value * @param isSet 0 for NULL value, 1 otherwise * @param value element value */ public void setSafe(int index, int isSet, long value) { handleSafe(index); set(index, isSet, value); }
@Override void addNext(int start, int index) { int intValue; if (usingDictionary) { intValue = pageReader.dictionaryValueReader.readInteger(); } else { intValue = readIntLittleEndian(bytebuf, start); } if (intValue > ParquetReaderUtility.DATE_CORRUPTION_THRESHOLD) { vector.set(index, (intValue - ParquetReaderUtility.CORRECT_CORRUPT_DATE_SHIFT) * DateTimeConstants.MILLIS_PER_DAY); } else { vector.set(index, intValue * (long) DateTimeConstants.MILLIS_PER_DAY); } }
@Override void addNext(int start, int index) { int intValue; if (usingDictionary) { intValue = pageReader.dictionaryValueReader.readInteger(); } else { intValue = readIntLittleEndian(bytebuf, start); } if (intValue > ParquetReaderUtility.DATE_CORRUPTION_THRESHOLD) { dateVector.set(index, (intValue - ParquetReaderUtility.CORRECT_CORRUPT_DATE_SHIFT) * DateTimeConstants.MILLIS_PER_DAY); } else { dateVector.set(index, intValue * (long) DateTimeConstants.MILLIS_PER_DAY); } } }
/** * Store the given value at a particular position in the vector. isSet indicates * whether the value is NULL or not. * * @param index position of the new value * @param isSet 0 for NULL value, 1 otherwise * @param value element value */ public void set(int index, int isSet, long value) { if (isSet > 0) { set(index, value); } else { BitVectorHelper.setValidityBit(validityBuffer, index, 0); } }
@Override void addNext(int start, int index) { int intValue; if (usingDictionary) { intValue = pageReader.dictionaryValueReader.readInteger(); } else { intValue = readIntLittleEndian(bytebuf, start); } vector.set(index, intValue * (long) DateTimeConstants.MILLIS_PER_DAY); } }
@Override void addNext(int start, int index) { int intValue; if (usingDictionary) { intValue = pageReader.dictionaryValueReader.readInteger(); } else { intValue = readIntLittleEndian(bytebuf, start); } valueVec.set(index, (intValue - ParquetReaderUtility.CORRECT_CORRUPT_DATE_SHIFT) * DateTimeConstants.MILLIS_PER_DAY); }
@Override void addNext(int start, int index) { int intValue; if (usingDictionary) { intValue = pageReader.dictionaryValueReader.readInteger(); } else { intValue = readIntLittleEndian(bytebuf, start); } vector.set(index, (intValue - ParquetReaderUtility.CORRECT_CORRUPT_DATE_SHIFT) * DateTimeConstants.MILLIS_PER_DAY); }
@Override void addNext(int start, int index) { int intValue; if (usingDictionary) { intValue = pageReader.dictionaryValueReader.readInteger(); } else { intValue = readIntLittleEndian(bytebuf, start); } valueVec.set(index, intValue * (long) DateTimeConstants.MILLIS_PER_DAY); }