@Override public void setReference(Record toCompare) { for (int i = 0; i < this.keyFields.length; i++) { if (!toCompare.getFieldInto(this.keyFields[i], this.keyHolders[i])) { throw new NullKeyFieldException(this.keyFields[i]); } } }
@Override public void setReference(Record reference) { for (int i = 0; i < this.keyFields1.length; i++) { if (!reference.getFieldInto(this.keyFields1[i], this.keyHolders1[i])) { throw new NullKeyFieldException(this.keyFields1[i]); } } }
/** * Gets the fields at the given positions into an array. * If at any position a field is null, then this method throws a @link NullKeyFieldException. * All fields that have been successfully read until the failing read are correctly contained in the record. * All other fields are not set. * * @param positions The positions of the fields to get. * @param targets The values into which the content of the fields is put. * * @throws A NullKeyFieldException in case of a failing field read. */ public void getFieldsIntoCheckingNull(int[] positions, Value[] targets) { for (int i = 0; i < positions.length; i++) { if (!getFieldInto(positions[i], targets[i])) { throw new NullKeyFieldException(i); } } }
/** * Gets the fields at the given positions into an array. * If at any position a field is null, then this method throws a @link NullKeyFieldException. * All fields that have been successfully read until the failing read are correctly contained in the record. * All other fields are not set. * * @param positions The positions of the fields to get. * @param targets The values into which the content of the fields is put. * * @throws A NullKeyFieldException in case of a failing field read. */ public void getFieldsIntoCheckingNull(int[] positions, Value[] targets) { for (int i = 0; i < positions.length; i++) { if (!getFieldInto(positions[i], targets[i])) { throw new NullKeyFieldException(i); } } }
@Override public boolean equalToReference(Record candidate) { for (int i = 0; i < this.keyFields.length; i++) { final Key<?> k = candidate.getField(this.keyFields[i], this.transientKeyHolders[i]); if (k == null) { throw new NullKeyFieldException(this.keyFields[i]); } else if (!k.equals(this.keyHolders[i])) { return false; } } return true; }
@SuppressWarnings("rawtypes") @Override public boolean equalToReference(Record candidate) { for (int i = 0; i < this.keyFields2.length; i++) { final Key k = candidate.getField(this.keyFields2[i], this.keyHolders2[i]); if (k == null) { throw new NullKeyFieldException(this.keyFields2[i]); } else if (!k.equals(this.keyHolders1[i])) { return false; } } return true; }
@Override public void putNormalizedKey(Record record, 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; ((NormalizableKey<?>) record.getField(this.keyFields[i], this.transientKeyHolders[i])).copyNormalizedKey(target, offset, len); numBytes -= len; offset += len; } } catch (NullPointerException npex) { throw new NullKeyFieldException(this.keyFields[i]); } }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public int compareToReference(Record candidate) { for (int i = 0; i < this.keyFields2.length; i++) { final Key k = candidate.getField(this.keyFields2[i], this.keyHolders2[i]); if (k == null) { throw new NullKeyFieldException(this.keyFields2[i]); } else { final int comp = k.compareTo(this.keyHolders1[i]); if (comp != 0) { return comp; } } } return 0; } }
@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.getField(this.keyPositions[i]), target, offset, len); numBytes -= len; offset += len; } } catch (NullPointerException npex) { throw new NullKeyFieldException(this.keyPositions[i]); } }
@Override public int compareToReference(TypeComparator<T> referencedComparator) { TupleComparator<T> other = (TupleComparator<T>) referencedComparator; int i = 0; try { for (; i < this.keyPositions.length; i++) { int cmp = this.comparators[i].compareToReference(other.comparators[i]); if (cmp != 0) { return cmp; } } return 0; } catch (NullPointerException npex) { throw new NullKeyFieldException(keyPositions[i]); } catch (IndexOutOfBoundsException iobex) { throw new KeyFieldOutOfBoundsException(keyPositions[i]); } }
@Override public void setReference(T toCompare) { int i = 0; try { for (; i < this.keyPositions.length; i++) { this.comparators[i].setReference(toCompare.getField(this.keyPositions[i])); } } catch (NullPointerException npex) { throw new NullKeyFieldException(keyPositions[i]); } catch (IndexOutOfBoundsException iobex) { throw new KeyFieldOutOfBoundsException(keyPositions[i]); } }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public int compare(Record first, Record second) { int i = 0; try { for (; i < this.keyFields.length; i++) { Key k1 = first.getField(this.keyFields[i], this.keyHolders[i]); Key k2 = second.getField(this.keyFields[i], this.transientKeyHolders[i]); int cmp = k1.compareTo(k2); if (cmp != 0) { return cmp; } } return 0; } catch (NullPointerException e) { throw new NullKeyFieldException(this.keyFields[i]); } }
@Override public int hash(Record object) { int i = 0; try { int code = 0; for (; i < this.keyFields.length; i++) { code ^= object.getField(this.keyFields[i], this.transientKeyHolders[i]).hashCode(); code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component } return code; } catch (NullPointerException npex) { throw new NullKeyFieldException(this.keyFields[i]); } catch (IndexOutOfBoundsException iobex) { throw new KeyFieldOutOfBoundsException(this.keyFields[i]); } }
@Override public boolean equalToReference(T candidate) { int i = 0; try { for (; i < this.keyPositions.length; i++) { if (!this.comparators[i].equalToReference(candidate.getField(this.keyPositions[i]))) { return false; } } return true; } catch (NullPointerException npex) { throw new NullKeyFieldException(keyPositions[i]); } catch (IndexOutOfBoundsException iobex) { throw new KeyFieldOutOfBoundsException(keyPositions[i]); } }
@Override public int compare(T first, T second) { int i = 0; try { for (; i < keyPositions.length; i++) { int keyPos = keyPositions[i]; int cmp = comparators[i].compare(first.getField(keyPos), second.getField(keyPos)); if (cmp != 0) { return cmp; } } return 0; } catch (NullPointerException npex) { throw new NullKeyFieldException(keyPositions[i]); } catch (IndexOutOfBoundsException iobex) { throw new KeyFieldOutOfBoundsException(keyPositions[i]); } }
@Override public int compare(DataInputView source1, DataInputView source2) throws IOException { this.temp1.read(source1); this.temp2.read(source2); for (int i = 0; i < this.keyFields.length; i++) { @SuppressWarnings("rawtypes") final Key k1 = this.temp1.getField(this.keyFields[i], this.keyHolders[i]); @SuppressWarnings("rawtypes") final Key k2 = this.temp2.getField(this.keyFields[i], this.transientKeyHolders[i]); if (k1 == null || k2 == null) { throw new NullKeyFieldException(this.keyFields[i]); } @SuppressWarnings("unchecked") final int comp = k1.compareTo(k2); if (comp != 0) { return this.ascending[i] ? comp : -comp; } } return 0; }
@Override public int hash(T value) { int i = 0; try { int code = this.comparators[0].hash(value.getField(keyPositions[0])); for (i = 1; i < this.keyPositions.length; i++) { code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component code += this.comparators[i].hash(value.getField(keyPositions[i])); } return code; } catch (NullPointerException npex) { throw new NullKeyFieldException(keyPositions[i]); } catch (IndexOutOfBoundsException iobex) { throw new KeyFieldOutOfBoundsException(keyPositions[i]); } }
@Override public int compare(DataInputView firstSource, DataInputView secondSource) throws IOException { if (deserializedFields1 == null) { instantiateDeserializationUtils(); } int i = 0; try { for (; i < serializers.length; i++) { deserializedFields1[i] = serializers[i].deserialize(deserializedFields1[i], firstSource); deserializedFields2[i] = serializers[i].deserialize(deserializedFields2[i], secondSource); } for (i = 0; i < keyPositions.length; i++) { int keyPos = keyPositions[i]; int cmp = comparators[i].compare(deserializedFields1[keyPos], deserializedFields2[keyPos]); if (cmp != 0) { return cmp; } } return 0; } catch (NullPointerException npex) { throw new NullKeyFieldException(keyPositions[i]); } catch (IndexOutOfBoundsException iobex) { throw new KeyFieldOutOfBoundsException(keyPositions[i]); } }