@Override public TypeComparator<T> duplicate() { return new WritableComparator<T>(ascendingComparison, type); }
@Override public void setReference(T toCompare) { checkKryoInitialized(); reference = KryoUtils.copy(toCompare, kryo, new WritableSerializer<T>(type)); }
@Override public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException { ensureReferenceInstantiated(); ensureTempReferenceInstantiated(); reference.readFields(firstSource); tempReference.readFields(secondSource); int comp = reference.compareTo(tempReference); return ascendingComparison ? comp : -comp; }
@Override public int getNormalizeKeyLen() { ensureReferenceInstantiated(); NormalizableKey<?> key = (NormalizableKey<?>) reference; return key.getMaxNormalizedKeyLen(); }
@Override public boolean isNormalizedKeyPrefixOnly(int keyBytes) { return keyBytes < getNormalizeKeyLen(); }
@Override public int getNormalizeKeyLen() { ensureReferenceInstantiated(); NormalizableKey<?> key = (NormalizableKey<?>) reference; return key.getMaxNormalizedKeyLen(); }
@Override public boolean isNormalizedKeyPrefixOnly(int keyBytes) { return keyBytes < getNormalizeKeyLen(); }
@Override protected TypeComparator<WritableID> createComparator(boolean ascending) { return new WritableComparator<>(ascending, WritableID.class); }
@Override public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException { ensureReferenceInstantiated(); ensureTempReferenceInstantiated(); reference.readFields(firstSource); tempReference.readFields(secondSource); int comp = reference.compareTo(tempReference); return ascendingComparison ? comp : -comp; }
@Override public void setReference(T toCompare) { checkKryoInitialized(); reference = KryoUtils.copy(toCompare, kryo, new WritableSerializer<T>(type)); }
@Override public int getNormalizeKeyLen() { ensureReferenceInstantiated(); NormalizableKey<?> key = (NormalizableKey<?>) reference; return key.getMaxNormalizedKeyLen(); }
@Override public boolean isNormalizedKeyPrefixOnly(int keyBytes) { return keyBytes < getNormalizeKeyLen(); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override @PublicEvolving public TypeComparator<T> createComparator(boolean sortOrderAscending, ExecutionConfig executionConfig) { if (Comparable.class.isAssignableFrom(typeClass)) { return new WritableComparator(sortOrderAscending, typeClass); } else { throw new UnsupportedOperationException("Cannot create Comparator for " + typeClass.getCanonicalName() + ". " + "Class does not implement Comparable interface."); } }
@Override public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException { ensureReferenceInstantiated(); ensureTempReferenceInstantiated(); reference.readFields(firstSource); tempReference.readFields(secondSource); int comp = reference.compareTo(tempReference); return ascendingComparison ? comp : -comp; }
@Override public void setReference(T toCompare) { checkKryoInitialized(); reference = KryoUtils.copy(toCompare, kryo, new WritableSerializer<T>(type)); }
@Override public int getNormalizeKeyLen() { ensureReferenceInstantiated(); NormalizableKey<?> key = (NormalizableKey<?>) reference; return key.getMaxNormalizedKeyLen(); }
@Override public boolean isNormalizedKeyPrefixOnly(int keyBytes) { return keyBytes < getNormalizeKeyLen(); }
@Override protected TypeComparator<StringArrayWritable> createComparator(boolean ascending) { return new WritableComparator<StringArrayWritable>(ascending, StringArrayWritable.class); }
@Override public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException { ensureReferenceInstantiated(); ensureTempReferenceInstantiated(); reference.readFields(firstSource); tempReference.readFields(secondSource); int comp = reference.compareTo(tempReference); return ascendingComparison ? comp : -comp; }
@Override public void setReference(T toCompare) { checkKryoInitialized(); reference = KryoUtils.copy(toCompare, kryo, new WritableSerializer<T>(type)); }