dlyubimov / ecoadapters Goto Github PK
View Code? Open in Web Editor NEWprotobuf adapters
protobuf adapters
Thanks a lot for making ProtoSerD, it rocks !
Some of my hive jobs (reading protos via ProtoSerDe) run much slower than expected, as they had raw bytes field in it. I tracked down performance issues and have fix, below. Is there way to incorporate it back to the master branch. I confirmed this resulted in 10x performance boost in case where raw byte fields are ~1kb. I tested compatibility of output of old string output and new, and they are same.
PS: Below is the fix diff
commit 3fcaca69b8fa897f57b9f1bf7277456d2d422a40
Author: Nemanja Spasojevic <[email protected]>
Date: Tue Oct 30 13:08:28 2012 -0700
Fix degraded performance of ProtoSerDe when dealing with BYTES fields.
diff --git a/ecoadapters/src/main/java/com/inadco/ecoadapters/hive/ProtoSerDe.java b/ecoadapters/src/main/java/com/inadco/ecoadapters/hive/ProtoSerDe.java
index 918e630..69740bc 100644
--- a/ecoadapters/src/main/java/com/inadco/ecoadapters/hive/ProtoSerDe.java
+++ b/ecoadapters/src/main/java/com/inadco/ecoadapters/hive/ProtoSerDe.java
@@ -230,8 +230,8 @@ public class ProtoSerDe implements SerDe {
return protoMsg2Hive(msgField, fd.getMessageType());
case BYTES:
byte[] val = ((ByteString) src).toByteArray();
- // we convert to string using %X formatting
- return String.format("%X", new BigInteger(1, val));
+ // we convert to string using %X formatting
+ return getHexString(val);
case BOOL:
case DOUBLE:
@@ -275,4 +275,12 @@ public class ProtoSerDe implements SerDe {
}
+ private static String getHexString(byte[] b) {
+ StringBuilder result = new StringBuilder();
+ for (int i = 0; i < b.length; i++) {
+ result.append(Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1));
+ }
+ return result.toString().toUpperCase();
+ }
+
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.