//-----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation.
//
//-----------------------------------------------------------------------
namespace Microsoft.Isam.Esent.Interop
{
///
/// Enumerator that can intersect indexes and return the intersected bookmarks.
///
internal sealed class IntersectIndexesEnumerator : TableEnumerator
{
///
/// The ranges to intersect.
///
private readonly JET_INDEXRANGE[] ranges;
///
/// The recordlist containing the result of the intersection.
///
private JET_RECORDLIST recordlist;
///
/// Initializes a new instance of the class.
///
///
/// The session to use.
///
///
/// The ranges to intersect.
///
public IntersectIndexesEnumerator(JET_SESID sesid, JET_INDEXRANGE[] ranges) : base(sesid)
{
this.ranges = ranges;
}
///
/// Open the table to be enumerated. This should set .
///
protected override void OpenTable()
{
Api.JetIntersectIndexes(this.Sesid, this.ranges, this.ranges.Length, out this.recordlist, IntersectIndexesGrbit.None);
this.TableidToEnumerate = this.recordlist.tableid;
}
///
/// Gets the entry the cursor is currently positioned on.
///
/// The entry the cursor is currently positioned on.
protected override byte[] GetCurrent()
{
return Api.RetrieveColumn(this.Sesid, this.TableidToEnumerate, this.recordlist.columnidBookmark);
}
}
}