long value = date.getMillis(); for (int i = start; i < end; i++) { v.getMutator().setSafe(i, value);
@Override public void load(int rowIndex, String value) { try { Date d = df.parse(value); long milliseconds = d.getTime(); mutator.set(rowIndex, milliseconds); } catch (NumberFormatException e) { throw UserException .dataReadError(e) .addContext("Failed to parse an DATE field") .addContext("Column", getName()) .addContext("Position", getIndex()) .addContext("Value", value) .build(logger); } catch (ParseException e) { throw UserException .dataReadError(e) .addContext("Date Format String does not match field value.") .addContext("Column", getName()) .addContext("Position", getIndex()) .addContext("Format String", getFormat()) .addContext("Value", value) .build(logger); } } }
@Override public boolean allocateNewSafe() { /* Boolean to keep track if all the memory allocations were successful * Used in the case of composite vectors when we need to allocate multiple * buffers for multiple vectors. If one of the allocations failed we need to * clear all the memory that we allocated */ boolean success = false; try { success = values.allocateNewSafe() && bits.allocateNewSafe(); } finally { if (!success) { clear(); } } bits.zeroVector(); mutator.reset(); accessor.reset(); return success; }
@Override public void allocateNew(int valueCount) { try { values.allocateNew(valueCount); bits.allocateNew(valueCount); } catch(OutOfMemoryException e) { clear(); throw e; } bits.zeroVector(); mutator.reset(); accessor.reset(); }
public void writeDate(long value) { mutator.setSafe(idx(), 1, value); vector.getMutator().setValueCount(idx() + 1); }
public void write(DateHolder h) { mutator.setSafe(idx(), h); vector.getMutator().setValueCount(idx()+1); }
public void writeNull() { mutator.setNull(idx()); vector.getMutator().setValueCount(idx() + 1); }
@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) { valueVec.getMutator().set(index, (intValue - ParquetReaderUtility.CORRECT_CORRUPT_DATE_SHIFT) * DateTimeConstants.MILLIS_PER_DAY); } else { valueVec.getMutator().set(index, intValue * (long) DateTimeConstants.MILLIS_PER_DAY); } } }
public void setSafe(int index, NullableDateHolder holder) { setType(index, MinorType.DATE); getDateVector().getMutator().setSafe(index, holder); }
@Override public void generateTestData(int valueCount){ bits.getMutator().generateTestDataAlt(valueCount); values.getMutator().generateTestData(valueCount); setValueCount(valueCount); }
@Override public void exchange(ValueVector other) { NullableDateVector target = (NullableDateVector) other; bits.exchange(target.bits); values.exchange(target.values); mutator.exchange(other.getMutator()); }
public void copyFrom(int fromIndex, int thisIndex, NullableDateVector from){ final Accessor fromAccessor = from.getAccessor(); if (!fromAccessor.isNull(fromIndex)) { mutator.set(thisIndex, fromAccessor.get(fromIndex)); } }
public void fromNotNullable(DateVector srce) { clear(); final int valueCount = srce.getAccessor().getValueCount(); // Create a new bits vector, all values non-null fillBitsVector(getBitsVector(), valueCount); // Swap the data portion getValuesVector().exchange(srce); setValueCount(valueCount); } }
@Override void addNext(int start, int index) { int intValue; if (usingDictionary) { intValue = pageReader.dictionaryValueReader.readInteger(); } else { intValue = readIntLittleEndian(bytebuf, start); } valueVec.getMutator().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.getMutator().set(index, intValue * (long) DateTimeConstants.MILLIS_PER_DAY); }
@Override public void reset() { bits.zeroVector(); mutator.reset(); accessor.reset(); super.reset(); }
@Override public void toNullable(ValueVector nullableVector) { NullableDateVector dest = (NullableDateVector) nullableVector; dest.getMutator().fromNotNullable(this); }
public void write(NullableDateHolder h) { mutator.setSafe(idx(), h); vector.getMutator().setValueCount(idx()+1); }
@Override public boolean allocateNewSafe() { /* Boolean to keep track if all the memory allocations were successful * Used in the case of composite vectors when we need to allocate multiple * buffers for multiple vectors. If one of the allocations failed we need to * clear all the memory that we allocated */ boolean success = false; try { success = values.allocateNewSafe() && bits.allocateNewSafe(); } finally { if (!success) { clear(); } } bits.zeroVector(); mutator.reset(); accessor.reset(); return success; }