Exemple #1
0
        public CompositeShardingID(params object[] data)
        {
            if (data == null || data.Length == 0)
            {
                throw new DataAccessException(StringConsts.ARGUMENT_ERROR + "CompositeShardingID.ctor(data==null|empty)");
            }

            m_Data = data;

            m_HashCode = 0ul;

            for (var i = 0; i < m_Data.Length; i++)
            {
                var elm = m_Data[i];

                ulong ehc;

                if (elm != null)
                {
                    ehc = ShardingUtils.ObjectToShardingID(elm);
                }
                else
                {
                    ehc = 0xaa018055ul;
                }

                m_HashCode <<= 1;
                m_HashCode  ^= ehc;
            }
        }
Exemple #2
0
            /// <summary>
            /// Finds appropriate shard for ID. See MDB.ShardingUtils
            /// </summary>
            public Shard GetShardForID(object idSharding)
            {
                ulong subid = ShardingUtils.ObjectToShardingID(idSharding);

                return(Shards[subid % (ulong)Shards.Length]);
            }