Пример #1
0
        /// <summary>
        /// get all matching indices for a specific row of expressions used in where statements
        /// </summary>
        public long[] GetMatchingIndices(long row)
        {
            //No where statements, setting index to null will bypass directly to the underlying table data
            if (where == null || where.Count == 0)
            {
                long[] r = new long[1];
                r[0] = row;
                return(r);
            }

            //only 1 where statement, use its result directly
            if (where.Count == 1)
            {
                return(where[0].GetMatchIndex(row));
            }

            // many where statements
            long[] index = null;
            foreach (var w in where)
            {
                if (index != null)
                {
                    index = w.GetMatchIndex(row, ArrayRange.IndexArray(index));
                }
                else
                {
                    index = w.GetMatchIndex(row);
                }
                if (index.Length == 0)
                {
                    break;
                }
            }
            return(index);
        }
Пример #2
0
        //get the first matching index for a specific row of expressions used in where statements
        public long GetIndexFirstMatch(long row)
        {
            //No where statements, seting index to null will bypass directly to the underlying talbe data
            if (where == null || where.Count == 0)
            {
                return(row);
            }

            //only 1 where statement, use its result directly
            if (where.Count == 1)
            {
                return(where[0].GetFirstMatchIndex(row));
            }

            // many where statements
            long[] index = null;
            foreach (var w in where)
            {
                if (index != null)
                {
                    index = w.GetMatchIndex(row, ArrayRange.IndexArray(index));
                }
                else
                {
                    index = w.GetMatchIndex(row);
                }
                if (index.Length == 0)
                {
                    break;
                }
            }
            if (index == null || index.Length == 0)
            {
                return(-1);
            }
            else
            {
                return(index[0]);
            }
        }