All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.azure.documentdb.hadoop.DocumentDBWritableComparator Maven / Gradle / Ivy

The newest version!
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
//------------------------------------------------------------
package com.microsoft.azure.documentdb.hadoop;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class DocumentDBWritableComparator extends WritableComparator {

    public DocumentDBWritableComparator() {
        super(DocumentDBWritable.class, true);
    }

    protected DocumentDBWritableComparator(
            final Class keyClass) {
        super(keyClass, true);
    }

    protected DocumentDBWritableComparator(
            final Class keyClass,
            final boolean createInstances) {
        super(keyClass, createInstances);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int compare(final WritableComparable a, final WritableComparable b) {
        if (a instanceof DocumentDBWritable && b instanceof DocumentDBWritable) {
            return new DocumentDBWritableComparator().compare(
                    ((DocumentDBWritable) a).getDoc(),
                    ((DocumentDBWritable) b).getDoc());
        } else {
            return super.compare(a, b);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy