示例#1
0
// existing functionality, it calls the overlaod with fireEvent== true, so it still fires the event
        private int InsertRecord(int record, bool fireEvent)
        {
            Bid.Trace("<ds.Index.InsertRecord|INFO> %d#, record=%d, fireEvent=%d{bool}\n", ObjectID, record, fireEvent);

            // SQLBU 428961: Serious performance issue when creating DataView
            // this improves performance when the is no filter, like with the default view (creating before rows added)
            // we know can append when the new record is the last row in table, normal insertion pattern
            bool append = false;

            if ((0 == IndexFields.Length) && (null != table))
            {
                DataRow row = table.recordManager[record];
                append = (table.Rows.IndexOf(row) + 1 == table.Rows.Count);
            }
            int nodeId = records.InsertAt(-1, record, append);

            recordCount++;

            MaintainDataView(ListChangedType.ItemAdded, record, !fireEvent);

            if (fireEvent)
            {
                if (DoListChanged)
                {
                    OnListChanged(ListChangedType.ItemAdded, records.GetIndexByNode(nodeId));
                }
                return(0);
            }
            else
            {
                return(records.GetIndexByNode(nodeId));
            }
        }
示例#2
0
        // existing functionality, it calls the overlaod with fireEvent== true, so it still fires the event
        private int InsertRecord(int record, bool fireEvent)
        {
            DataCommonEventSource.Log.Trace("<ds.Index.InsertRecord|INFO> {0}, record={1}, fireEvent={2}", ObjectID, record, fireEvent);

            // this improves performance when the is no filter, like with the default view (creating before rows added)
            // we know can append when the new record is the last row in table, normal insertion pattern
            bool append = false;

            if ((0 == _indexFields.Length) && (null != _table))
            {
                DataRow row = _table._recordManager[record];
                append = (_table.Rows.IndexOf(row) + 1 == _table.Rows.Count);
            }
            int nodeId = _records.InsertAt(-1, record, append);

            _recordCount++;

            MaintainDataView(ListChangedType.ItemAdded, record, !fireEvent);

            if (fireEvent)
            {
                if (DoListChanged)
                {
                    OnListChanged(ListChangedType.ItemAdded, _records.GetIndexByNode(nodeId));
                }
                return(0);
            }
            else
            {
                return(_records.GetIndexByNode(nodeId));
            }
        }
示例#3
0
        private void InitRecords(IFilter filter)
        {
            DataViewRowState states = recordStates;

            // SQLBU 428961: Serious performance issue when creating DataView
            // this improves performance when the is no filter, like with the default view (creating after rows added)
            // we know the records are in the correct order, just append to end, duplicates not possible
            bool append = (0 == IndexFields.Length);

            records = new IndexTree(this);

            recordCount = 0;

            // SQLBU 428961: Serious performance issue when creating DataView
            // this improves performance by iterating of the index instead of computing record by index
            foreach (DataRow b in table.Rows)
            {
                int record = -1;
                if (b.oldRecord == b.newRecord)
                {
                    if ((int)(states & DataViewRowState.Unchanged) != 0)
                    {
                        record = b.oldRecord;
                    }
                }
                else if (b.oldRecord == -1)
                {
                    if ((int)(states & DataViewRowState.Added) != 0)
                    {
                        record = b.newRecord;
                    }
                }
                else if (b.newRecord == -1)
                {
                    if ((int)(states & DataViewRowState.Deleted) != 0)
                    {
                        record = b.oldRecord;
                    }
                }
                else
                {
                    if ((int)(states & DataViewRowState.ModifiedCurrent) != 0)
                    {
                        record = b.newRecord;
                    }
                    else if ((int)(states & DataViewRowState.ModifiedOriginal) != 0)
                    {
                        record = b.oldRecord;
                    }
                }
                if (record != -1 && AcceptRecord(record, filter))
                {
                    records.InsertAt(-1, record, append);
                    recordCount++;
                }
            }
        }