Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
28b25d1
Barrage: Refactor Read/Write Chunk Factories
nbauernfeind Sep 16, 2024
8876208
Ryan's feedback and bug fixes
nbauernfeind Sep 16, 2024
27df3d3
dunno .. stuf
nbauernfeind Oct 16, 2024
1852b0a
Restore initial commit from grpc-java, plus a few local changes
niloc132 Oct 21, 2024
68b925a
Guard writing payload as hex if FINEST is enabled
niloc132 Oct 21, 2024
e88c47e
Apply upstream "Fix AsyncServletOutputStreamWriterConcurrencyTest
niloc132 Oct 21, 2024
f9a19fc
Apply upstream "Avoid flushing headers when the server returns a single
niloc132 Oct 21, 2024
4733524
Apply upstream "servlet: introduce ServletServerBuilder.buildServlet()"
niloc132 Oct 21, 2024
06e63ec
Bump grpc vers, add inprocess dep for tests
niloc132 Oct 21, 2024
09ade64
Merge branch 'main' into grpc-history-replay
niloc132 Oct 28, 2024
c8af47c
Apply https://github.com/deephaven/deephaven-core/pull/6301
niloc132 Oct 28, 2024
57c8008
Bump to 1.65.1 to better match arrow 18
niloc132 Nov 1, 2024
cbf8ab2
Merge remote-tracking branch 'colin/grpc-history-replay' into vp_simp…
nbauernfeind Nov 6, 2024
85f604f
Version Upgrades; MavenLocal
nbauernfeind Nov 6, 2024
70a0207
Implement Simplified Viewport Table Updates in BMP/BT
nbauernfeind Nov 8, 2024
0089d62
Ryan's Synchronous Review
nbauernfeind Nov 9, 2024
485746d
Merge remote-tracking branch 'upstream/main' into vp_simplification
nbauernfeind Nov 9, 2024
ad8de73
Remove SNAPSHOT version and mavenLocal references
nbauernfeind Nov 11, 2024
02ce2ad
Fixes removed/added rows in most VP cases
nbauernfeind Nov 12, 2024
da23e2b
Bug fixes around viewport snapshot rowsRemoved and rowsAdded
nbauernfeind Nov 12, 2024
299f56e
Bugfix for correct growing VP logic
nbauernfeind Nov 12, 2024
9d6f389
remaining java side fixes
nbauernfeind Nov 13, 2024
fd5aced
Ryan's feedback on javaserver/client impls
nbauernfeind Nov 14, 2024
53b1eed
Inline Feedback from VC w/Ryan
nbauernfeind Nov 14, 2024
6e7fe94
Do not propagate modifies for any repainted rows
nbauernfeind Nov 14, 2024
d568eb7
Minor cleanup from personal review
nbauernfeind Nov 14, 2024
6653ca6
Ryan's feedback latest round.
nbauernfeind Nov 14, 2024
44cdf93
jsAPI mostly complete; looking for tree table issue
nbauernfeind Nov 15, 2024
d549d79
Fixes for jsapi and HierarchicalTable
nbauernfeind Nov 15, 2024
b4d5b69
Lazily compute rowset encoding
nbauernfeind Nov 15, 2024
6c12314
Fixup jsapi tests
nbauernfeind Nov 15, 2024
f9be6e5
Quick round feedback
nbauernfeind Nov 15, 2024
4252622
spotless
nbauernfeind Nov 15, 2024
2767def
Double checked locking fixes
nbauernfeind Nov 15, 2024
78c4cb7
Ryan's final review
nbauernfeind Nov 15, 2024
ea6f898
Clarify strategy on who owns RowSets passed into getSubView
nbauernfeind Nov 15, 2024
3eeb628
npe fix
nbauernfeind Nov 15, 2024
84a6100
Bugfix if HT is empty or viewport past end of table
nbauernfeind Nov 16, 2024
476ae65
Colin's feedback
nbauernfeind Nov 16, 2024
738cb11
Limit jsapi data change event to prev and curr table sizes
nbauernfeind Nov 16, 2024
38f320c
Merge branch 'vp_simplification' into barrage_types
nbauernfeind Nov 16, 2024
7a351a2
Merge compilation fixes
nbauernfeind Nov 16, 2024
58d34e2
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Nov 16, 2024
68f080b
Fix for #5258
nbauernfeind Nov 16, 2024
0f088c8
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Nov 18, 2024
ea513bb
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Nov 18, 2024
6526a9f
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Nov 21, 2024
66261b0
tmp some fixes
nbauernfeind Nov 21, 2024
bf9495c
tmp disable cpp test
nbauernfeind Nov 21, 2024
fe02980
broken map support
nbauernfeind Nov 25, 2024
c9e8fc6
fix: Ensure that rollup and tree snapshot tests succeed reliably (#6407)
rcaudy Nov 21, 2024
e26d6f1
fix: return type for IcebergCatalogAdapter::load_table in python (#6408)
malhotrashivam Nov 21, 2024
2ee3dca
fix: Close Jetty h2 streams with RST_STREAM and no error code (#6401)
niloc132 Nov 21, 2024
1deee97
fix: Apply auto-locking in time_window() (#6411)
jmao-denver Nov 21, 2024
c31c48a
ci: Add cpwright to CODEOWNERS for /py, protos, gwt, and function lib…
cpwright Nov 21, 2024
3b13fc5
chore: Update projects that use Arrow 18 to require Java 11 (#6417)
niloc132 Nov 22, 2024
2222fd9
Add sketch of CommandGetSqlInfo
devinrsmith Nov 22, 2024
6a9be96
checkpoint
nbauernfeind Nov 29, 2024
4ba36f0
Fix #6216
nbauernfeind Nov 29, 2024
65d596d
java client support for column as list feature
nbauernfeind Dec 2, 2024
efa5dee
finish getSqlInfo up to new schema
nbauernfeind Dec 2, 2024
00b66a7
was able to acquire all union child writers
nbauernfeind Dec 3, 2024
a219b84
impl most of union writer; need non-nullable support
nbauernfeind Dec 3, 2024
675e745
Can officially write sql info
nbauernfeind Dec 4, 2024
4eadb96
Dense Union Reader + fixedChunkLength fixes
nbauernfeind Dec 4, 2024
4ae05b8
remove stubs for type mapping
nbauernfeind Dec 4, 2024
be9f2df
Bug fixes
nbauernfeind Dec 4, 2024
c5000e7
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Dec 4, 2024
2dba609
More BugFixes
nbauernfeind Dec 5, 2024
9c3db73
fix go tests
nbauernfeind Dec 5, 2024
2ab1088
revert: RST_STREAM(cancel) fix for gRPC, this seems to be breaking JS…
niloc132 Nov 22, 2024
ae71435
Charles' Feedback
nbauernfeind Dec 16, 2024
0400086
More Feedback + Tests + BugFixes
nbauernfeind Dec 16, 2024
1e68d61
spotless + pull casting out of loops
nbauernfeind Dec 16, 2024
fe1eb5c
WebReaderFactory support for ListView and FixedSizeList
nbauernfeind Dec 17, 2024
8febaa0
Add a bunch of test and fixes
nbauernfeind Dec 30, 2024
b948edf
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Dec 30, 2024
08ca30a
spotless
nbauernfeind Dec 30, 2024
fca6d18
tests and fixes for remaining type mappings
nbauernfeind Jan 22, 2025
d7bc45a
Fix BarrageRoundTripTest due to Reinterpretation; to restart nightlies
nbauernfeind Jan 22, 2025
2ec6faa
ZDT tests pass
nbauernfeind Jan 24, 2025
3756c89
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Jan 24, 2025
da44dde
rm unused imports
nbauernfeind Jan 24, 2025
825d1e1
RTT tests:
nbauernfeind Jan 27, 2025
767e7a1
Interval/Errors/CustomBinary/Union/Head/Tail Tests
nbauernfeind Jan 30, 2025
93cd532
rm extra newline
nbauernfeind Jan 30, 2025
f40b628
feat(cpp-client): Honor Arrow TimeUnit when converting Timestamp and …
kosak Dec 6, 2024
0db9d19
generic union test + fixes
nbauernfeind Feb 4, 2025
fae471f
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Feb 4, 2025
60a23b9
update copyright headers
nbauernfeind Feb 4, 2025
d121063
Default mapping for Map and Union; fix TODOs
nbauernfeind Feb 4, 2025
34f1406
Most of hd/tl testing
nbauernfeind Feb 7, 2025
df7b92d
Fix the other not-working tests
nbauernfeind Feb 7, 2025
1eb6c4d
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Feb 7, 2025
bfdb17c
fix type propagation to client
nbauernfeind Feb 7, 2025
52a486d
actually fix #6114
nbauernfeind Feb 7, 2025
614d172
Merge remote-tracking branch 'kosak/kosak_time-units' into barrage_types
nbauernfeind Feb 7, 2025
a7a6361
W/R and cpp test fix
nbauernfeind Feb 7, 2025
af1e760
cpp tests don't run with this name
nbauernfeind Feb 7, 2025
48b5884
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Feb 8, 2025
36ce6ae
Reference arrow-java issue for List of Union
nbauernfeind Feb 8, 2025
4e3a1f6
revert bool object vector.. need to debug more
nbauernfeind Feb 10, 2025
d3c302b
2nd attempt at ObjectVector<Boolean> w2w transfer
nbauernfeind Feb 11, 2025
1904411
initial quick set of feedback
nbauernfeind Feb 11, 2025
bad569f
apply spotless
nbauernfeind Feb 11, 2025
85b7636
checkpoint charles' feedback
nbauernfeind Feb 18, 2025
336af7c
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Feb 18, 2025
21d91f8
fix go client test
nbauernfeind Feb 18, 2025
2e791ae
Fix a few more tests and real bugs
nbauernfeind Feb 20, 2025
e4e3516
Fix majority of remaining issues..
nbauernfeind Feb 25, 2025
5d017b8
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Feb 25, 2025
9397ca9
fix gwt compile
nbauernfeind Feb 25, 2025
5443a4f
single element header reader test
nbauernfeind Feb 27, 2025
89cc72f
Merge remote-tracking branch 'upstream/main' into barrage_types
nbauernfeind Feb 27, 2025
88324ef
two review comments from charles
nbauernfeind Feb 28, 2025
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 @@ -168,7 +168,7 @@ public int available() throws IOException {
* @formatter:on
*/
protected boolean sendValidityBuffer() {
return fieldNullable && nullCount() != 0;
return nullCount() != 0;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected void writePayload(
}

final BigInteger truncatedValue;
boolean isNegative = value.compareTo(BigDecimal.ZERO) < 0;
boolean isNegative = value.signum() < 0;
if (isNegative) {
// negative values are sign extended to match truncationMask's byte length; operate on abs-value
truncatedValue = value.unscaledValue().negate().and(truncationMask).negate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public interface ChunkWriter<SOURCE_CHUNK_TYPE extends Chunk<Values>> {
/**
* Creator of {@link ChunkWriter} instances.
* <p>
* This API may not be stable, while the JS API's usages of it are implemented.
* TODO: https://github.com/deephaven/deephaven-core/issues/5927 This API may not be stable, while the JS API's
* usages of it are implemented.
*/
interface Factory {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ ChunkReader<? extends WritableChunk<Values>> make(
}

// allow subclasses to modify this as they wish
protected final Map<ArrowType.ArrowTypeID, Map<Class<?>, ChunkReaderFactory>> registeredFactories =
private final Map<ArrowType.ArrowTypeID, Map<Class<?>, ChunkReaderFactory>> registeredFactories =
new HashMap<>();

protected DefaultChunkReaderFactory() {
Expand Down Expand Up @@ -282,6 +282,8 @@ public <T extends WritableChunk<Values>> ChunkReader<T> newReaderPojo(
}

if (typeId == ArrowType.ArrowTypeID.Map) {
// TODO: https://github.com/deephaven/deephaven-core/issues/6637
// should we allow the user to supply the collector?
final Field structField = field.getChildren().get(0);
final BarrageTypeInfo<Field> keyTypeInfo = BarrageUtil.getDefaultType(structField.getChildren().get(0));
final BarrageTypeInfo<Field> valueTypeInfo = BarrageUtil.getDefaultType(structField.getChildren().get(1));
Expand All @@ -293,9 +295,10 @@ public <T extends WritableChunk<Values>> ChunkReader<T> newReaderPojo(
return (ChunkReader<T>) new MapChunkReader<>(keyReader, valueReader);
}

// TODO: if (typeId == ArrowType.ArrowTypeID.Struct) {
// expose transformer API of Map<String, Chunk<Values>> -> T
// maybe defaults to Map<String, Object>
// TODO: struct support - https://github.com/deephaven/deephaven-core/issues/6636
// expose @FunctionInterface of Map<String, Chunk<Values>> -> T
// maybe defaults to Map<String, Object>?
// if (typeId == ArrowType.ArrowTypeID.Struct) {

if (typeId == ArrowType.ArrowTypeID.Union) {
final ArrowType.Union unionType = (ArrowType.Union) field.getType();
Expand Down Expand Up @@ -716,7 +719,7 @@ private static ChunkReader<WritableObjectChunk<BigInteger, Values>> fpToBigInteg
final short value = src.get(ii);
dst.set(dstOffset + ii, value == QueryConstants.NULL_SHORT
? null
: BigInteger.valueOf((long) Float16.toFloat(value)));
: BigDecimal.valueOf(Float16.toFloat(value)).toBigInteger());
}
});

Expand All @@ -726,7 +729,7 @@ private static ChunkReader<WritableObjectChunk<BigInteger, Values>> fpToBigInteg
final float value = src.get(ii);
dst.set(dstOffset + ii, value == QueryConstants.NULL_FLOAT
? null
: BigInteger.valueOf((long) value));
: BigDecimal.valueOf(value).toBigInteger());
}
});
case DOUBLE:
Expand All @@ -735,7 +738,7 @@ private static ChunkReader<WritableObjectChunk<BigInteger, Values>> fpToBigInteg
final double value = src.get(ii);
dst.set(dstOffset + ii, value == QueryConstants.NULL_DOUBLE
? null
: BigInteger.valueOf((long) value));
: BigDecimal.valueOf(value).toBigInteger());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,6 @@ public <T extends Chunk<Values>> ChunkWriter<T> newWriterPojo(
if (useVectorKernels) {
Class<?> componentType =
VectorExpansionKernel.getComponentType(typeInfo.type(), typeInfo.componentType());
if (componentType == Boolean.class) {
// Boolean's are stored in ObjectVector and should use ObjectVectorExpansionKernel
componentType = Object.class;
}
componentTypeInfo = new BarrageTypeInfo<>(
componentType,
componentType.getComponentType(),
Expand Down Expand Up @@ -298,7 +294,6 @@ public <T extends Chunk<Values>> ChunkWriter<T> newWriterPojo(
}

if (typeId == ArrowType.ArrowTypeID.Map) {
// TODO: should we allow the user to supply the collector?
final Field structField = field.getChildren().get(0);
final BarrageTypeInfo<Field> keyTypeInfo = BarrageUtil.getDefaultType(structField.getChildren().get(0));
final BarrageTypeInfo<Field> valueTypeInfo = BarrageUtil.getDefaultType(structField.getChildren().get(1));
Expand All @@ -311,8 +306,9 @@ public <T extends Chunk<Values>> ChunkWriter<T> newWriterPojo(
keyWriter, valueWriter, keyTypeInfo.chunkType(), valueTypeInfo.chunkType(), field.isNullable());
}

// TODO: if (typeId == ArrowType.ArrowTypeID.Struct) {
// expose transformer API of Map<String, Chunk<Values>> -> T
// TODO: struct support - https://github.com/deephaven/deephaven-core/issues/6636
// expose @FunctionalInterface of Map<String, Chunk<Values>> -> T?
// if (typeId == ArrowType.ArrowTypeID.Struct) {

if (typeId == ArrowType.ArrowTypeID.Union) {
final ArrowType.Union unionType = (ArrowType.Union) field.getType();
Expand Down Expand Up @@ -422,8 +418,9 @@ private static ChunkWriter<Chunk<Values>> timestampFromZonedDateTime(
chunk.set(ii, longChunk.isNull(ii) ? value : value / factor);
}
} else {
final ObjectChunk<ZonedDateTime, Values> zdtChunk = source.asObjectChunk();
for (int ii = 0; ii < source.size(); ++ii) {
final ZonedDateTime value = source.<ZonedDateTime>asObjectChunk().get(ii);
final ZonedDateTime value = zdtChunk.get(ii);
chunk.set(ii, value == null
? QueryConstants.NULL_LONG
: DateTimeUtils.epochNanos(value) / factor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ <A extends Any> WritableChunk<A> expand(
* <li>If {@code offsets} is {@code null}, each row is assumed to have a fixed size defined by
* {@code sizePerElement}.</li>
* <li>If {@code lengths} is {@code null}, each row's size is determined by differences between adjacent elements in
* {@code offsets}.</li>
* {@code offsets}. An element's length is determined by subtracting its offset from the next offset, therefore
* offsets must contain one more element than the number of elements.</li>
* <li>If both {@code offsets} and {@code lengths} are provided, {@code lengths} determines the row sizes.</li>
* </ul>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void visitBuffers(final BufferListener listener) {
}
listener.noteLogicalBuffer(padBufferSize(numOffsetBytes));

// a validity buffer for the inner struct ??
// a validity buffer for the inner struct; (the buffer is odd since each entry needs to be valid)
listener.noteLogicalBuffer(0);

// payload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ public <A extends Any> WritableChunk<A> expand(
final ObjectChunk<boolean[], A> typedSource = source.asObjectChunk();

long totalSize = 0;
for (int ii = 0; ii < typedSource.size(); ++ii) {
int rowLen;
if (fixedSizeLength != 0) {
rowLen = Math.abs(fixedSizeLength);
} else {
if (fixedSizeLength != 0) {
totalSize = typedSource.size() * (long) fixedSizeLength;
} else {
for (int ii = 0; ii < typedSource.size(); ++ii) {
final boolean[] row = typedSource.get(ii);
rowLen = row == null ? 0 : row.length;
int rowLen = row == null ? 0 : row.length;
totalSize += rowLen;
}
totalSize += rowLen;
}
final WritableByteChunk<A> result = WritableByteChunk.makeWritableChunk(
LongSizedDataStructure.intSize(DEBUG_NAME, totalSize));
Expand All @@ -64,18 +63,12 @@ public <A extends Any> WritableChunk<A> expand(
}
int written = 0;
if (row != null) {
int offset = 0;
if (fixedSizeLength != 0) {
// limit length to fixedSizeLength
written = Math.min(row.length, Math.abs(fixedSizeLength));
if (fixedSizeLength < 0 && written < row.length) {
// read from the end of the array when fixedSizeLength is negative
offset = row.length - written;
}
written = Math.min(row.length, fixedSizeLength);
} else {
written = row.length;
}

// copy the row into the result
for (int j = 0; j < written; ++j) {
final byte value = row[j] ? BooleanUtils.TRUE_BOOLEAN_AS_BYTE : BooleanUtils.FALSE_BOOLEAN_AS_BYTE;
Expand All @@ -84,7 +77,7 @@ public <A extends Any> WritableChunk<A> expand(
}
if (fixedSizeLength != 0) {
final int toNull = LongSizedDataStructure.intSize(
DEBUG_NAME, Math.max(0, Math.abs(fixedSizeLength) - written));
DEBUG_NAME, Math.max(0, fixedSizeLength - written));
if (toNull > 0) {
// fill the rest of the row with nulls
result.fillWithNullValue(lenWritten + written, toNull);
Expand Down Expand Up @@ -135,9 +128,6 @@ public <A extends Any> WritableObjectChunk<boolean[], A> contract(
final int rowLen = computeSize(ii, sizePerElement, offsets, lengths);
if (rowLen == 0) {
result.set(outOffset + ii, ZERO_LEN_ARRAY);
} else if (rowLen < 0) {
// note that this may occur when data sent from a native arrow client is null
result.set(outOffset + ii, null);
} else {
final boolean[] row = new boolean[rowLen];
for (int j = 0; j < rowLen; ++j) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ public <A extends Any> WritableChunk<A> expand(
final ObjectChunk<Boolean[], A> typedSource = source.asObjectChunk();

long totalSize = 0;
for (int ii = 0; ii < typedSource.size(); ++ii) {
int rowLen;
if (fixedSizeLength > 0) {
rowLen = Math.abs(fixedSizeLength);
} else {
if (fixedSizeLength != 0) {
totalSize = source.size() * (long) fixedSizeLength;
} else {
for (int ii = 0; ii < source.size(); ++ii) {
final Boolean[] row = typedSource.get(ii);
rowLen = row == null ? 0 : row.length;
final int rowLen = row == null ? 0 : row.length;
totalSize += rowLen;
}
totalSize += rowLen;
}
final WritableByteChunk<A> result = WritableByteChunk.makeWritableChunk(
LongSizedDataStructure.intSize(DEBUG_NAME, totalSize));
Expand All @@ -64,27 +63,22 @@ public <A extends Any> WritableChunk<A> expand(
}
int written = 0;
if (row != null) {
int offset = 0;
if (fixedSizeLength != 0) {
// limit length to fixedSizeLength
written = Math.min(row.length, Math.abs(fixedSizeLength));
if (fixedSizeLength < 0 && written < row.length) {
// read from the end of the array when fixedSizeLength is negative
offset = row.length - written;
}
written = Math.min(row.length, fixedSizeLength);
} else {
written = row.length;
}

// copy the row into the result
for (int j = 0; j < written; ++j) {
final byte value = BooleanUtils.booleanAsByte(row[offset + j]);
final byte value = BooleanUtils.booleanAsByte(row[j]);
result.set(lenWritten + j, value);
}
}
if (fixedSizeLength != 0) {
final int toNull = LongSizedDataStructure.intSize(
DEBUG_NAME, Math.max(0, Math.abs(fixedSizeLength) - written));
DEBUG_NAME, Math.max(0, fixedSizeLength - written));
if (toNull > 0) {
// fill the rest of the row with nulls
result.fillWithNullValue(lenWritten + written, toNull);
Expand Down Expand Up @@ -135,9 +129,6 @@ public <A extends Any> WritableObjectChunk<Boolean[], A> contract(
final int rowLen = computeSize(ii, sizePerElement, offsets, lengths);
if (rowLen == 0) {
result.set(outOffset + ii, ZERO_LEN_ARRAY);
} else if (rowLen < 0) {
// note that this may occur when data sent from a native arrow client is null
result.set(outOffset + ii, null);
} else {
final Boolean[] row = new Boolean[rowLen];
int numSent = Math.min(rowLen, typedSource.size() - offset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ public <A extends Any> WritableChunk<A> expand(
}

long totalSize = 0;
for (int ii = 0; ii < source.size(); ++ii) {
final int rowLen;
if (fixedSizeLength != 0) {
rowLen = Math.abs(fixedSizeLength);
} else {
if (fixedSizeLength != 0) {
totalSize = source.size() * (long) fixedSizeLength;
} else {
for (int ii = 0; ii < source.size(); ++ii) {
final byte[] row = source.get(ii);
rowLen = row == null ? 0 : row.length;
final int rowLen = row == null ? 0 : row.length;
totalSize += rowLen;
}
totalSize += rowLen;
}
final WritableByteChunk<A> result = WritableByteChunk.makeWritableChunk(
LongSizedDataStructure.intSize(DEBUG_NAME, totalSize));
Expand All @@ -65,23 +64,18 @@ public <A extends Any> WritableChunk<A> expand(
}
int written = 0;
if (row != null) {
int offset = 0;
if (fixedSizeLength != 0) {
// limit length to fixedSizeLength
written = Math.min(row.length, Math.abs(fixedSizeLength));
if (fixedSizeLength < 0 && written < row.length) {
// read from the end of the array when fixedSizeLength is negative
offset = row.length - written;
}
written = Math.min(row.length, fixedSizeLength);
} else {
written = row.length;
}
// copy the row into the result
result.copyFromArray(row, offset, lenWritten, written);
result.copyFromArray(row, 0, lenWritten, written);
}
if (fixedSizeLength != 0) {
final int toNull = LongSizedDataStructure.intSize(
DEBUG_NAME, Math.max(0, Math.abs(fixedSizeLength) - written));
DEBUG_NAME, Math.max(0, fixedSizeLength - written));
if (toNull > 0) {
// fill the rest of the row with nulls
result.fillWithNullValue(lenWritten + written, toNull);
Expand Down Expand Up @@ -135,9 +129,6 @@ public <A extends Any> WritableObjectChunk<byte[], A> contract(
final int rowLen = computeSize(ii, sizePerElement, offsets, lengths);
if (rowLen == 0) {
result.set(outOffset + ii, ZERO_LEN_ARRAY);
} else if (rowLen < 0) {
// note that this may occur when data sent from a native arrow client is null
result.set(outOffset + ii, null);
} else {
final byte[] row = new byte[rowLen];
typedSource.copyToArray(offset, row, 0, rowLen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ public <A extends Any> WritableChunk<A> expand(
}

long totalSize = 0;
for (int ii = 0; ii < source.size(); ++ii) {
final int rowLen;
if (fixedSizeLength != 0) {
rowLen = Math.abs(fixedSizeLength);
} else {
if (fixedSizeLength != 0) {
totalSize = source.size() * (long) fixedSizeLength;
} else {
for (int ii = 0; ii < source.size(); ++ii) {
final char[] row = source.get(ii);
rowLen = row == null ? 0 : row.length;
final int rowLen = row == null ? 0 : row.length;
totalSize += rowLen;
}
totalSize += rowLen;
}
final WritableCharChunk<A> result = WritableCharChunk.makeWritableChunk(
LongSizedDataStructure.intSize(DEBUG_NAME, totalSize));
Expand All @@ -61,23 +60,18 @@ public <A extends Any> WritableChunk<A> expand(
}
int written = 0;
if (row != null) {
int offset = 0;
if (fixedSizeLength != 0) {
// limit length to fixedSizeLength
written = Math.min(row.length, Math.abs(fixedSizeLength));
if (fixedSizeLength < 0 && written < row.length) {
// read from the end of the array when fixedSizeLength is negative
offset = row.length - written;
}
written = Math.min(row.length, fixedSizeLength);
} else {
written = row.length;
}
// copy the row into the result
result.copyFromArray(row, offset, lenWritten, written);
result.copyFromArray(row, 0, lenWritten, written);
}
if (fixedSizeLength != 0) {
final int toNull = LongSizedDataStructure.intSize(
DEBUG_NAME, Math.max(0, Math.abs(fixedSizeLength) - written));
DEBUG_NAME, Math.max(0, fixedSizeLength - written));
if (toNull > 0) {
// fill the rest of the row with nulls
result.fillWithNullValue(lenWritten + written, toNull);
Expand Down Expand Up @@ -131,9 +125,6 @@ public <A extends Any> WritableObjectChunk<char[], A> contract(
final int rowLen = computeSize(ii, sizePerElement, offsets, lengths);
if (rowLen == 0) {
result.set(outOffset + ii, ZERO_LEN_ARRAY);
} else if (rowLen < 0) {
// note that this may occur when data sent from a native arrow client is null
result.set(outOffset + ii, null);
} else {
final char[] row = new char[rowLen];
typedSource.copyToArray(offset, row, 0, rowLen);
Expand Down
Loading
Loading