@Override public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) { int i = 0; for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) { int len = this.normalizedKeyLengths[i]; len = numBytes >= len ? len : numBytes; this.comparators[i].putNormalizedKey(accessField(keyFields[i], value), target, offset, len); numBytes -= len; offset += len; } }
@Override public void putNormalizedKey(Row record, MemorySegment target, int offset, int numBytes) { int bytesLeft = numBytes; int currentOffset = offset; for (int i = 0; i < numLeadingNormalizableKeys && bytesLeft > 0; i++) { int len = normalizedKeyLengths[i]; len = bytesLeft >= len ? len : bytesLeft; TypeComparator<Object> comparator = comparators[i]; Object element = record.getField(keyPositions[i]); // element can be null // write key comparator.putNormalizedKey(element, target, currentOffset, len); bytesLeft -= len; currentOffset += len; } }
public MemorySegment setupNormalizedKeysMemSegment(T[] data, int normKeyLen, TypeComparator<T> comparator) { MemorySegment memSeg = MemorySegmentFactory.allocateUnpooledSegment(2048); // Setup normalized Keys in the memory segment int offset = 0; for (T e : data) { comparator.putNormalizedKey(e, memSeg, offset, normKeyLen); offset += normKeyLen; } return memSeg; }
@SuppressWarnings("unchecked") @Override public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) { int i = 0; try { for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) { int len = this.normalizedKeyLengths[i]; len = numBytes >= len ? len : numBytes; this.comparators[i].putNormalizedKey(value.getFieldNotNull(this.keyPositions[i]), target, offset, len); numBytes -= len; offset += len; } } catch (NullFieldException nfex) { throw new NullKeyFieldException(nfex); } catch (NullPointerException npex) { throw new NullKeyFieldException(this.keyPositions[i]); } }
@Override public void putNormalizedKey(T record, MemorySegment target, int offset, int numBytes) { if (numBytes > 0) { // write a null byte with padding if (record == null) { target.putBoolean(offset, false); // write padding for (int j = 0; j < numBytes - 1; j++) { target.put(offset + 1 + j, (byte) 0); } } // write a non-null byte with key else { target.putBoolean(offset, true); // write key wrappedComparator.putNormalizedKey(record, target, offset + 1, numBytes - 1); } } }
@Override public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) { int i = 0; for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) { int len = this.normalizedKeyLengths[i]; len = numBytes >= len ? len : numBytes; this.comparators[i].putNormalizedKey(accessField(keyFields[i], value), target, offset, len); numBytes -= len; offset += len; } }
@Override public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) { int i = 0; for (; i < this.numLeadingNormalizableKeys & numBytes > 0; i++) { int len = this.normalizedKeyLengths[i]; len = numBytes >= len ? len : numBytes; this.comparators[i].putNormalizedKey(accessField(keyFields[i], value), target, offset, len); numBytes -= len; offset += len; } }
@SuppressWarnings("unchecked") @Override public void putNormalizedKey(Tuple value, MemorySegment target, int offset, int numBytes) { int i = 0; for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) { int len = this.normalizedKeyLengths[i]; len = numBytes >= len ? len : numBytes; this.comparators[i].putNormalizedKey(value.getObject(this.keyPositions[i]), target, offset, len); numBytes -= len; offset += len; } }
@Override public void putNormalizedKey(Row record, MemorySegment target, int offset, int numBytes) { int bytesLeft = numBytes; int currentOffset = offset; for (int i = 0; i < numLeadingNormalizableKeys && bytesLeft > 0; i++) { int len = normalizedKeyLengths[i]; len = bytesLeft >= len ? len : bytesLeft; TypeComparator<Object> comparator = comparators[i]; Object element = record.getField(keyPositions[i]); // element can be null // write key comparator.putNormalizedKey(element, target, currentOffset, len); bytesLeft -= len; currentOffset += len; } }
@Override public void putNormalizedKey(Row record, MemorySegment target, int offset, int numBytes) { int bytesLeft = numBytes; int currentOffset = offset; for (int i = 0; i < numLeadingNormalizableKeys && bytesLeft > 0; i++) { int len = normalizedKeyLengths[i]; len = bytesLeft >= len ? len : bytesLeft; TypeComparator<Object> comparator = comparators[i]; Object element = record.getField(keyPositions[i]); // element can be null // write key comparator.putNormalizedKey(element, target, currentOffset, len); bytesLeft -= len; currentOffset += len; } }
@Override public void putNormalizedKey(T val, MemorySegment target, int offset, int numBytes) { if(val != null) { target.put(offset, NOT_NULL_FLAG); this.wrappedComparator.putNormalizedKey(val, target, offset + 1, numBytes - 1); } else { for(int i=0; i < numBytes; i++) { target.put(offset, NULL_FLAG); } } }
@SuppressWarnings("unchecked") @Override public void putNormalizedKey(Tuple value, MemorySegment target, int offset, int numBytes) { if(!areKeysAbs) { makeKeysAbs(keyPositions, value.size()); areKeysAbs = true; } int i = 0; for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) { int len = this.normalizedKeyLengths[i]; len = numBytes >= len ? len : numBytes; this.comparators[i].putNormalizedKey(value.getObject(keyPositions[i]), target, offset, len); numBytes -= len; offset += len; } }
@SuppressWarnings("unchecked") @Override public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) { int i = 0; try { for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) { int len = this.normalizedKeyLengths[i]; len = numBytes >= len ? len : numBytes; this.comparators[i].putNormalizedKey(value.getFieldNotNull(this.keyPositions[i]), target, offset, len); numBytes -= len; offset += len; } } catch (NullFieldException nfex) { throw new NullKeyFieldException(nfex); } catch (NullPointerException npex) { throw new NullKeyFieldException(this.keyPositions[i]); } }
@Override public void putNormalizedKey(T record, MemorySegment target, int offset, int numBytes) { if (numBytes > 0) { // write a null byte with padding if (record == null) { target.putBoolean(offset, false); // write padding for (int j = 0; j < numBytes - 1; j++) { target.put(offset + 1 + j, (byte) 0); } } // write a non-null byte with key else { target.putBoolean(offset, true); // write key wrappedComparator.putNormalizedKey(record, target, offset + 1, numBytes - 1); } } }
@SuppressWarnings("unchecked") @Override public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) { int i = 0; try { for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) { int len = this.normalizedKeyLengths[i]; len = numBytes >= len ? len : numBytes; this.comparators[i].putNormalizedKey(value.getFieldNotNull(this.keyPositions[i]), target, offset, len); numBytes -= len; offset += len; } } catch (NullFieldException nfex) { throw new NullKeyFieldException(nfex); } catch (NullPointerException npex) { throw new NullKeyFieldException(this.keyPositions[i]); } }
@Override public void putNormalizedKey(T record, MemorySegment target, int offset, int numBytes) { if (numBytes > 0) { // write a null byte with padding if (record == null) { target.putBoolean(offset, false); // write padding for (int j = 0; j < numBytes - 1; j++) { target.put(offset + 1 + j, (byte) 0); } } // write a non-null byte with key else { target.putBoolean(offset, true); // write key wrappedComparator.putNormalizedKey(record, target, offset + 1, numBytes - 1); } } }
this.comparator.putNormalizedKey(record, this.currentSortIndexSegment, this.currentSortIndexOffset + OFFSET_LEN, this.numKeyBytes);
this.comparator.putNormalizedKey(record, this.currentSortIndexSegment, this.currentSortIndexOffset + OFFSET_LEN, this.numKeyBytes);
this.comparator.putNormalizedKey(record, this.currentSortIndexSegment, this.currentSortIndexOffset + OFFSET_LEN, this.numKeyBytes);
this.comparator.putNormalizedKey(record, this.currentSortIndexSegment, this.currentSortIndexOffset + OFFSET_LEN, this.numKeyBytes);