private Index(DataTable table, IndexField[] indexFields, System.Comparison <DataRow> comparison, DataViewRowState recordStates, IFilter rowFilter)
{
DataCommonEventSource.Log.Trace("<ds.Index.Index|API> {0}, table={1}, recordStates={2}",
ObjectID, (table != null) ? table.ObjectID : 0, recordStates);
Debug.Assert(indexFields != null);
Debug.Assert(null != table, "null table");
if ((recordStates &
(~(DataViewRowState.CurrentRows | DataViewRowState.OriginalRows))) != 0)
{
throw ExceptionBuilder.RecordStateRange();
}
_table = table;
_listeners = new Listeners <DataViewListener>(ObjectID, listener => null != listener);
_indexFields = indexFields;
_recordStates = recordStates;
_comparison = comparison;
DataColumnCollection columns = table.Columns;
_isSharable = (rowFilter == null) && (comparison == null); // a filter or comparison make an index unsharable
if (null != rowFilter)
{
_rowFilter = new WeakReference(rowFilter);
DataExpression expr = (rowFilter as DataExpression);
if (null != expr)
{
_hasRemoteAggregate = expr.HasRemoteAggregate();
}
}
InitRecords(rowFilter);
// do not AddRef in ctor, every caller should be responsible to AddRef it
// if caller does not AddRef, it is expected to be a one-time read operation because the index won't be maintained on writes
}