Beispiel #1
0
            public override int FindPartition(BinaryComparable key)
            {
                int pos = System.Array.BinarySearch(this.splitPoints, this.lower, this.upper, key
                                                    ) + 1;

                return((pos < 0) ? -pos : pos);
            }
Beispiel #2
0
 internal SinglySplitTrieNode(TotalOrderPartitioner <K, V> _enclosing, int level, BinaryComparable
                              [] splitPoints, int lower)
     : base(level)
 {
     this._enclosing   = _enclosing;
     this.lower        = lower;
     this.mySplitPoint = splitPoints[lower];
 }
Beispiel #3
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
                                                                                                 ));
            }
        /// <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);
        }
Beispiel #5
0
 public override int FindPartition(BinaryComparable key)
 {
     return(this.lower + (key.CompareTo(this.mySplitPoint) < 0 ? 0 : 1));
 }
Beispiel #6
0
 public override int FindPartition(BinaryComparable key)
 {
     return(this.result);
 }