@Override public int compare(ByteArray code1, ByteArray code2) { return code1.compareTo(code2); } }
private void addValue(byte[] valueBytes) { ByteArray valueByteArray = new ByteArray(valueBytes); if (previousValue != null && isOrdered) { int comp = previousValue.compareTo(valueByteArray); if (comp == 0) { return; //duplicate value } if (comp > 0) { logger.info("values not in ascending order, previous '{}', current '{}'", previousValue, valueByteArray); isOrdered = false; if (trees.size() > 0) { throw new IllegalStateException("Invalid input data. Unordered data cannot be split into multi trees"); } } } previousValue = valueByteArray; trieBuilder.addValue(valueBytes); curTreeSize += valueBytes.length; if (curTreeSize >= maxTrieTreeSize && isOrdered) { TrieDictionary<T> tree = trieBuilder.build(0); addTree(tree); reset(); } }
@Override public int compare(T o1, T o2) { //return BytesUtil.safeCompareBytes(converter.convertToBytes(o1),converter.convertToBytes(o2)); byte[] b1 = converter.convertToBytes(o1); byte[] b2 = converter.convertToBytes(o2); ByteArray ba1 = new ByteArray(b1, 0, b1.length); ByteArray ba2 = new ByteArray(b2, 0, b2.length); return ba1.compareTo(ba2); } }
if (search.compareTo(maxValueOfTree) > 0) index++; if (index >= trees.size())
@Override public int compareTo(ResultMergeSlot o) { long cuboidComp = this.currentCuboidId - o.currentCuboidId; if (cuboidComp != 0) return cuboidComp < 0 ? -1 : 1; // note GTRecord.equals() don't work because the two GTRecord comes from different GridTable ImmutableBitSet pk = this.currentRecord.getInfo().getPrimaryKey(); for (int i = 0; i < pk.trueBitCount(); i++) { int c = pk.trueBitAt(i); int comp = this.currentRecord.get(c).compareTo(o.currentRecord.get(c)); if (comp != 0) return comp; } return 0; }
@Override public int compareTo(MergeSlot o) { long cuboidComp = this.currentCuboidId - o.currentCuboidId; if (cuboidComp != 0) return cuboidComp < 0 ? -1 : 1; // note GTRecord.equals() don't work because the two GTRecord comes from different GridTable ImmutableBitSet pk = this.currentRecord.getInfo().getPrimaryKey(); for (int i = 0; i < pk.trueBitCount(); i++) { int c = pk.trueBitAt(i); int comp = this.currentRecord.get(c).compareTo(o.currentRecord.get(c)); if (comp != 0) return comp; } return 0; }
@Override public int compare(ByteArray code1, ByteArray code2) { return code1.compareTo(code2); } }
private void addValue(byte[] valueBytes) { ByteArray valueByteArray = new ByteArray(valueBytes); if (previousValue != null && isOrdered) { int comp = previousValue.compareTo(valueByteArray); if (comp == 0) { return; //duplicate value } if (comp > 0) { logger.info("values not in ascending order, previous '{}', current '{}'", previousValue, valueByteArray); isOrdered = false; if (trees.size() > 0) { throw new IllegalStateException("Invalid input data. Unordered data cannot be split into multi trees"); } } } previousValue = valueByteArray; trieBuilder.addValue(valueBytes); curTreeSize += valueBytes.length; if (curTreeSize >= maxTrieTreeSize && isOrdered) { TrieDictionary<T> tree = trieBuilder.build(0); addTree(tree); reset(); } }
@Override public int compare(T o1, T o2) { //return BytesUtil.safeCompareBytes(converter.convertToBytes(o1),converter.convertToBytes(o2)); byte[] b1 = converter.convertToBytes(o1); byte[] b2 = converter.convertToBytes(o2); ByteArray ba1 = new ByteArray(b1, 0, b1.length); ByteArray ba2 = new ByteArray(b2, 0, b2.length); return ba1.compareTo(ba2); } }
if (search.compareTo(maxValueOfTree) > 0) index++; if (index >= trees.size())
@Override public int compareTo(ResultMergeSlot o) { long cuboidComp = this.currentCuboidId - o.currentCuboidId; if (cuboidComp != 0) return cuboidComp < 0 ? -1 : 1; // note GTRecord.equals() don't work because the two GTRecord comes from different GridTable ImmutableBitSet pk = this.currentRecord.getInfo().getPrimaryKey(); for (int i = 0; i < pk.trueBitCount(); i++) { int c = pk.trueBitAt(i); int comp = this.currentRecord.get(c).compareTo(o.currentRecord.get(c)); if (comp != 0) return comp; } return 0; }
@Override public int compareTo(MergeSlot o) { long cuboidComp = this.currentCuboidId - o.currentCuboidId; if (cuboidComp != 0) return cuboidComp < 0 ? -1 : 1; // note GTRecord.equals() don't work because the two GTRecord comes from different GridTable ImmutableBitSet pk = this.currentRecord.getInfo().getPrimaryKey(); for (int i = 0; i < pk.trueBitCount(); i++) { int c = pk.trueBitAt(i); int comp = this.currentRecord.get(c).compareTo(o.currentRecord.get(c)); if (comp != 0) return comp; } return 0; }