Cell Navigation in a Dataset
After the structure of the axes is known, the application needs to navigate the cells in the dataset. Navigation is the process of traversing through the various cells in the dataset and zeroing in on the set of cells that you want. In order to navigate through a dataset, there must be a way to refer to cells that determines their relative position in the dataset. This leads to the following three modes of navigation:
-
Navigating by cell ordinal. In this method, you assign each cell a unique number. To navigate, the application simply refers to the ordinal number of the cell it wants (or the starting cell of the set of cells it wants). In other words, the application says, “Go to cell number x and fetch...”
-
Navigating by axes coordinates. In this method, you identify a cell by giving the tuple on each axis at the intersection of which the cell lies. To navigate, the application gives a set of coordinates that identify the cells it is interested in. In other words, the application says “Give me the cell at the intersection of the coordinates (5, 3, 2)...” (5th coordinate on x-axis, 3rd coordinate on y-axis and 2nd coordinate on the z-axis).
-
Navigating by member names. This is a variation on the previous method. You identify a cell by a set of members. Each tuple, which is formed of members, is broken down into its constituent parts and this is used for identification of the desired cells. In other words, the application says, “Give me data value for Sales in USA for 1992, Quarter1 for all Salesreps.” In a sense, this is the “natural” way to think about the cells in a dataset.
OLE DB for OLAP allows for all these three methods of navigation as follows:
-
For navigating by cell ordinal, each coordinate (tuple) on an axis is assigned a number starting from zero and increasing as you move along the axis. This number is called the tuple ordinal. OLE DB for OLAP also defines an algorithm for assigning a unique ordinal to each cell in a dataset, given the tuple ordinals of its coordinates. The method IMDDataset::GetCellData takes as arguments the cell ordinals of the starting cell and the ending cell of the desired range. It then returns those cells contained in the slice of the dataset bounded by the starting cell at its upper left corner and the ending cell at its lower right corner.
-
For navigating by axes coordinates, OLE DB for OLAP defines the method IMDFind::FindTuple, which takes in a set of members (which form the constituents of the desired tuple) and returns the tuple ordinal. The application can make multiple calls to this method to find the tuple ordinal of each coordinate, use the algorithm in OLE DB for OLAP to derive the cell ordinal, and call IMDDataset::GetCellData. The tuple ordinal for each tuple on an axis is also available in the axis rowset.
-
For navigating by member names, OLE DB for OLAP defines the method IMDFind::FindCell, which takes an array of members, a starting cell ordinal, and returns the corresponding cell ordinal. You can now use the IMDDataset::GetCellData method.
For more information on the formula used to derive a cell ordinal given its tuple ordinals, see the description of IMDDataset::GetCellData in Chapter 4.