public abstract class AbstractRabaCoderTestCase extends TestCase2
IRabaCoder
implementations.Modifier and Type | Class and Description |
---|---|
static class |
AbstractRabaCoderTestCase.TestOp
Tests of the
Op test helper class. |
TestCase2.MyProperties, TestCase2.RandomType
Modifier and Type | Field and Description |
---|---|
protected IRabaCoder |
rabaCoder
The fixture under test.
|
protected static double |
scalingFactor
Scaling factor converts nanoseconds to milliseconds.
|
_randomType, log
Constructor and Description |
---|
AbstractRabaCoderTestCase() |
AbstractRabaCoderTestCase(String name) |
Modifier and Type | Method and Description |
---|---|
protected static void |
assertSameIterator(Iterator<byte[]> eitr,
Iterator<byte[]> aitr)
Verify same byte[] iterators.
|
static int |
doRabaCoderPerformanceTest(IRaba expected,
IRabaCoder rabaCoder,
int size,
int nops,
Random r,
com.bigdata.btree.raba.codec.AbstractRabaCoderTestCase.Op op)
Do a performance stress test consisting of random operations on a
randomly generated B+Tree keys
IRaba . |
protected void |
doRandomRoundTripTest(IRabaCoder dataCoder,
int size,
int capacity)
Generates a random byte[][] and verifies round-trip encoding and
decoding.
|
static void |
doRoundTripTest(IRabaCoder rabaCoder,
IRaba expected) |
protected byte[] |
getRandomValue(IRabaCoder dataCoder)
Return a random byte array.
|
protected boolean |
isFixedLength()
|
static void |
main(String[] args)
Performance stress test for keys.
|
void |
test_empty() |
void |
test_emptyElement()
Test with an empty byte[] element.
|
void |
test_entryCount1()
Test with
IRaba having a size of ONE (1) and a variety of
capacities. |
void |
test_entryCount2()
Test with
IRaba having a size of TWO (2) and a variety of
capacities. |
void |
test_error1()
This test case was developed for the
FrontCodedRabaCoder . |
void |
test_error2()
This test case was developed for the
CanonicalHuffmanRabaCoder . |
void |
test_keyCoderPerformance()
A test designed to measure the performance of an
IRabaCoder for
operations on B+Tree keys, including search. |
void |
test_mike_personick()
A simple unit test.
|
void |
test_negativeByteValues()
Test with byte values which are negative values when interpreted as as
signed 8 bit integers.
|
void |
test_nsymbolsOne_nulls()
Test with a single byte value (nsymbols=1) and some nulls.
|
void |
test_nsymbolsOne()
Test with a single byte value (nsymbols:=1).
|
void |
test_randomOnce() |
void |
test_randomURIs()
Test using a sequence of random URIs (formed with successive prefixes).
|
void |
test_withNulls()
Test with a null value.
|
void |
test_withNulls2()
Test with a single value, which is null.
|
void |
testStress() |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEqualsWithinUlps, assertSameArray, assertSameArray, assertSameBigDecimal, assertSameBigDecimal, assertSameBigInteger, assertSameBigInteger, assertSameIterator, assertSameIterator, assertSameIteratorAnyOrder, assertSameIteratorAnyOrder, assertSameValue, assertSameValue, assertZeroUlps, assertZeroUlps, fail, getInnerCause, getNormalInt, getProjectBuildPath, getProperties, getRandomObject, getRandomObject, getRandomOrder, getRandomString, getTestInputStream, getTestResource, getTestResource, getUlps, getUlps, isDEBUG, isDEBUG, isINFO, isINFO, isInnerCause, logProperties
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
protected IRabaCoder rabaCoder
null
unless you
explicitly set it in TestCase.setUp()
.protected static final double scalingFactor
public AbstractRabaCoderTestCase()
public AbstractRabaCoderTestCase(String name)
name
- protected boolean isFixedLength()
true
if the IRabaCoder
only handles fixed
length values (the default always returns false
). This is
used to skip tests which have variable length byte[]s when testing the
FixedLengthValueRabaCoder
.public void test_mike_personick() throws UnsupportedEncodingException
UnsupportedEncodingException
public void test_negativeByteValues() throws UnsupportedEncodingException
UnsupportedEncodingException
public void test_emptyElement() throws UnsupportedEncodingException
UnsupportedEncodingException
public void test_nsymbolsOne()
HuffmanCodec
and
CanonicalFast64CodeWordDecoder
. A workaround for that bug has
been implemented in the CanonicalHuffmanRabaCoder
.public void test_nsymbolsOne_nulls()
HuffmanCodec
and
CanonicalFast64CodeWordDecoder
. A workaround for that bug has
been implemented in the CanonicalHuffmanRabaCoder
.public void test_withNulls() throws UnsupportedEncodingException
UnsupportedEncodingException
public void test_withNulls2()
CanonicalFast64CodeWordDecoder
ctor
there is a problem handling a logical byte[][] consisting solely of
null
s. We handle this for the case of an empty logical
byte[][] using an EmptyRabaValueDecoder
. I suppose that could be
parameterized to identify the null
s or else just fix the
ctor.public void test_empty() throws IOException
IOException
public void test_entryCount1() throws IOException
IRaba
having a size of ONE (1) and a variety of
capacities.IOException
public void test_entryCount2() throws IOException
IRaba
having a size of TWO (2) and a variety of
capacities.IOException
public void test_error1() throws IOException
FrontCodedRabaCoder
.IOException
public void test_error2()
CanonicalHuffmanRabaCoder
.
junit.framework.AssertionFailedError: search([44, 186, 169, 175, 191, 31, 36, 227]): expectedIndex=1, actualIndex=-1, expected=com.bigdata.btree.raba.ReadOnlyKeysRaba{ capacity=3, size=2, isKeys=true, isReadOnly=true, [ [44, 186, 169, 175, 191, 31, 36, 12], [44, 186, 169, 175, 191, 31, 36, 227]]}, actual=com.bigdata.btree.raba.codec.CanonicalHuffmanRabaCoder$RabaDecoder{ capacity=2, size=2, isKeys=true, isReadOnly=true, [ [44, 186, 169, 175, 191, 31, 36, 12], [44, 186, 169, 175, 191, 31, 36, 227]]} at junit.framework.Assert.fail(Assert.java:47) at com.bigdata.btree.AbstractBTreeTestCase.assertSameRaba(AbstractBTreeTestCase.java:583) at com.bigdata.btree.raba.codec.AbstractRabaCoderTestCase.doRoundTripTest(AbstractRabaCoderTestCase.java:499) at com.bigdata.btree.raba.codec.AbstractRabaCoderTestCase.doRandomRoundTripTest(AbstractRabaCoderTestCase.java:487) at com.bigdata.btree.raba.codec.AbstractRabaCoderTestCase.test_entryCount2(AbstractRabaCoderTestCase.java:247)
junit.framework.AssertionFailedError: search([44, 197, 214, 208, 192, 31, 36, 156]): expectedIndex=1, actualIndex=-1, expected=com.bigdata.btree.raba.ReadOnlyKeysRaba{ capacity=2, size=2, isKeys=true, isReadOnly=true, [ [44, 197, 214, 208, 192, 31, 36, 12], [44, 197, 214, 208, 192, 31, 36, 156]]}, actual=com.bigdata.btree.raba.codec.CanonicalHuffmanRabaCoder$RabaDecoder{ capacity=2, size=2, isKeys=true, isReadOnly=true, [ [44, 197, 214, 208, 192, 31, 36, 12], [44, 197, 214, 208, 192, 31, 36, 156]]} at junit.framework.Assert.fail(Assert.java:47) at com.bigdata.btree.AbstractBTreeTestCase.assertSameRaba(AbstractBTreeTestCase.java:583) at com.bigdata.btree.raba.codec.AbstractRabaCoderTestCase.doRoundTripTest(AbstractRabaCoderTestCase.java:538) at com.bigdata.btree.raba.codec.AbstractRabaCoderTestCase.test_error2(AbstractRabaCoderTestCase.java:325)
public void test_randomOnce() throws IOException
IOException
public void testStress() throws IOException
IOException
public void test_randomURIs() throws Exception
Exception
protected byte[] getRandomValue(IRabaCoder dataCoder)
IRabaCoder
is a
FixedLengthValueRabaCoder
, in which case a byte[] having the
appropriate length will be returned.dataCoder
- The coder.protected void doRandomRoundTripTest(IRabaCoder dataCoder, int size, int capacity) throws IOException
Note: This uses a uniform random distribution. Therefore the huffman codes tend to occupy MORE space than the original byte[][] since the canonical huffman code can not be shorter than the original byte values on average when all values are equally likely. When you want to measure the expected compression ratio you need to test with a gaussian distribution (bell curve) over the values, a USASCII distribution, etc.
size
- The #of entries in the byte[][].capacity
- The capacity of the byte[][].IOException
public static void doRoundTripTest(IRabaCoder rabaCoder, IRaba expected)
public static void main(String[] args)
args
- [nops [generator [size]]]
FIXME parameterize the generator choice.public void test_keyCoderPerformance()
IRabaCoder
for
operations on B+Tree keys, including search.public static int doRabaCoderPerformanceTest(IRaba expected, IRabaCoder rabaCoder, int size, int nops, Random r, com.bigdata.btree.raba.codec.AbstractRabaCoderTestCase.Op op)
IRaba
. The operations will be
checked against ground truth.rabaCoder
- The coder to be tested.size
- The #of keys.nops
- The #of operations to perform.r
- The random number generator.op
- The distribution of the operations to be performed.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.