예제 #1
0
            public override int FindPartition(BinaryComparable key)
            {
                int level = this.GetLevel();

                if (key.GetLength() <= level)
                {
                    return(this.child[0].FindPartition(key));
                }
                return(this.child[unchecked ((int)(0xFF)) & key.GetBytes()[level]].FindPartition(key
                                                                                                 ));
            }
예제 #2
0
        /// <summary>
        /// Use (the specified slice of the array returned by)
        /// <see cref="Org.Apache.Hadoop.IO.BinaryComparable.GetBytes()"/>
        /// to partition.
        /// </summary>
        public override int GetPartition(BinaryComparable key, V value, int numPartitions
                                         )
        {
            int length     = key.GetLength();
            int leftIndex  = (leftOffset + length) % length;
            int rightIndex = (rightOffset + length) % length;
            int hash       = WritableComparator.HashBytes(key.GetBytes(), leftIndex, rightIndex - leftIndex
                                                          + 1);

            return((hash & int.MaxValue) % numPartitions);
        }