latest updates to zc
partial gut of comparator
near final comparison, still barfs on edge cases
auto advancing past squiqles
moved to external classes for parse
Add apache libraries

Need apache-cassandra so we can use the ByteBuffer utils. Need the
extra libraries because they are loaded by the ByteBufferUtil.

*Note:* In production the comparator will be able to load these because
cassandra will be running, only needed for testing / dev.
bug fixes to pass tests

* use the reverseResult() function
* refactor DatumType.directCompare() to match the logic layout of
 regexCompare
* bug in DatumUtil.advanceToLongIfPresent() it was advancing beyond the start
of the digits.
* modify DatumUtil.advanceToLongIfPresent() to test for trailing non digits
add more tests
Merge branch 'master' into zero-copy-TLP
refactor to detect number of tokens

refactor buffer parsing to use a state machine and detect
the number of tokens. This means we can better replicate the regex impl
that did not reverse string comparisons if both buffers have less than 2 tokens.

change timestamp comparison to use ByteBufferUtil instead of creating
longs to improve performance a little

Note: This detects a~~1 as two tokens, the reg would detect 3. I think this
may result in bugs in edge cases. If there is less than 2 tokens in each
buffer the full buffer are compared without reverse. If there is more than two but they can not be turned into longs the full buffer is compared with
reverse.

So we probably need to change the state machine to detect the same number of tokens.

Times for running the throughout test 10 times on my MBP 2011, 16GB, SSD

Previous implementation

Throughput test 493 ms for 200000 comparisons
Throughput test 88 ms for 200000 comparisons
Throughput test 106 ms for 200000 comparisons
Throughput test 70 ms for 200000 comparisons
Throughput test 70 ms for 200000 comparisons
Throughput test 118 ms for 200000 comparisons
Throughput test 91 ms for 200000 comparisons
Throughput test 74 ms for 200000 comparisons
Throughput test 71 ms for 200000 comparisons
Throughput test 71 ms for 200000 comparisons

Reg Ex

Throughput test 665 ms for 200000 comparisons
Throughput test 349 ms for 200000 comparisons
Throughput test 397 ms for 200000 comparisons
Throughput test 307 ms for 200000 comparisons
Throughput test 310 ms for 200000 comparisons
Throughput test 307 ms for 200000 comparisons
Throughput test 312 ms for 200000 comparisons
Throughput test 314 ms for 200000 comparisons
Throughput test 311 ms for 200000 comparisons
Throughput test 315 ms for 200000 comparisons

Zero Copy all ByteBufferUtil comparison

Throughput test 479 ms for 200000 comparisons
Throughput test 85 ms for 200000 comparisons
Throughput test 107 ms for 200000 comparisons
Throughput test 70 ms for 200000 comparisons
Throughput test 68 ms for 200000 comparisons
Throughput test 118 ms for 200000 comparisons
Throughput test 81 ms for 200000 comparisons
Throughput test 67 ms for 200000 comparisons
Throughput test 67 ms for 200000 comparisons
Throughput test 65 ms for 200000 comparisons

Zero Copy with cassandra LongType comparison

Throughput test 489 ms for 200000 comparisons
Throughput test 84 ms for 200000 comparisons
Throughput test 99 ms for 200000 comparisons
Throughput test 61 ms for 200000 comparisons
Throughput test 62 ms for 200000 comparisons
Throughput test 111 ms for 200000 comparisons
Throughput test 82 ms for 200000 comparisons
Throughput test 63 ms for 200000 comparisons
Throughput test 62 ms for 200000 comparisons
Throughput test 62 ms for 200000 comparisons

Zero Copy with java long comparison

Throughput test 514 ms for 200000 comparisons
Throughput test 107 ms for 200000 comparisons
Throughput test 125 ms for 200000 comparisons
Throughput test 99 ms for 200000 comparisons
Throughput test 87 ms for 200000 comparisons
Throughput test 135 ms for 200000 comparisons
Throughput test 106 ms for 200000 comparisons
Throughput test 85 ms for 200000 comparisons
Throughput test 87 ms for 200000 comparisons
Throughput test 84 ms for 200000 comparisons

Calling BytesType.compare

Throughput test 448 ms for 200000 comparisons
Throughput test 49 ms for 200000 comparisons
Throughput test 41 ms for 200000 comparisons
Throughput test 60 ms for 200000 comparisons
Throughput test 30 ms for 200000 comparisons
Throughput test 30 ms for 200000 comparisons
Throughput test 66 ms for 200000 comparisons
Throughput test 60 ms for 200000 comparisons
Throughput test 29 ms for 200000 comparisons
Throughput test 29 ms for 200000 comparisons
code tidy

merged DatumUtil and DatumType.

moved unused extract function to the tests
do not duplicate() ByteBuffers

Removed ByteBuffer duplication, compare() is now
responsible for returning the buffers to their original position.

I guess we should never change the position but it is safer for use to use
ByteBufferUtil.compareUnsigned rather than re-implement it. As it uses
the position of the buffer.

With duplicate()

Throughput test 479 ms for 200000 comparisons
Throughput test 84 ms for 200000 comparisons
Throughput test 98 ms for 200000 comparisons
Throughput test 64 ms for 200000 comparisons
Throughput test 65 ms for 200000 comparisons
Throughput test 117 ms for 200000 comparisons
Throughput test 86 ms for 200000 comparisons
Throughput test 77 ms for 200000 comparisons
Throughput test 73 ms for 200000 comparisons
Throughput test 64 ms for 200000 comparisons

Without duplicate()

Throughput test 167 ms for 200000 comparisons
Throughput test 72 ms for 200000 comparisons
Throughput test 52 ms for 200000 comparisons
Throughput test 88 ms for 200000 comparisons
Throughput test 55 ms for 200000 comparisons
Throughput test 51 ms for 200000 comparisons
Throughput test 64 ms for 200000 comparisons
Throughput test 83 ms for 200000 comparisons
Throughput test 52 ms for 200000 comparisons
Throughput test 59 ms for 200000 comparisons
count zero length tokens

see https://github.com/backupify/backupify-comparator/pull/6#discussion_r8895764

Original implementation counted zero length tokens, e.g. X~~9 should be
3 tokens.

Added tests for the same, all tests pass with both zero copy algorithm and
the original reg ex one.
apply coding style.

also improve some comments.
Detect same object and use absolute methods

Tests when running in cassandra were failing because there are times
when we have to compare the same instance. The code was temporarily
changing the position of buffer 1, and this meant we did not detect any
tokens in buffer two.

Added test to return 0 if buffer 1 and 2 are ==.

Modified buffer access code to only use absolute get methods and not avoid
using remaining(). We did not code to ensure the buffer was returned to
it's original position, but it's best to not change the position.

All tests passing, and they passed on the reg ex pattern.
removed unused imports
Merge pull request #1 from thelastpickle/zero-copy-TLP

Zero copy