ToArray() публичный Метод

public ToArray ( ) : Deveel.Data.Index.IndexRange[]
Результат Deveel.Data.Index.IndexRange[]
Пример #1
0
        /// <inheritdoc/>
        public override ITable Evaluate(IQueryContext context)
        {
            var t = Child.Evaluate(context);

            var exp = Expression;

            // Assert that all variables in the expression are identical.
            var columnNames = exp.DiscoverReferences();
            ObjectName columnName = null;
            foreach (var cv in columnNames) {
                if (columnName != null && !cv.Equals(columnName))
                    throw new InvalidOperationException("Range plan does not contain common column.");

                columnName = cv;
            }

            // Find the variable field in the table.
            var col = t.IndexOfColumn(columnName);
            if (col == -1)
                throw new InvalidOperationException("Could not find column reference in table: " + columnName);

            var field = t.TableInfo[col];

            // Calculate the range
            var range = new IndexRangeSet();
            var calculator = new RangeSetCalculator(context, field, range);
            range = calculator.Calculate(exp);

            // Select the range from the table
            var ranges = range.ToArray();
            return t.SelectRange(columnName, ranges);
        }
Пример #2
0
        public static IEnumerable<int> SelectRows(this ITable table, int column, SqlExpressionType op, DataObject value)
        {
            // If the cell is of an incompatible type, return no results,
            var colType = table.TableInfo[column].ColumnType;
            if (!value.Type.IsComparable(colType)) {
                // Types not comparable, so return 0
                return new List<int>(0);
            }

            // Get the selectable scheme for this column
            var index = table.GetIndex(column);

            // If the operator is a standard operator, use the interned SelectableScheme
            // methods.
            if (op == SqlExpressionType.Equal)
                return index.SelectEqual(value);
            if (op == SqlExpressionType.NotEqual)
                return index.SelectNotEqual(value);
            if (op == SqlExpressionType.GreaterThan)
                return index.SelectGreater(value);
            if (op == SqlExpressionType.SmallerThan)
                return index.SelectLess(value);
            if (op == SqlExpressionType.GreaterOrEqualThan)
                return index.SelectGreaterOrEqual(value);
            if (op == SqlExpressionType.SmallerOrEqualThan)
                return index.SelectLessOrEqual(value);

            // If it's not a standard operator (such as IS, NOT IS, etc) we generate the
            // range set especially.
            var rangeSet = new IndexRangeSet();
            rangeSet = rangeSet.Intersect(op, value);
            return index.SelectRange(rangeSet.ToArray());
        }