1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Licensed Materials - Property of IBM
- * IBM Business Analytics (C) Copyright IBM Corp. 2019, 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['underscore', './VIPRDataPoint'], function (_, VIPRDataPoint) {
- // implements IDataPointIterator
- var VIPRDataPointIterator = function () {
- function VIPRDataPointIterator(dataset, context) {
- _classCallCheck(this, VIPRDataPointIterator);
- this.dataPointIndex = -1;
- this.queryResult = dataset.queryResult;
- this.dataset = dataset;
- this.dataItemInfo = this._getDataItemInfo();
- //viprDataPoints is a map that matches the lifecycle of the VIPRDataset.
- //It stores backing datapoint objects that the vipr IDataPoint objects use for their API.
- //This is needed to support decorating the IDataPoints.
- this.viprDataPoints = this.dataset.viprDataPoints;
- this.context = context;
- }
- VIPRDataPointIterator.prototype.nextValue = function nextValue() {
- if (++this.dataPointIndex < this.queryResult.getRowCount()) {
- var thisdatapoint = this.viprDataPoints[this.dataPointIndex];
- //No IDatapoint exists for this key yet....create an object and create the API with asIDataPoint.
- if (!thisdatapoint) {
- thisdatapoint = new VIPRDataPoint(this.dataPointIndex, this.dataset, this.dataItemInfo, this.context);
- this.viprDataPoints[this.dataPointIndex] = thisdatapoint;
- }
- return thisdatapoint;
- }
- return null;
- };
- VIPRDataPointIterator.prototype.getTupleItems = function getTupleItems() {
- return this.viprDataPoints[this.dataPointIndex].getTupleItems();
- };
- //Cache information about the dataItems to avoid
- VIPRDataPointIterator.prototype._getDataItemInfo = function _getDataItemInfo() {
- var _this = this;
- var dataItemInfo = {
- isLatLong: {},
- formatter: {}
- };
- this.dataset.dataItems.forEach(function (dataItem, resultItemIndex) {
- var slotDef = _this.dataset.slots[resultItemIndex] && _this.dataset.slots[resultItemIndex].getDefinition();
- var subType = slotDef && slotDef.getSubType();
- if (subType === 'longitude' || subType === 'latitude') {
- dataItemInfo.isLatLong[resultItemIndex] = true;
- }
- if (dataItem.getFormatter) {
- dataItemInfo.formatter[resultItemIndex] = dataItem.getFormatter && dataItem.getFormatter();
- }
- });
- return dataItemInfo;
- };
- return VIPRDataPointIterator;
- }();
- return VIPRDataPointIterator;
- });
- //# sourceMappingURL=VIPRDataPointIterator.js.map
|