Пример #1
0
        public int getPartitionKey(IScalar partitionCol)
        {
            if (partitionCol.getDataCategory() != cat)
            {
                throw new Exception("Data category incompatible.");
            }
            if (cat == DATA_CATEGORY.TEMPORAL && type != partitionCol.getDataType())
            {
                DATA_TYPE old = partitionCol.getDataType();
                partitionCol = (IScalar)Utils.castDateTime(partitionCol, type);
                if (partitionCol == null)
                {
                    throw new Exception("Can't convert type from " + old.ToString() + " to " + type.ToString());
                }
            }
            int index = 0;

            if (dict.ContainsKey(partitionCol))
            {
                index = (int)dict[partitionCol];
            }
            else
            {
                index = -1;
            }
            return(index);
        }
Пример #2
0
        public int getPartitionKey(IScalar partitionCol)
        {
            if (partitionCol.getDataCategory() != cat)
            {
                throw new Exception("Data category incompatible.");
            }
            if (cat == DATA_CATEGORY.TEMPORAL && type != partitionCol.getDataType())
            {
                //类型转化
                DATA_TYPE old = partitionCol.getDataType();
                partitionCol = (IScalar)Utils.castDateTime(partitionCol, type);
                if (partitionCol == null)
                {
                    throw new Exception("Can't convert type from " + old.ToString() + " to " + type.ToString());
                }
            }
            int rows = partitionCol.rows();
            int key  = partitionCol.hashBucket(buckets);

            return(key);
        }
Пример #3
0
        public int getPartitionKey(IScalar partitionCol)
        {
            if (partitionCol.getDataCategory() != cat)
            {
                throw new Exception("Data category incompatible.");
            }
            if (cat == DATA_CATEGORY.TEMPORAL && type != partitionCol.getDataType())
            {
                DATA_TYPE old = partitionCol.getDataType();
                partitionCol = (IScalar)Utils.castDateTime(partitionCol, type);
                if (partitionCol == null)
                {
                    throw new Exception("Can't convert type from " + old.ToString() + " to " + type.ToString());
                }
            }
            if (type == DATA_TYPE.DT_LONG)
            {
                throw new Exception("Long type value can't be used as a partition column.");
            }
            int key = partitionCol.hashBucket(1048576);

            return(key);
        }
Пример #4
0
        public int getPartitionKey(IScalar partitionCol)
        {
            if (partitionCol.getDataCategory() != cat)
            {
                throw new Exception("Data category incompatible.");
            }
            if (cat == DATA_CATEGORY.TEMPORAL && type != partitionCol.getDataType())
            {
                DATA_TYPE old = partitionCol.getDataType();
                partitionCol = (IScalar)Utils.castDateTime(partitionCol, type);
                if (partitionCol == null)
                {
                    throw new Exception("Can't convert type from " + old.ToString() + " to " + type.ToString());
                }
            }
            int partitions = range.rows() - 1;
            int key        = range.asof(partitionCol);

            if (key >= partitions)
            {
                key = -1;
            }
            return(key);
        }