Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW:17 & ARROW:18 #5

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public static ValueVector getNewVector(MaterializedField field, BufferAllocator
return getNewVector(field, allocator, null);
}
public static ValueVector getNewVector(MaterializedField field, BufferAllocator allocator, CallBack callBack){
field = field.clone();
MajorType type = field.getType();

switch (type.getMinorType()) {
Expand Down
2 changes: 1 addition & 1 deletion java/vector/src/main/codegen/templates/MapWriters.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public void end() {
}

public ${minor.class}Writer ${lowerName}(String name, int scale, int precision) {
final MajorType ${upperName}_TYPE = new MajorType(MinorType.${upperName}, DataMode.OPTIONAL, scale, precision, null, null);
final MajorType ${upperName}_TYPE = new MajorType(MinorType.${upperName}, DataMode.OPTIONAL, precision, scale, 0, null);
<#else>
private static final MajorType ${upperName}_TYPE = Types.optional(MinorType.${upperName});
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ public final class ${className} extends BaseDataValueVector implements <#if type
private final FieldReader reader = new Nullable${minor.class}ReaderImpl(Nullable${minor.class}Vector.this);

private final MaterializedField bitsField = MaterializedField.create("$bits$", new MajorType(MinorType.UINT1, DataMode.REQUIRED));
private final UInt1Vector bits = new UInt1Vector(bitsField, allocator);
private final ${valuesName} values = new ${minor.class}Vector(field, allocator);
private final MaterializedField valuesField = MaterializedField.create("$values$", new MajorType(field.getType().getMinorType(), DataMode.REQUIRED, field.getPrecision(), field.getScale()));

final UInt1Vector bits = new UInt1Vector(bitsField, allocator);
final ${valuesName} values = new ${minor.class}Vector(valuesField, allocator);

private final Mutator mutator = new Mutator();
private final Accessor accessor = new Accessor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class Repeated${minor.class}Vector extends BaseRepeatedValueVector
//private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Repeated${minor.class}Vector.class);

// we maintain local reference to concrete vector type for performance reasons.
private ${minor.class}Vector values;
${minor.class}Vector values;
private final FieldReader reader = new Repeated${minor.class}ReaderImpl(Repeated${minor.class}Vector.this);
private final Mutator mutator = new Mutator();
private final Accessor accessor = new Accessor();
Expand Down
4 changes: 2 additions & 2 deletions java/vector/src/main/codegen/templates/UnionVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public class UnionVector implements ValueVector {
private BufferAllocator allocator;
private Accessor accessor = new Accessor();
private Mutator mutator = new Mutator();
private int valueCount;
int valueCount;

private MapVector internalMap;
MapVector internalMap;
private UInt1Vector typeVector;

private MapVector mapVector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public final class ${minor.class}Vector extends BaseDataValueVector implements V

public final static String OFFSETS_VECTOR_NAME = "$offsets$";
private final MaterializedField offsetsField = MaterializedField.create(OFFSETS_VECTOR_NAME, new MajorType(MinorType.UINT4, DataMode.REQUIRED));
private final UInt${type.width}Vector offsetVector = new UInt${type.width}Vector(offsetsField, allocator);
final UInt${type.width}Vector offsetVector = new UInt${type.width}Vector(offsetsField, allocator);
private final FieldReader reader = new ${minor.class}ReaderImpl(${minor.class}Vector.this);

private final Accessor accessor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class BitVector extends BaseDataValueVector implements FixedWidthVe
private final Accessor accessor = new Accessor();
private final Mutator mutator = new Mutator();

private int valueCount;
int valueCount;
private int allocationSizeInBytes = INITIAL_VALUE_ALLOCATION;
private int allocationMonitor = 0;

Expand All @@ -64,7 +64,7 @@ public int getBufferSizeFor(final int valueCount) {
return getSizeFromCount(valueCount);
}

private int getSizeFromCount(int valueCount) {
int getSizeFromCount(int valueCount) {
return (int) Math.ceil(valueCount / 8.0);
}

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

public class ListVector extends BaseRepeatedValueVector {

private UInt4Vector offsets;
private final UInt1Vector bits;
UInt4Vector offsets;
final UInt1Vector bits;
private Mutator mutator = new Mutator();
private Accessor accessor = new Accessor();
private UnionListWriter writer;
Expand All @@ -72,6 +72,7 @@ public UnionListWriter getWriter() {
@Override
public void allocateNew() throws OutOfMemoryException {
super.allocateNewSafe();
bits.allocateNewSafe();
}

public void transferTo(ListVector target) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class MapVector extends AbstractMapVector {
private final SingleMapReaderImpl reader = new SingleMapReaderImpl(MapVector.this);
private final Accessor accessor = new Accessor();
private final Mutator mutator = new Mutator();
private int valueCount;
int valueCount;

public MapVector(String path, BufferAllocator allocator, CallBack callBack){
this(MaterializedField.create(path, TYPE), allocator, callBack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class RepeatedListVector extends AbstractContainerVector

public final static MajorType TYPE = new MajorType(MinorType.LIST, DataMode.REPEATED);
private final RepeatedListReaderImpl reader = new RepeatedListReaderImpl(null, this);
private final DelegateRepeatedVector delegate;
final DelegateRepeatedVector delegate;

protected static class DelegateRepeatedVector extends BaseRepeatedValueVector {

Expand Down Expand Up @@ -313,7 +313,6 @@ public <T extends ValueVector> AddOrGetResult<T> addOrGetVector(VectorDescriptor
if (result.isCreated() && callBack != null) {
callBack.doWork();
}
this.field = delegate.getField();
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class RepeatedMapVector extends AbstractMapVector

public final static MajorType TYPE = new MajorType(MinorType.MAP, DataMode.REPEATED);

private final UInt4Vector offsets; // offsets to start of each record (considering record indices are 0-indexed)
final UInt4Vector offsets; // offsets to start of each record (considering record indices are 0-indexed)
private final RepeatedMapReaderImpl reader = new RepeatedMapReaderImpl(RepeatedMapVector.this);
private final RepeatedMapAccessor accessor = new RepeatedMapAccessor();
private final Mutator mutator = new Mutator();
Expand Down
54 changes: 44 additions & 10 deletions java/vector/src/main/java/org/apache/arrow/vector/types/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class Types {
public enum MinorType {
Expand Down Expand Up @@ -73,26 +74,35 @@ public enum DataMode {
public static class MajorType {
private MinorType minorType;
private DataMode mode;
private Integer precision;
private Integer scale;
private Integer timezone;
private int precision;
private int scale;
private int timezone;
private int width;
private List<MinorType> subTypes;

public MajorType(MinorType minorType, DataMode mode) {
this(minorType, mode, null, null, null, null);
this(minorType, mode, 0, 0, 0, 0, null);
}

public MajorType(MinorType minorType, DataMode mode, Integer precision, Integer scale) {
this(minorType, mode, precision, scale, null, null);
public MajorType(MinorType minorType, DataMode mode, int precision, int scale) {
this(minorType, mode, precision, scale, 0, 0, null);
}

public MajorType(MinorType minorType, DataMode mode, Integer precision, Integer scale, Integer timezone, List<MinorType> subTypes) {
public MajorType(MinorType minorType, DataMode mode, int precision, int scale, int timezone, List<MinorType> subTypes) {
this(minorType, mode, precision, scale, timezone, 0, subTypes);
}

public MajorType(MinorType minorType, DataMode mode, int precision, int scale, int timezone, int width, List<MinorType> subTypes) {
this.minorType = minorType;
this.mode = mode;
this.precision = precision;
this.scale = scale;
this.timezone = timezone;
this.width = width;
this.subTypes = subTypes;
if (subTypes == null) {
this.subTypes = new ArrayList<>();
}
}

public MinorType getMinorType() {
Expand All @@ -103,21 +113,45 @@ public DataMode getMode() {
return mode;
}

public Integer getPrecision() {
public int getPrecision() {
return precision;
}

public Integer getScale() {
public int getScale() {
return scale;
}

public Integer getTimezone() {
public int getTimezone() {
return timezone;
}

public List<MinorType> getSubTypes() {
return subTypes;
}

public int getWidth() {
return width;
}


@Override
public boolean equals(Object other) {
if (other == null) {
return false;
}
if (!(other instanceof MajorType)) {
return false;
}
MajorType that = (MajorType) other;
return this.minorType == that.minorType &&
this.mode == that.mode &&
this.precision == that.precision &&
this.scale == that.scale &&
this.timezone == that.timezone &&
this.width == that.width &&
Objects.equals(this.subTypes, that.subTypes);
}

}

public static MajorType required(MinorType minorType) {
Expand Down
Loading