Skip to content

Commit

Permalink
apacheGH-15187: Move supplier and just return new instance of FieldRe…
Browse files Browse the repository at this point in the history
…ader type when asked for impl
  • Loading branch information
rtadepalli committed Jun 17, 2023
1 parent 24deeeb commit 94fe92d
Show file tree
Hide file tree
Showing 41 changed files with 81 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ long computeCombinedBufferSize(int valueCount, int typeWidth) {
*
* @return Returns a lambda that initializes a reader when called.
*/
protected abstract Supplier<FieldReader> getReaderImpl();
protected abstract FieldReader getReaderImpl();

/**
* Default implementation to create a reader for the vector. Depends on the individual vector
Expand All @@ -169,7 +169,7 @@ public FieldReader getReader() {
}
synchronized (this) {
if (fieldReader == null) {
fieldReader = getReaderImpl().get();
fieldReader = getReaderImpl();
}

return fieldReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.complex.impl.BigIntReaderImpl;
Expand Down Expand Up @@ -75,8 +73,8 @@ public BigIntVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new BigIntReaderImpl(BigIntVector.this);
protected FieldReader getReaderImpl() {
return new BigIntReaderImpl(BigIntVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import static org.apache.arrow.memory.util.LargeMemoryUtil.capAtMaxInt;
import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.util.ArrowBufPointer;
Expand Down Expand Up @@ -83,8 +81,8 @@ public BitVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new BitReaderImpl(BitVector.this);
protected FieldReader getReaderImpl() {
return new BitReaderImpl(BitVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.complex.impl.DateDayReaderImpl;
Expand Down Expand Up @@ -76,8 +74,8 @@ public DateDayVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new DateDayReaderImpl(DateDayVector.this);
protected FieldReader getReaderImpl() {
return new DateDayReaderImpl(DateDayVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.time.LocalDateTime;
import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
Expand Down Expand Up @@ -77,8 +76,8 @@ public DateMilliVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new DateMilliReaderImpl(DateMilliVector.this);
protected FieldReader getReaderImpl() {
return new DateMilliReaderImpl(DateMilliVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import java.math.BigDecimal;
import java.nio.ByteOrder;
import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
Expand Down Expand Up @@ -90,8 +89,8 @@ public Decimal256Vector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new Decimal256ReaderImpl(Decimal256Vector.this);
protected FieldReader getReaderImpl() {
return new Decimal256ReaderImpl(Decimal256Vector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import java.math.BigDecimal;
import java.nio.ByteOrder;
import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
Expand Down Expand Up @@ -89,8 +88,8 @@ public DecimalVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new DecimalReaderImpl(DecimalVector.this);
protected FieldReader getReaderImpl() {
return new DecimalReaderImpl(DecimalVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.time.Duration;
import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
Expand Down Expand Up @@ -72,8 +71,8 @@ public DurationVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new DurationReaderImpl(DurationVector.this);
protected FieldReader getReaderImpl() {
return new DurationReaderImpl(DurationVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import java.util.Iterator;
import java.util.List;
import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
Expand Down Expand Up @@ -132,13 +131,7 @@ public TransferPair makeTransferPair(ValueVector target) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
throw new UnsupportedOperationException("Readers for extension types depend on the underlying vector, " +
"asking for a concrete implementation class of the reader type is invalid.");
}

@Override
public FieldReader getReader() {
protected FieldReader getReaderImpl() {
return underlyingVector.getReader();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.util.Preconditions;
Expand Down Expand Up @@ -79,8 +77,8 @@ public FixedSizeBinaryVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new FixedSizeBinaryReaderImpl(FixedSizeBinaryVector.this);
protected FieldReader getReaderImpl() {
return new FixedSizeBinaryReaderImpl(FixedSizeBinaryVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.complex.impl.Float4ReaderImpl;
Expand Down Expand Up @@ -75,8 +73,8 @@ public Float4Vector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new Float4ReaderImpl(Float4Vector.this);
protected FieldReader getReaderImpl() {
return new Float4ReaderImpl(Float4Vector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.complex.impl.Float8ReaderImpl;
Expand Down Expand Up @@ -75,8 +73,8 @@ public Float8Vector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new Float8ReaderImpl(Float8Vector.this);
protected FieldReader getReaderImpl() {
return new Float8ReaderImpl(Float8Vector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.complex.impl.IntReaderImpl;
Expand Down Expand Up @@ -75,8 +73,8 @@ public IntVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new IntReaderImpl(IntVector.this);
protected FieldReader getReaderImpl() {
return new IntReaderImpl(IntVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.time.Duration;
import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
Expand Down Expand Up @@ -78,8 +77,8 @@ public IntervalDayVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new IntervalDayReaderImpl(IntervalDayVector.this);
protected FieldReader getReaderImpl() {
return new IntervalDayReaderImpl(IntervalDayVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import java.time.Duration;
import java.time.Period;
import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
Expand Down Expand Up @@ -84,8 +83,8 @@ public IntervalMonthDayNanoVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new IntervalMonthDayNanoReaderImpl(IntervalMonthDayNanoVector.this);
protected FieldReader getReaderImpl() {
return new IntervalMonthDayNanoReaderImpl(IntervalMonthDayNanoVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.time.Period;
import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
Expand Down Expand Up @@ -76,8 +75,8 @@ public IntervalYearVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new IntervalYearReaderImpl(IntervalYearVector.this);
protected FieldReader getReaderImpl() {
return new IntervalYearReaderImpl(IntervalYearVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.apache.arrow.vector;

import java.util.function.Supplier;

import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.complex.impl.LargeVarBinaryReaderImpl;
import org.apache.arrow.vector.complex.reader.FieldReader;
Expand Down Expand Up @@ -72,8 +70,8 @@ public LargeVarBinaryVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new LargeVarBinaryReaderImpl(LargeVarBinaryVector.this);
protected FieldReader getReaderImpl() {
return new LargeVarBinaryReaderImpl(LargeVarBinaryVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.apache.arrow.vector;

import java.util.function.Supplier;

import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.complex.impl.LargeVarCharReaderImpl;
import org.apache.arrow.vector.complex.reader.FieldReader;
Expand Down Expand Up @@ -73,8 +71,8 @@ public LargeVarCharVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new LargeVarCharReaderImpl(LargeVarCharVector.this);
protected FieldReader getReaderImpl() {
return new LargeVarCharReaderImpl(LargeVarCharVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.complex.impl.SmallIntReaderImpl;
Expand Down Expand Up @@ -75,8 +73,8 @@ public SmallIntVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new SmallIntReaderImpl(SmallIntVector.this);
protected FieldReader getReaderImpl() {
return new SmallIntReaderImpl(SmallIntVector.this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;

import java.util.function.Supplier;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.complex.impl.TimeMicroReaderImpl;
Expand Down Expand Up @@ -76,8 +74,8 @@ public TimeMicroVector(Field field, BufferAllocator allocator) {
}

@Override
protected Supplier<FieldReader> getReaderImpl() {
return () -> new TimeMicroReaderImpl(TimeMicroVector.this);
protected FieldReader getReaderImpl() {
return new TimeMicroReaderImpl(TimeMicroVector.this);
}

/**
Expand Down

0 comments on commit 94fe92d

Please sign in to comment.