001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    
019    package org.apache.hadoop.io;
020    
021    import java.util.Comparator;
022    
023    import org.apache.hadoop.classification.InterfaceAudience;
024    import org.apache.hadoop.classification.InterfaceStability;
025    import org.apache.hadoop.io.serializer.DeserializerComparator;
026    
027    /**
028     * <p>
029     * A {@link Comparator} that operates directly on byte representations of
030     * objects.
031     * </p>
032     * @param <T>
033     * @see DeserializerComparator
034     */
035    @InterfaceAudience.Public
036    @InterfaceStability.Stable
037    public interface RawComparator<T> extends Comparator<T> {
038    
039      /**
040       * Compare two objects in binary.
041       * b1[s1:l1] is the first object, and b2[s2:l2] is the second object.
042       * 
043       * @param b1 The first byte array.
044       * @param s1 The position index in b1. The object under comparison's starting index.
045       * @param l1 The length of the object in b1.
046       * @param b2 The second byte array.
047       * @param s2 The position index in b2. The object under comparison's starting index.
048       * @param l2 The length of the object under comparison in b2.
049       * @return An integer result of the comparison.
050       */
051      public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2);
052    
053    }