Skip to content

Commit

Permalink
Fix tests that peek into the guts of NewChunk
Browse files Browse the repository at this point in the history
Fix sparse/dense bitvector path
  • Loading branch information
cliffclick committed Nov 13, 2013
1 parent 5821fe6 commit 60af390
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion prj.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'(jde-run-option-debug nil)
'(jde-run-option-vm-args nil)
'(jde-compile-option-directory "./target/classes")
'(jde-run-option-application-args (quote ("-beta" "-mainClass" "org.junit.runner.JUnitCore" "water.fvec.CBSChunkTest" "water.fvec.ParserTest2")))
'(jde-run-option-application-args (quote ("-beta" "-mainClass" "org.junit.runner.JUnitCore" "water.fvec.NewVectorTest" "water.fvec.CBSChunkTest" "water.fvec.ParserTest2")))
'(jde-debugger (quote ("JDEbug")))
'(jde-compile-option-source (quote ("1.6")))
'(jde-compile-option-classpath (quote ("./target/classes" "./lib/javassist.jar" "./lib/hadoop/cdh4/hadoop-common.jar" "./lib/hadoop/cdh4/hadoop-auth.jar" "./lib/hadoop/cdh4/slf4j-api-1.6.1.jar" "./lib/hadoop/cdh4/slf4j-nop-1.6.1.jar" "./lib/hadoop/cdh4/hadoop-hdfs.jar" "./lib/hadoop/cdh4/protobuf-java-2.4.0a.jar" "./lib/apache/commons-codec-1.4.jar" "./lib/apache/commons-configuration-1.6.jar" "./lib/apache/commons-lang-2.4.jar" "./lib/apache/commons-logging-1.1.1.jar" "./lib/apache/httpclient-4.1.1.jar" "./lib/apache/httpcore-4.1.jar" "./lib/junit/junit-4.11.jar" "./lib/apache/guava-12.0.1.jar" "./lib/gson/gson-2.2.2.jar" "./lib/poi/poi-3.8-20120326.jar" "./lib/poi/poi-ooxml-3.8-20120326.jar" "./lib/poi/poi-ooxml-schemas-3.8-20120326.jar" "./lib/poi/dom4j-1.6.1.jar" "./lib/Jama/Jama.jar" "./lib/s3/aws-java-sdk-1.3.27.jar" "./lib/log4j/log4j-1.2.15.jar")))
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/water/fvec/NewChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ private Chunk chunkD() {
// Compute compressed boolean buffer
private byte[] bufB(int bpv) {
assert bpv == 1 || bpv == 2 : "Only bit vectors with/without NA are supported";
int clen = CBSChunk.OFF + CBSChunk.clen(_len2, bpv);
final int off = CBSChunk.OFF;
int clen = off + CBSChunk.clen(_len2, bpv);
byte bs[] = new byte[clen];
// Save the gap = number of unfilled bits and bpv value
bs[0] = (byte) (((_len2*bpv)&7)==0 ? 0 : (8-((_len2*bpv)&7)));
Expand All @@ -348,7 +349,7 @@ private byte[] bufB(int bpv) {
assert bpv==1; // No NAs
for (int i=0; i<_len; i++) {
int row = _xs[i];
CBSChunk.write1b(bs[row>>3],(byte)1,row&7);
bs[(row>>3)+off] = CBSChunk.write1b(bs[(row>>3)+off],(byte)1,row&7);
}
return bs;
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/water/fvec/NewVectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private void testImpl( long[] ls, int[] xs, Class C, boolean hasFloat ) {
NewChunk nv = new NewChunk(av,0);
nv._ls = ls;
nv._xs = xs;
nv._len= ls.length;
nv._len= nv._len2 = ls.length;
Chunk bv = nv.compress();
bv._vec = av.close(new Futures());
// Compression returns the expected compressed-type:
Expand Down Expand Up @@ -87,7 +87,7 @@ private void testImpl( long[] ls, int[] xs, Class C, boolean hasFloat ) {
NewChunk nv = new NewChunk(av,0);
nv._ls = new long[]{0,0,0,0}; // A 4-row chunk
nv._xs = new int []{0,0,0,0};
nv._len= nv._ls.length;
nv._len= nv._len2 = nv._ls.length;
nv.close(0,null);
Vec vec = av.close(new Futures());
assertEquals( nv._ls.length, vec.length() );
Expand Down

0 comments on commit 60af390

Please sign in to comment.