From bcf6b61125a7b6770434b6d5c00a2f95413b2d89 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Fri, 5 Oct 2012 08:50:23 -0400 Subject: [PATCH] adding the byteProcess() function --- src/main/java/com/redhat/trie/Util.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/redhat/trie/Util.java b/src/main/java/com/redhat/trie/Util.java index 57ff054..5e0615c 100644 --- a/src/main/java/com/redhat/trie/Util.java +++ b/src/main/java/com/redhat/trie/Util.java @@ -441,6 +441,20 @@ public class Util { return nodesList.get(0); } + private byte[] byteProcess(List entries) + throws IOException, UnsupportedEncodingException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DeflaterOutputStream dos = new DeflaterOutputStream(baos, + new Deflater(Deflater.BEST_COMPRESSION)); + for (String segment : entries) { + dos.write(segment.getBytes("UTF-8")); + dos.write("\0".getBytes("UTF-8")); + } + dos.finish(); + dos.close(); + return baos.toByteArray(); + } + private int findSmallest(int exclude, List nodes) { int smallest = -1; for (int index = 0; index < nodes.size(); index++) {