first break off of the hydrate function
This commit is contained in:
parent
eb4a4a7bdd
commit
2a9511cbe5
2 changed files with 22 additions and 10 deletions
|
@ -16,6 +16,9 @@
|
||||||
package com.redhat.trie;
|
package com.redhat.trie;
|
||||||
|
|
||||||
public class PathTree {
|
public class PathTree {
|
||||||
|
private HuffNode dict;
|
||||||
|
private PathNode tree;
|
||||||
|
|
||||||
public PathTree() {
|
public PathTree() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -476,6 +476,23 @@ public class Util {
|
||||||
null, left.getWeight() + right.getWeight(), left, right);
|
null, left.getWeight() + right.getWeight(), left, right);
|
||||||
return parent;
|
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
|
* FIXME - break this apart, so that the hydrated payload
|
||||||
|
@ -493,17 +510,9 @@ public class Util {
|
||||||
ios.finish();
|
ios.finish();
|
||||||
long read = i.getBytesRead();
|
long read = i.getBytesRead();
|
||||||
|
|
||||||
String name = "";
|
|
||||||
int weight = 1;
|
int weight = 1;
|
||||||
for (byte b : baos.toByteArray()) {
|
for (String name : byteArrayToStrings(baos.toByteArray())) {
|
||||||
if (b == '\0') {
|
pathDictionary.add(new HuffNode(getHuffNodeContext(), name, weight++));
|
||||||
pathDictionary.add(new HuffNode(getHuffNodeContext(),
|
|
||||||
name, weight++));
|
|
||||||
name = "";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
name += (char) b;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pathDictionary.add(new HuffNode(HuffNode.END_NODE, weight));
|
pathDictionary.add(new HuffNode(HuffNode.END_NODE, weight));
|
||||||
List<HuffNode> triePathDictionary = new ArrayList<HuffNode>();
|
List<HuffNode> triePathDictionary = new ArrayList<HuffNode>();
|
||||||
|
|
Loading…
Reference in a new issue