keith-turner commented on a change in pull request #875: fixes #830
URL: https://github.com/apache/incubator-fluo/pull/875#discussion_r123603926
 
 

 ##########
 File path: 
modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ByteArrayUtil.java
 ##########
 @@ -98,21 +96,59 @@ public static long decodeLong(byte[] ba) {
    * @param listOfBytes Bytes objects to concatenate
    * @return Bytes
    */
-  public static final byte[] concat(Bytes... listOfBytes) {
-    try {
-      // TODO calculate exact array size needed
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      DataOutputStream dos = new DataOutputStream(baos);
-
-      for (Bytes b : listOfBytes) {
-        WritableUtils.writeVInt(dos, b.length());
-        b.writeTo(dos);
-      }
+  public static byte[] concat(Bytes... listOfBytes) {
+    int offset = 0;
+    int counter = 0;
 
-      dos.close();
-      return baos.toByteArray();
-    } catch (IOException e) {
-      throw new RuntimeException(e);
+    for (Bytes b : listOfBytes) {
+      counter += b.length() + 1;
 
 Review comment:
   Sometimes the variable lenght int will take more than one byte,  so can't 
just add 1.  I think another method that calculates the expected length of the 
vint could be called here.  This method would be a simpler form of `writeVint` 
that basically returns the number of times `writeVint` would increment offset 
in its implementation.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to