Beispiel #1
0
        protected virtual void SetupIndexes(Type indexType)
        {
            indexes = new TableIndex[TableInfo.Columns.Count];
            for (int i = 0; i < TableInfo.Columns.Count; i++)
            {
                var columnName = TableInfo.Columns[i].ColumnName;
                var indexInfo  = new IndexInfo($"#COLIDX_{i}", TableInfo.TableName, columnName);

                if (indexType == typeof(BlindSearchIndex))
                {
                    indexes[i] = new BlindSearchIndex(indexInfo, this);
                }
                else if (indexType == typeof(InsertSearchIndex))
                {
                    indexes[i] = new InsertSearchIndex(indexInfo, this);
                }
                else
                {
                    var index = Activator.CreateInstance(indexType, indexInfo, this) as TableIndex;
                    if (index == null)
                    {
                        throw new InvalidOperationException();
                    }

                    indexes[i] = index;
                }
            }
        }
Beispiel #2
0
        protected virtual void SetupIndexes(Type indexType)
        {
            indexes = new ColumnIndex[ColumnCount];
            for (int i = 0; i < ColumnCount; i++)
            {
                if (indexType == typeof(BlindSearchIndex))
                {
                    indexes[i] = new BlindSearchIndex(this, i);
                }
                else if (indexType == typeof(InsertSearchIndex))
                {
                    indexes[i] = new InsertSearchIndex(this, i);
                }
                else
                {
                    var index = Activator.CreateInstance(indexType, this, i) as ColumnIndex;
                    if (index == null)
                    {
                        throw new InvalidOperationException();
                    }

                    indexes[i] = index;
                }
            }
        }
Beispiel #3
0
        protected override TableIndex GetColumnIndex(int column, int originalColumn, ITable ancestor)
        {
            // First check if the given SelectableScheme is in the column_scheme array
            var scheme = Indexes[column];

            if (scheme != null)
            {
                if (ancestor == this)
                {
                    return(scheme);
                }

                return(scheme.Subset(ancestor, originalColumn));
            }

            // If it isn't then we need to calculate it
            TableIndex index;

            // Optimization: The table may be naturally ordered by a column.  If it
            // is we don't try to generate an ordered set.
            if (SortColumn != -1 &&
                SortColumn == column)
            {
                var columnName = JoinedTableInfo.Columns[column].ColumnName;
                var indexInfo  = new IndexInfo($"#COLIDX[{column}]", TableInfo.TableName, columnName);
                index = new InsertSearchIndex(indexInfo, this, CalculateTableRows());

                Indexes[column] = index;
                if (ancestor != this)
                {
                    index = index.Subset(ancestor, originalColumn);
                }
            }
            else
            {
                // Otherwise we must generate the ordered set from the information in
                // a parent index.
                var parentTable = Tables[JoinedTableInfo.GetTableOffset(column)];
                index = parentTable.GetColumnIndex(JoinedTableInfo.GetColumnOffset(column), originalColumn, ancestor);
                if (ancestor == this)
                {
                    Indexes[column] = index;
                }
            }

            return(index);
        }
Beispiel #4
0
        protected override ColumnIndex GetIndex(int column, int originalColumn, ITable table)
        {
            // First check if the given SelectableScheme is in the column_scheme array
            var scheme = indexes[column];

            if (scheme != null)
            {
                if (table == this)
                {
                    return(scheme);
                }

                return(scheme.GetSubset(table, originalColumn));
            }

            // If it isn't then we need to calculate it
            ColumnIndex index;

            // Optimization: The table may be naturally ordered by a column.  If it
            // is we don't try to generate an ordered set.
            if (SortColumn != -1 &&
                SortColumn == column)
            {
                var isop = new InsertSearchIndex(this, column, CalculateRowReferenceList());
                isop.RecordUid  = false;
                index           = isop;
                indexes[column] = index;
                if (table != this)
                {
                    index = index.GetSubset(table, originalColumn);
                }
            }
            else
            {
                // Otherwise we must generate the ordered set from the information in
                // a parent index.
                var parentTable = referenceList[columnTable[column]];
                index = parentTable.GetIndex(columnFilter[column], originalColumn, table);
                if (table == this)
                {
                    indexes[column] = index;
                }
            }

            return(index);
        }
Beispiel #5
0
        protected override ColumnIndex GetIndex(int column, int originalColumn, ITable table)
        {
            // First check if the given SelectableScheme is in the column_scheme array
            var scheme = indexes[column];
            if (scheme != null) {
                if (table == this)
                    return scheme;

                return scheme.GetSubset(table, originalColumn);
            }

            // If it isn't then we need to calculate it
            ColumnIndex index;

            // Optimization: The table may be naturally ordered by a column.  If it
            // is we don't try to generate an ordered set.
            if (SortColumn != -1 &&
                SortColumn == column) {
                var isop = new InsertSearchIndex(this, column, CalculateRowReferenceList());
                isop.RecordUid = false;
                index = isop;
                indexes[column] = index;
                if (table != this) {
                    index = index.GetSubset(table, originalColumn);
                }

            } else {
                // Otherwise we must generate the ordered set from the information in
                // a parent index.
                var parentTable = referenceList[columnTable[column]];
                index = parentTable.GetIndex(columnFilter[column], originalColumn, table);
                if (table == this) {
                    indexes[column] = index;
                }
            }

            return index;
        }
Beispiel #6
0
        protected virtual void SetupIndexes(Type indexType)
        {
            indexes = new ColumnIndex[ColumnCount];
            for (int i = 0; i < ColumnCount; i++) {
                if (indexType == typeof (BlindSearchIndex)) {
                    indexes[i] = new BlindSearchIndex(this, i);
                } else if (indexType == typeof (InsertSearchIndex)) {
                    indexes[i] = new InsertSearchIndex(this, i);
                } else {
                    var index = Activator.CreateInstance(indexType, this, i) as ColumnIndex;
                    if (index == null)
                        throw new InvalidOperationException();

                    indexes[i] = index;
                }
            }
        }