-
Notifications
You must be signed in to change notification settings - Fork 80
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
Barrage/web UI support for BigDecimal and BigInteger. #1627
Merged
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9bca2fc
Adding decimal support for parquet writing; fixing nested avro; start…
jcferretti 283c5d1
Remove mistakenly added file. build.gradle.compactstringexperiment
jcferretti 6e0222a
Merge remote-tracking branch 'origin/main' into cfs-mdemo-0
jcferretti 4e4b493
Fix for BigDecimal and BigInteger to the web UI.
jcferretti 01cbe67
More comments.
jcferretti b976f03
Merge branch 'main' into cfs-mdemo-0
jcferretti 7647350
Renamed DatetimeAsLongCS to DateTime...
jcferretti 1014eb8
Added a comment to explain computedCache.
jcferretti c43b71c
Slight improvement to BigDecimal codec detection.
jcferretti 360b067
Followup to review comments.
jcferretti 99bf225
Followup to review comments.
jcferretti a834086
Fixed int32 and int64 based parquet decimal reading.
jcferretti 6775ab4
Spotlessfy.
jcferretti a8ff693
Followup to review comments.
jcferretti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...uet/table/src/main/java/io/deephaven/parquet/table/pagestore/topage/ToBigDecimalBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.deephaven.parquet.table.pagestore.topage; | ||
|
||
import io.deephaven.chunk.ChunkType; | ||
import io.deephaven.chunk.attributes.Any; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.math.BigDecimal; | ||
|
||
public abstract class ToBigDecimalBase<ATTR extends Any> implements ToPage<ATTR, BigDecimal[]> { | ||
protected final byte scale; | ||
|
||
protected ToBigDecimalBase(@NotNull final Class<?> nativeType, final int precision, final int scale) { | ||
if (!BigDecimal.class.equals(nativeType)) { | ||
throw new IllegalArgumentException( | ||
"The native type for a BigDecimal column is " + nativeType.getCanonicalName()); | ||
} | ||
|
||
this.scale = (byte) scale; | ||
if (((int) this.scale) != scale) { | ||
throw new IllegalArgumentException( | ||
"precision=" + precision + " and scale=" + scale + " can't be represented"); | ||
} | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Class<?> getNativeType() { | ||
return BigDecimal.class; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public final ChunkType getChunkType() { | ||
return ChunkType.Object; | ||
} | ||
} |
40 changes: 17 additions & 23 deletions
40
...le/src/main/java/io/deephaven/parquet/table/pagestore/topage/ToBigDecimalFromIntPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,41 @@ | ||
package io.deephaven.parquet.table.pagestore.topage; | ||
|
||
import io.deephaven.chunk.attributes.Any; | ||
import io.deephaven.vector.ObjectVector; | ||
import io.deephaven.vector.ObjectVectorDirect; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
|
||
public class ToBigDecimalFromIntPage<ATTR extends Any> extends ToIntPage<ATTR> { | ||
private final byte scale; | ||
import static io.deephaven.util.QueryConstants.NULL_INT_BOXED; | ||
|
||
public class ToBigDecimalFromIntPage<ATTR extends Any> extends ToBigDecimalBase<ATTR> { | ||
|
||
public static <ATTR extends Any> ToPage<ATTR, BigDecimal[]> create( | ||
@NotNull final Class<?> nativeType, | ||
final int precision, | ||
final int scale | ||
) { | ||
if (!BigDecimal.class.equals(nativeType)) { | ||
throw new IllegalArgumentException( | ||
"The native type for a BigDecimal column is " + nativeType.getCanonicalName()); | ||
} | ||
|
||
return new ToBigDecimalFromIntPage(precision, scale); | ||
return new ToBigDecimalFromIntPage(nativeType, precision, scale); | ||
} | ||
|
||
protected ToBigDecimalFromIntPage(final int precision, final int scale) { | ||
this.scale = (byte) scale; | ||
if (((int) this.scale) != scale) { | ||
throw new IllegalArgumentException("precision=" + precision + " and scale=" + scale + " can't be represented"); | ||
} | ||
protected ToBigDecimalFromIntPage(@NotNull final Class<?> nativeType, final int precision, final int scale) { | ||
super(nativeType, precision, scale); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public ObjectVector<BigDecimal> makeVector(final int[] result) { | ||
final BigDecimal[] to = new BigDecimal[result.length]; | ||
for (int i = 0; i < result.length; ++i) { | ||
to[i] = BigDecimal.valueOf(result[i], scale); | ||
public BigDecimal[] convertResult(@NotNull final Object result) { | ||
final int[] in = (int[]) result; | ||
final int resultLength = in.length; | ||
final BigDecimal[] out = new BigDecimal[resultLength]; | ||
for (int ri = 0; ri < resultLength; ++ri) { | ||
out[ri] = new BigDecimal(BigInteger.valueOf(in[ri]), scale); | ||
jcferretti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return new ObjectVectorDirect<>(to); | ||
return out; | ||
} | ||
|
||
@Override | ||
public int[] convertResult(@NotNull final Object result) { | ||
return (int[]) result; | ||
@NotNull | ||
public final Object nullValue() { | ||
return NULL_INT_BOXED; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test seems incomplete. Shouldn't we read the data back in and compare it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally yes, but this test something that wasn't being tested before, meaning, that writing the file doesn't blow up.
Ok, let's test more...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better. Might be better still with
TstUtils.assertTableEquals(table, table2)
if that's easy to do from Python.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried, but is not easy to do from python:
My guess is we don't export the test packages when we build the docker image (which makes sense).
I used TableTools.diff instead, which I think should give a similar value.