Github user myui commented on a diff in the pull request:
https://github.com/apache/incubator-hivemall/pull/87#discussion_r124191703
--- Diff: core/src/main/java/hivemall/model/FeatureValue.java ---
@@ -74,6 +83,16 @@ public void setValue(double value) {
this.value = value;
}
+ public void writeTo(@Nonnull final ByteBuffer dst) {
+ NIOUtils.putString(getFeatureAsString(), dst);
+ dst.putDouble(value);
+ }
+
+ public void readFrom(@Nonnull final ByteBuffer src) {
+ this.feature = new Text(NIOUtils.getString(src));
--- End diff --
No need to wrap `feature` in Text.
`this.feature = NIOUtils.getString(src);`
Text holds every strings in UTF-8.
UTF8 (1-4 bytes) => UTF-16 (2 bytes) `getChar` => UTF-8 will cause invalid
character conversions.
Unfortunately, `hadoop.io.Text` cannot set internal bytes without
conversion. `hivemall.utils.hadoop.Text2` do it using reflection though.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---