public class TestKeyBuilder extends TestCase2
TestCase2.MyProperties, TestCase2.RandomType
_randomType, log
Constructor and Description |
---|
TestKeyBuilder() |
TestKeyBuilder(String name) |
Modifier and Type | Method and Description |
---|---|
static byte[] |
asSortKey(Object val)
Utility method converts an application key to a sort key (an unsigned
byte[] that imposes the same sort order).
|
void |
badTest_BigDecimal_stress_byteArray_values()
Stress test with random byte[]s from which we then construct
BigDecimal s. |
protected void |
doCompareTest(BigDecimal i1,
BigDecimal i2,
com.bigdata.btree.keys.TestKeyBuilder.CompareEnum cmp) |
protected void |
doEncodeDecodeTest(BigDecimal expected) |
protected void |
doEncodeDecodeTest(BigInteger expected) |
protected void |
doEQTest(BigDecimal i1,
BigDecimal i2) |
protected void |
doLTTest(BigDecimal i1,
BigDecimal i2) |
protected void |
doLTTest(BigInteger i1,
BigInteger i2) |
void |
test_BigDecimal_383() |
void |
test_BigDecimal_largeExponents()
Test with positive and negative
BigDecimal s with large
exponents |
void |
test_BigDecimal_m1() |
void |
test_BigDecimal_negativeSortOrder()
Test with positive and negative
BigDecimal s having varying
digits after the decimals. |
void |
test_BigDecimal_stress_double_values()
Stress test with random
double values. |
void |
test_BigDecimal_zeroPrecisionNotPreserved()
Unit test demonstrates that precision is not preserved by the encoding.
|
void |
test_BigDecimal_zeros() |
void |
test_BigDecimal0()
Test encode/decode for various values of zero.
|
void |
test_bigDecimalKey()
Unit tests for encoding
BigDecimal keys. |
void |
test_BigInteger_383() |
void |
test_BigInteger_ctor() |
void |
test_BigInteger_m1() |
void |
test_BigInteger_sortOrder()
Test with positive and negative
BigInteger s having a common
prefix with varying digits after the prefix. |
void |
test_BigInteger_stress_byteArray_values()
Stress test with random byte[]s from which we then construct
BigInteger s. |
void |
test_BigInteger_stress_long_values()
Stress test with random
long values. |
void |
test_bigIntegerKey()
Unit tests for encoding
BigInteger keys. |
void |
test_ctor()
ctor tests, including correct rejection.
|
void |
test_double_order()
Verify that we can convert double keys to unsigned byte[]s while
preserving the value space order.
|
void |
test_encodeDecodeByte()
Unit test for
KeyBuilder#encodeByte(byte) and
KeyBuilder#decodeByte(byte) . |
void |
test_float_order()
Verify that we can convert float keys to unsigned byte[]s while
preserving the value space order.
|
void |
test_keyBuilder_append_bytes()
Tests ability to append to the buffer, including with overflow of the
buffer capacity.
|
void |
test_keyBuilder_ascii_order()
Test verifies the order for ASCII sort keys, including verifying that
the pad byte causes a prefix such as "bro" to sort before a term which
extends that prefix, such as "brown".
|
void |
test_keyBuilder_ascii()
Test ordering imposed by encoding a single ASCII key.
|
void |
test_keyBuilder_byte_key()
Note: The
KeyBuilder uses an order preserving transfrom from
signed bytes to unsigned bytes. |
void |
test_keyBuilder_double_key() |
void |
test_keyBuilder_ensureCapacity() |
void |
test_keyBuilder_ensureCapacity02() |
void |
test_keyBuilder_ensureCapacity03()
verify that existing data is preserved if the capacity is extended.
|
void |
test_keyBuilder_ensureFree() |
void |
test_keyBuilder_float_key() |
void |
test_keyBuilder_getKey_len0()
Verify returns zero length byte[] when the key has zero bytes.
|
void |
test_keyBuilder_getKey()
Test ability to extract and return a key.
|
void |
test_keyBuilder_int_key() |
void |
test_keyBuilder_long_key() |
void |
test_keyBuilder_multiField_ascii_long()
Test that lexiographic order is maintain when a variable length ASCII
field is followed by another field.
|
void |
test_keyBuilder_reset()
Test ability to reset the key buffer (simply zeros the #of valid bytes
in the buffer without touching the buffer itself).
|
void |
test_keyBuilder_short_key() |
void |
test_keyBuilder_UUID()
Test verifies encode/decode of
UUID s and also verifies that the
natural order of the encoded UUID s respects the order imposed
by UUID.compareTo(UUID) . |
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
public TestKeyBuilder()
public TestKeyBuilder(String name)
name
- public void test_ctor()
public void test_keyBuilder_ensureCapacity()
public void test_keyBuilder_ensureCapacity02()
public void test_keyBuilder_ensureCapacity03()
public void test_keyBuilder_ensureFree()
public void test_keyBuilder_append_bytes()
public void test_keyBuilder_getKey()
public void test_keyBuilder_getKey_len0()
public void test_keyBuilder_reset()
public void test_keyBuilder_byte_key()
KeyBuilder
uses an order preserving transfrom from
signed bytes to unsigned bytes. This transform preserves the order of
values in the signed space by translating them such that the minimum
signed value (-128) is represented by an unsigned 0x00. For example, zero
(signed) becomes 0x80 (unsigned) while -1 (signed) is becomes to 0x79
(0x79 LT 0x80).public void test_keyBuilder_short_key()
public void test_keyBuilder_int_key()
public void test_keyBuilder_long_key()
public void test_keyBuilder_float_key() throws NoSuccessorException
NoSuccessorException
public void test_keyBuilder_double_key() throws NoSuccessorException
NoSuccessorException
public void test_keyBuilder_UUID()
UUID
s and also verifies that the
natural order of the encoded UUID
s respects the order imposed
by UUID.compareTo(UUID)
.public void test_keyBuilder_ascii()
public void test_keyBuilder_ascii_order()
public void test_keyBuilder_multiField_ascii_long()
Test that lexiographic order is maintain when a variable length ASCII field is followed by another field. This test works by comparing the original multi-field key with the multi-field key formed from the successor of the ASCII field followed by the other field:
[text][nextValue] LT [successor(text)][nextValue]
public void test_float_order()
public void test_double_order()
public void test_encodeDecodeByte()
KeyBuilder#encodeByte(byte)
and
KeyBuilder#decodeByte(byte)
. The former should have the same
behavior as KeyBuilder.appendSigned(byte)
while the latter should
reverse the mapping.public void test_BigInteger_ctor()
protected void doEncodeDecodeTest(BigInteger expected)
protected void doEncodeDecodeTest(BigDecimal expected)
protected void doLTTest(BigInteger i1, BigInteger i2)
protected void doEQTest(BigDecimal i1, BigDecimal i2)
protected void doLTTest(BigDecimal i1, BigDecimal i2)
public void test_BigInteger_383()
public void test_BigDecimal_383()
public void test_BigInteger_m1()
public void test_BigDecimal_m1()
public void test_BigDecimal_zeroPrecisionNotPreserved()
public void test_BigDecimal_zeros()
public void test_bigIntegerKey()
BigInteger
keys.public void test_bigDecimalKey()
BigDecimal
keys.public void test_BigInteger_stress_long_values()
long
values.public void test_BigDecimal_stress_double_values()
double
values.public void test_BigInteger_sortOrder()
BigInteger
s having a common
prefix with varying digits after the prefix.public void test_BigDecimal_negativeSortOrder()
BigDecimal
s having varying
digits after the decimals.public void test_BigDecimal_largeExponents()
BigDecimal
s with large
exponentspublic void test_BigInteger_stress_byteArray_values()
BigInteger
s.public void badTest_BigDecimal_stress_byteArray_values()
BigDecimal
s.protected void doCompareTest(BigDecimal i1, BigDecimal i2, com.bigdata.btree.keys.TestKeyBuilder.CompareEnum cmp)
public void test_BigDecimal0()
public static final byte[] asSortKey(Object val)
Note: This method is thread-safe.
Note: Strings are Unicode safe for the default locale. See
Locale.getDefault()
. If you require a specific local or different
locals at different times or for different indices then you MUST
provision and apply your own KeyBuilder
.
Note: This method circumvents explicit configuration of the
KeyBuilder
and is used nearly exclusively by unit tests. While
explicit configuration is not required for keys which do not include
Unicode sort key components, this method also relies on a single global
KeyBuilder
instance protected by a lock. That lock is therefore a
bottleneck. The correct practice is to use thread-local or per task
IKeyBuilder
s to avoid lock contention.
val
- An application key.null
iff the key is null
. If the
key is a byte[], then the byte[] itself will be returned.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.