first break off of the hydrate function

This commit is contained in:
Vincent Batts 2012-10-12 12:29:06 -04:00
parent eb4a4a7bdd
commit 2a9511cbe5
2 changed files with 22 additions and 10 deletions

View file

@ -16,6 +16,9 @@
package com.redhat.trie;
public class PathTree {
private HuffNode dict;
private PathNode tree;
public PathTree() {
}
}

View file

@ -477,6 +477,23 @@ public class Util {
return parent;
}
/* fix breakoff of hydrateContentPackage */
private List<String> byteArrayToStrings(byte[] ba) {
List<String> strings = new ArrayList<String>();
String str = "";
for (byte b : ba) {
if (b == '\0') {
strings.add(str);
str = "";
} else {
str += (char) b;
}
}
return strings;
}
/*
* FIXME - break this apart, so that the hydrated payload
* can be structure to more quickly search, and use less memory
@ -493,17 +510,9 @@ public class Util {
ios.finish();
long read = i.getBytesRead();
String name = "";
int weight = 1;
for (byte b : baos.toByteArray()) {
if (b == '\0') {
pathDictionary.add(new HuffNode(getHuffNodeContext(),
name, weight++));
name = "";
}
else {
name += (char) b;
}
for (String name : byteArrayToStrings(baos.toByteArray())) {
pathDictionary.add(new HuffNode(getHuffNodeContext(), name, weight++));
}
pathDictionary.add(new HuffNode(HuffNode.END_NODE, weight));
List<HuffNode> triePathDictionary = new ArrayList<HuffNode>();