-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-1238: [Java] Adding Decimal type JSON read and write support #994
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
Changes from all commits
f4560d9
da11b4f
c5e8fba
10cac9c
31b7ec1
28c1e3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,10 +26,12 @@ | |
| import java.util.Set; | ||
|
|
||
| import com.google.common.collect.ImmutableList; | ||
| import io.netty.buffer.ArrowBuf; | ||
| import org.apache.arrow.vector.BitVector; | ||
| import org.apache.arrow.vector.BufferBacked; | ||
| import org.apache.arrow.vector.DateDayVector; | ||
| import org.apache.arrow.vector.DateMilliVector; | ||
| import org.apache.arrow.vector.DecimalVector; | ||
| import org.apache.arrow.vector.FieldVector; | ||
| import org.apache.arrow.vector.TimeMicroVector; | ||
| import org.apache.arrow.vector.TimeMilliVector; | ||
|
|
@@ -54,6 +56,7 @@ | |
| import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; | ||
| import com.fasterxml.jackson.core.util.DefaultPrettyPrinter.NopIndenter; | ||
| import com.fasterxml.jackson.databind.MappingJsonFactory; | ||
| import org.apache.arrow.vector.util.DecimalUtility; | ||
| import org.apache.arrow.vector.util.DictionaryUtility; | ||
| import org.apache.commons.codec.binary.Hex; | ||
|
|
||
|
|
@@ -233,9 +236,16 @@ private void writeValueToGenerator(ValueVector valueVector, int i) throws IOExce | |
| case BIT: | ||
| generator.writeNumber(((BitVector) valueVector).getAccessor().get(i)); | ||
| break; | ||
| case VARBINARY: | ||
| String hexString = Hex.encodeHexString(((VarBinaryVector) valueVector).getAccessor().get(i)); | ||
| generator.writeObject(hexString); | ||
| case VARBINARY: { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we remove the brackets?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's there to limit the scope of the variables declared in the case block to that case only. Since now there are 2 blocks decoding hex values, just to prevent using the wrong variables.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM |
||
| String hexString = Hex.encodeHexString(((VarBinaryVector) valueVector).getAccessor().get(i)); | ||
| generator.writeString(hexString); | ||
| } | ||
| break; | ||
| case DECIMAL: { | ||
| ArrowBuf bytebuf = valueVector.getDataBuffer(); | ||
| String hexString = Hex.encodeHexString(DecimalUtility.getByteArrayFromArrowBuf(bytebuf, i)); | ||
| generator.writeString(hexString); | ||
| } | ||
| break; | ||
| default: | ||
| // TODO: each type | ||
|
|
||
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.
Why this?
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.
Most of the vectors do not use
setSafeso reading beyond the default capacity would cause problems. Maybe for cases where the majority of values are null this is overdoing it, but I think that is less common.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.
LGTM