private int CompareRecords(int record1, int record2) { int length = this.indexDesc.Length; for (int i = 0; i < length; i++) { int indexDesc = this.indexDesc[i]; int num3 = this.table.Columns[DataKey.ColumnOrder(indexDesc)].Compare(record1, record2); if (num3 != 0) { if (DataKey.SortDecending(indexDesc)) { num3 = -num3; } return(num3); } } long recordState = (this.table.recordManager[record1] == null) ? 0L : this.table.recordManager[record1].rowID; long num = (this.table.recordManager[record2] == null) ? 0L : this.table.recordManager[record2].rowID; int num5 = (recordState < num) ? -1 : ((num < recordState) ? 1 : 0); if (((num5 == 0) && (record1 != record2)) && ((this.table.recordManager[record1] != null) && (this.table.recordManager[record2] != null))) { recordState = (long)this.table.recordManager[record1].GetRecordState(record1); num = (long)this.table.recordManager[record2].GetRecordState(record2); num5 = (recordState < num) ? -1 : ((num < recordState) ? 1 : 0); } return(num5); }
private int CompareRecordToKey(int record1, object val) { Debug.Assert(indexDesc.Length == 1, "Invalid ussage: CompareRecordToKey"); Int32 d = indexDesc[0]; int c = table.Columns[DataKey.ColumnOrder(d)].CompareToValue(record1, val); if (c != 0) { if (DataKey.SortDecending(d)) { c = -c; } return(c); } return(0); }
private int CompareRecordToKey(int record1, object[] vals) { for (int i = 0; i < indexDesc.Length; i++) { Int32 d = indexDesc[i]; int c = table.Columns[DataKey.ColumnOrder(d)].CompareToValue(record1, vals[i]); if (c != 0) { if (DataKey.SortDecending(d)) { c = -c; } return(c); } } return(0); }
private int Evaluate(int record) { DataRow row = table.recordManager[record]; if (row == null) { return(0); } // UNDONE: perf switch to (row, version) internaly DataRowVersion version = DataRowVersion.Default; if (row.oldRecord == record) { version = DataRowVersion.Original; } else if (row.newRecord == record) { version = DataRowVersion.Current; } else if (row.tempRecord == record) { version = DataRowVersion.Proposed; } int[] id = index.IndexDesc; for (int i = 0; i < matchedCandidates; i++) { Debug.Assert(candidateColumns[DataKey.ColumnOrder(id[i])] != null, "How come this is not a candidate column"); Debug.Assert(candidateColumns[DataKey.ColumnOrder(id[i])].expr != null, "How come there is no associated expression"); int c = Eval(candidateColumns[DataKey.ColumnOrder(id[i])].expr, row, version); if (c != 0) { return(DataKey.SortDecending(id[i]) ? -c : c); } } return(0); }
private void CreateIndex() { if (this.index == null) { if (this.nCandidates == 0) { this.index = new Index(this.table, this.IndexFields, this.recordStates, null); this.index.AddRef(); } else { int num; int length = this.candidateColumns.Length; int num5 = this.indexDesc.Length; bool flag = true; for (num = 0; num < length; num++) { if ((this.candidateColumns[num] != null) && !this.candidateColumns[num].equalsOperator) { flag = false; break; } } int num2 = 0; for (num = 0; num < num5; num++) { ColumnInfo info4 = this.candidateColumns[DataKey.ColumnOrder(this.indexDesc[num])]; if (info4 != null) { info4.flag = true; num2++; } } int num7 = num5 - num2; int[] ndexDesc = new int[this.nCandidates + num7]; if (flag) { num2 = 0; for (num = 0; num < length; num++) { if (this.candidateColumns[num] != null) { ndexDesc[num2++] = num; this.candidateColumns[num].flag = false; } } for (num = 0; num < num5; num++) { ColumnInfo info = this.candidateColumns[DataKey.ColumnOrder(this.indexDesc[num])]; if ((info == null) || info.flag) { ndexDesc[num2++] = this.indexDesc[num]; if (info != null) { info.flag = false; } } } for (num = 0; num < this.candidateColumns.Length; num++) { if (this.candidateColumns[num] != null) { this.candidateColumns[num].flag = false; } } IndexField[] zeroIndexField = DataTable.zeroIndexField; if (0 < ndexDesc.Length) { zeroIndexField = new IndexField[ndexDesc.Length]; for (int i = 0; i < ndexDesc.Length; i++) { DataColumn column2 = this.table.Columns[DataKey.ColumnOrder(ndexDesc[i])]; bool isDescending = DataKey.SortDecending(ndexDesc[i]); zeroIndexField[i] = new IndexField(column2, isDescending); } } this.index = new Index(this.table, ndexDesc, zeroIndexField, this.recordStates, null); if (!this.IsOperatorIn(this.expression)) { this.index.AddRef(); } this.matchedCandidates = this.nCandidates; } else { num = 0; while (num < num5) { ndexDesc[num] = this.indexDesc[num]; ColumnInfo info3 = this.candidateColumns[DataKey.ColumnOrder(this.indexDesc[num])]; if (info3 != null) { info3.flag = true; } num++; } num2 = num; for (num = 0; num < length; num++) { if (this.candidateColumns[num] != null) { if (!this.candidateColumns[num].flag) { ndexDesc[num2++] = num; } else { this.candidateColumns[num].flag = false; } } } IndexField[] indexFields = DataTable.zeroIndexField; if (0 < ndexDesc.Length) { indexFields = new IndexField[ndexDesc.Length]; for (int j = 0; j < ndexDesc.Length; j++) { DataColumn column = this.table.Columns[DataKey.ColumnOrder(ndexDesc[j])]; bool flag2 = DataKey.SortDecending(ndexDesc[j]); indexFields[j] = new IndexField(column, flag2); } } this.index = new Index(this.table, ndexDesc, indexFields, this.recordStates, null); this.matchedCandidates = 0; if (this.linearExpression != this.expression) { int[] indexDesc = this.index.IndexDesc; while (this.matchedCandidates < num2) { ColumnInfo info2 = this.candidateColumns[DataKey.ColumnOrder(indexDesc[this.matchedCandidates])]; if ((info2 == null) || (info2.expr == null)) { break; } this.matchedCandidates++; if (!info2.equalsOperator) { break; } } } for (num = 0; num < this.candidateColumns.Length; num++) { if (this.candidateColumns[num] != null) { this.candidateColumns[num].flag = false; } } } } } }