| | |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import static org.opends.server.backends.jeb.Importer.indexComparator; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.DataOutputStream; |
| | | import java.io.IOException; |
| | |
| | | /** Used to iterate over the buffer when writing to a scratch file. */ |
| | | private int position; |
| | | |
| | | /** The comparator to use sort the keys. */ |
| | | private ComparatorBuffer<byte[]> comparator; |
| | | |
| | | /** |
| | | * Used to make sure that an instance of this class is put on the |
| | | * correct scratch file writer work queue for processing. |
| | |
| | | recordOffset = size - 1; |
| | | keys = 0; |
| | | position = 0; |
| | | comparator = null; |
| | | indexKey = null; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Set the comparator to be used in the buffer processing to the specified |
| | | * comparator. |
| | | * |
| | | * @param comparator The comparator to set the buffer's comparator to. |
| | | */ |
| | | public void setComparator(ComparatorBuffer<byte[]> comparator) |
| | | { |
| | | this.comparator = comparator; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Return a buffer's current position value. |
| | | * |
| | | * @return The buffer's current position value. |
| | |
| | | return position; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Set a buffer's position value to the specified position. |
| | | * |
| | |
| | | this.position = position; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Sort the buffer. |
| | | */ |
| | |
| | | sort(0, keys); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Add the specified key byte array and EntryID to the buffer. |
| | | * |
| | |
| | | int yKeyLen = PackedInteger.readInt(buffer, yoffSet); |
| | | int yKey = PackedInteger.getReadIntLength(buffer, yoffSet) + yoffSet; |
| | | |
| | | int cmp = comparator.compare(buffer, xKey, xKeyLen, xIndexID, yKey, yKeyLen, yIndexID); |
| | | int cmp = indexComparator.compare(buffer, xKey, xKeyLen, xIndexID, yKey, yKeyLen, yIndexID); |
| | | return evaluateReturnCode(cmp, op); |
| | | } |
| | | |
| | |
| | | int xKeyLen = PackedInteger.readInt(buffer, xoffSet); |
| | | int xKey = PackedInteger.getReadIntLength(buffer, xoffSet) + xoffSet; |
| | | |
| | | int cmp = comparator.compare(buffer, xKey, xKeyLen, xIndexID, yKey, yKey.length, yIndexID); |
| | | int cmp = indexComparator.compare(buffer, xKey, xKeyLen, xIndexID, yKey, yKey.length, yIndexID); |
| | | return evaluateReturnCode(cmp, op); |
| | | } |
| | | |
| | |
| | | offset += PackedInteger.getReadLongLength(buffer, offset); |
| | | int keyLen = PackedInteger.readInt(buffer, offset); |
| | | int key = PackedInteger.getReadIntLength(buffer, offset) + offset; |
| | | return comparator.compare(buffer, key, keyLen, b, b.length) == 0 |
| | | return indexComparator.compare(buffer, key, keyLen, b, b.length) == 0 |
| | | && indexID == bIndexID; |
| | | } |
| | | |
| | |
| | | int keyLen = PackedInteger.readInt(buffer, offset); |
| | | int key = PackedInteger.getReadIntLength(buffer, offset) + offset; |
| | | |
| | | final int cmp = comparator.compare(buffer, key, keyLen, keyBuf.array(), keyBuf.limit()); |
| | | final int cmp = indexComparator.compare(buffer, key, keyLen, keyBuf.array(), keyBuf.limit()); |
| | | if (cmp != 0) |
| | | { |
| | | return cmp; |