TODO: refactor this out into a data access layer
491288
public void populate(Result result) {
    // process job-level stats and properties
    NavigableMap<byte[], byte[]> infoValues = result.getFamilyMap(Constants.INFO_FAM_BYTES);

    this.jobId = ByteUtil.getValueAsString(JobHistoryKeys.KEYS_TO_BYTES
          .get(JobHistoryKeys.JOBID), infoValues);
    this.user = ByteUtil.getValueAsString(JobHistoryKeys.KEYS_TO_BYTES
          .get(JobHistoryKeys.USER), infoValues);
    this.jobName = ByteUtil.getValueAsString(JobHistoryKeys.KEYS_TO_BYTES
          .get(JobHistoryKeys.JOBNAME),infoValues);
    this.priority = ByteUtil.getValueAsString(JobHistoryKeys.KEYS_TO_BYTES
          .get(JobHistoryKeys.JOB_PRIORITY), infoValues);
    this.status = ByteUtil.getValueAsString(JobHistoryKeys.KEYS_TO_BYTES
          .get(JobHistoryKeys.JOB_STATUS), infoValues);
    this.hadoopVersion = getHadoopVersionFromResult(JobHistoryKeys.hadoopversion, infoValues);
    this.version = ByteUtil.getValueAsString(Constants.VERSION_COLUMN_BYTES, infoValues);
    this.cost = ByteUtil.getValueAsDouble(Constants.JOBCOST_BYTES, infoValues);

    // times
    this.submitTime = ByteUtil.getValueAsLong(JobHistoryKeys.KEYS_TO_BYTES
          .get(JobHistoryKeys.SUBMIT_TIME), infoValues);
    this.launchTime = ByteUtil.getValueAsLong(JobHistoryKeys.KEYS_TO_BYTES
          .get(JobHistoryKeys.LAUNCH_TIME), infoValues);
    this.finishTime = ByteUtil.getValueAsLong(JobHistoryKeys.KEYS_TO_BYTES
          .get(JobHistoryKeys.FINISH_TIME), infoValues);
    this.megabyteMillis = ByteUtil.getValueAsLong(Constants.MEGABYTEMILLIS_BYTES, infoValues);
    this.cost = ByteUtil.getValueAsDouble(Constants.JOBCOST_BYTES, infoValues);

    // task counts
    this.totalMaps =
        ByteUtil.getValueAsLong(JobHistoryKeys.KEYS_TO_BYTES.get(JobHistoryKeys.TOTAL_MAPS),
          infoValues);
    this.totalReduces =
        ByteUtil.getValueAsLong(JobHistoryKeys.KEYS_TO_BYTES.get(JobHistoryKeys.TOTAL_REDUCES),
          infoValues);
    this.finishedMaps =
        ByteUtil.getValueAsLong(JobHistoryKeys.KEYS_TO_BYTES.get(JobHistoryKeys.FINISHED_MAPS),
          infoValues);
    this.finishedReduces =
        ByteUtil.getValueAsLong(JobHistoryKeys.KEYS_TO_BYTES.get(JobHistoryKeys.FINISHED_REDUCES),
          infoValues);
    this.failedMaps =
        ByteUtil.getValueAsLong(JobHistoryKeys.KEYS_TO_BYTES.get(JobHistoryKeys.FAILED_MAPS),
          infoValues);
    this.failedReduces =
        ByteUtil.getValueAsLong(JobHistoryKeys.KEYS_TO_BYTES.get(JobHistoryKeys.FAILED_REDUCES),
          infoValues);

    this.config = JobHistoryService.parseConfiguration(infoValues);
    this.queue = this.config.get(Constants.HRAVEN_QUEUE);
    this.counters = JobHistoryService.parseCounters(Constants.COUNTER_COLUMN_PREFIX_BYTES,
        infoValues);
    this.mapCounters = JobHistoryService.parseCounters(Constants.MAP_COUNTER_COLUMN_PREFIX_BYTES,
        infoValues);
    this.reduceCounters = JobHistoryService.parseCounters(Constants.REDUCE_COUNTER_COLUMN_PREFIX_BYTES,
        infoValues);

    // populate stats from counters for this job based on
    // hadoop version
    if (this.hadoopVersion == HadoopVersion.TWO) {
      // map file bytes read
      this.mapFileBytesRead = getCounterValueAsLong(this.mapCounters, 
            Constants.FILESYSTEM_COUNTER_HADOOP2, Constants.FILES_BYTES_READ);

      // map file bytes written
      this.mapFileBytesWritten = getCounterValueAsLong(this.mapCounters,
            Constants.FILESYSTEM_COUNTER_HADOOP2, Constants.FILES_BYTES_WRITTEN);

      // reduce file bytes read
      this.reduceFileBytesRead = getCounterValueAsLong(this.reduceCounters,
            Constants.FILESYSTEM_COUNTER_HADOOP2, Constants.FILES_BYTES_READ);

      // hdfs bytes read
      this.hdfsBytesRead = getCounterValueAsLong(this.counters, Constants.FILESYSTEM_COUNTER_HADOOP2,
            Constants.HDFS_BYTES_READ);

      // hdfs bytes written
      this.hdfsBytesWritten = getCounterValueAsLong(this.counters, Constants.FILESYSTEM_COUNTER_HADOOP2,
            Constants.HDFS_BYTES_WRITTEN);

      // map slot millis
      this.mapSlotMillis = getCounterValueAsLong(this.counters, Constants.JOB_COUNTER_HADOOP2,
            Constants.SLOTS_MILLIS_MAPS);

      // reduce slot millis
      this.reduceSlotMillis = getCounterValueAsLong(this.counters, Constants.JOB_COUNTER_HADOOP2,
            Constants.SLOTS_MILLIS_REDUCES);

      // reduce shuffle bytes
      this.reduceShuffleBytes = getCounterValueAsLong(this.reduceCounters, Constants.TASK_COUNTER_HADOOP2,
            Constants.REDUCE_SHUFFLE_BYTES);
    } else { // presume it's hadoop1
      // map file bytes read
      this.mapFileBytesRead = getCounterValueAsLong(this.mapCounters, Constants.FILESYSTEM_COUNTERS,
            Constants.FILES_BYTES_READ);

      // map file bytes written
      this.mapFileBytesWritten = getCounterValueAsLong(this.mapCounters, Constants.FILESYSTEM_COUNTERS,
            Constants.FILES_BYTES_WRITTEN);

      // reduce file bytes read
      this.reduceFileBytesRead = getCounterValueAsLong(this.reduceCounters, Constants.FILESYSTEM_COUNTERS,
            Constants.FILES_BYTES_READ);

      // hdfs bytes read
      this.hdfsBytesRead = getCounterValueAsLong(this.counters, Constants.FILESYSTEM_COUNTERS,
            Constants.HDFS_BYTES_READ);

      // hdfs bytes written
      this.hdfsBytesWritten = getCounterValueAsLong(this.counters, Constants.FILESYSTEM_COUNTERS,
            Constants.HDFS_BYTES_WRITTEN);

      // map slot millis
      this.mapSlotMillis = getCounterValueAsLong(this.counters, Constants.JOBINPROGRESS_COUNTER,
            Constants.SLOTS_MILLIS_MAPS);

      // reduce slot millis
      this.reduceSlotMillis = getCounterValueAsLong(this.counters, Constants.JOBINPROGRESS_COUNTER,
            Constants.SLOTS_MILLIS_REDUCES);

      // reduce shuffle bytes
      this.reduceShuffleBytes = getCounterValueAsLong(this.reduceCounters, Constants.TASK_COUNTER,
            Constants.REDUCE_SHUFFLE_BYTES);
    }
    // populate the task-level data
    // TODO: make sure to properly implement setTasks(...) before adding TaskDetails
    //populateTasks(result.getFamilyMap(Constants.TASK_FAM_BYTES));
  }
480512
private static String adjustData(String data, ClassNode type, DelegationMetadata dmd) {
        StringBuilder path = new StringBuilder();
        int i = 0;
        String[] propertyPath = data.split("\\.");
        while (dmd != null) {
            int strategy = dmd.getStrategy();
            ClassNode delegate = dmd.getType();
            dmd = dmd.getParent();
            switch (strategy) {
                case Closure.DELEGATE_FIRST:
                    if (!delegate.isDerivedFrom(CLOSURE_TYPE) && !delegate.isDerivedFrom(type)) {
                        path.append("owner"); // must be non-delegate case
                    } else {
                        path.append("delegate");
                    }
                    break;
                default:
                    if (i >= propertyPath.length) return data;
                    path.append(propertyPath[i]);
            }
            if (type.equals(delegate)) break;
            i++;
            if (dmd != null) path.append('.');
        }
        String result = path.toString();
        if (!result.isEmpty()) {
            return result;
        }
        return data;
    }
429052
private static AccessInfo getAccessInfo
        (Class desiredClass,
         int dataType, String dataTypeName, int columnSize, int decimalDigits)
    {
        if (!desiredClass.isPrimitive()) {
            TypeDesc desiredType = TypeDesc.forClass(desiredClass);
            if (desiredType.toPrimitiveType() != null) {
                desiredType = desiredType.toPrimitiveType();
                desiredClass = desiredType.toClass();
            }
        }

        if (desiredClass == Object.class) {
            return new AccessInfo("Object", Object.class);
        }

        Class actualClass;
        String suffix;

        switch (dataType) {
        default:
            return null;

        case BIT:
        case BOOLEAN:
            if (desiredClass == boolean.class) {
                actualClass = boolean.class;
                suffix = "Boolean";
            } else if (desiredClass == String.class) {
                actualClass = String.class;
                suffix = "String";
            } else {
                return null;
            }
            break;

        case TINYINT:
            if (desiredClass == byte.class) {
                actualClass = byte.class;
                suffix = "Byte";
            } else if (desiredClass == short.class) {
                actualClass = short.class;
                suffix = "Short";
            } else if (desiredClass == String.class) {
                actualClass = String.class;
                suffix = "String";
            } else {
                return null;
            }
            break;

        case SMALLINT:
            if (desiredClass == short.class) {
                actualClass = short.class;
                suffix = "Short";
            } else if (desiredClass == int.class) {
                actualClass = int.class;
                suffix = "Int";
            } else if (desiredClass == String.class) {
                actualClass = String.class;
                suffix = "String";
            } else {
                return null;
            }
            break;

        case INTEGER:
            if (desiredClass == int.class) {
                actualClass = int.class;
                suffix = "Int";
            } else if (desiredClass == long.class) {
                actualClass = long.class;
                suffix = "Long";
            } else if (desiredClass == String.class) {
                actualClass = String.class;
                suffix = "String";
            } else {
                return null;
            }
            break;

        case BIGINT:
            if (desiredClass == long.class) {
                actualClass = long.class;
                suffix = "Long";
            } else if (desiredClass == String.class) {
                actualClass = String.class;
                suffix = "String";
            } else {
                return null;
            }
            break;

        case REAL:
        case FLOAT:
        case DOUBLE:
            if (desiredClass == float.class) {
                actualClass = float.class;
                suffix = "Float";
            } else if (desiredClass == double.class) {
                actualClass = double.class;
                suffix = "Double";
            } else if (desiredClass == String.class) {
                actualClass = String.class;
                suffix = "String";
            } else {
                return null;
            }
            break;

        case NUMERIC:
        case DECIMAL:
            if (desiredClass == int.class) {
                if (decimalDigits <= 0) {
                    actualClass = int.class;
                    suffix = "Int";
                } else {
                    return null;
                }
            } else if (desiredClass == long.class) {
                if (decimalDigits <= 0) {
                    actualClass = long.class;
                    suffix = "Long";
                } else {
                    return null;
                }
            } else if (desiredClass == double.class) {
                actualClass = double.class;
                suffix = "Double";
            } else if (desiredClass == BigDecimal.class) {
                actualClass = BigDecimal.class;
                suffix = "BigDecimal";
            } else if (desiredClass == short.class) {
                if (decimalDigits <= 0) {
                    actualClass = short.class;
                    suffix = "Short";
                } else {
                    return null;
                }
            } else if (desiredClass == byte.class) {
                if (decimalDigits <= 0) {
                    actualClass = byte.class;
                    suffix = "Byte";
                } else {
                    return null;
                }
            } else if (desiredClass == String.class) {
                actualClass = String.class;
                suffix = "String";
            } else {
                return null;
            }
            break;

        case CHAR:
        case VARCHAR:
        case LONGVARCHAR:
            if (desiredClass == String.class) {
                actualClass = String.class;
                suffix = "String";
            } else if (desiredClass == char.class && columnSize == 1) {
                actualClass = String.class;
                suffix = "String";
            } else {
                return null;
            }
            break;

        case DATE:
            // Treat Date as a Timestamp since some databases make no
            // distinction.  The DateTimeAdapter can be used to provide
            // more control over the desired precision.
            if (desiredClass == java.sql.Date.class) {
                actualClass = java.sql.Timestamp.class;
                suffix = "Timestamp";
            } else {
                return null;
            }
            break;

        case TIME:
            if (desiredClass == java.sql.Time.class) {
                actualClass = java.sql.Time.class;
                suffix = "Time";
            } else {
                return null;
            }
            break;

        case TIMESTAMP:
            if (desiredClass == java.sql.Timestamp.class) {
                actualClass = java.sql.Timestamp.class;
                suffix = "Timestamp";
            } else {
                return null;
            }
            break;

        case BINARY:
        case VARBINARY:
        case LONGVARBINARY:
            if (desiredClass == byte[].class) {
                actualClass = byte[].class;
                suffix = "Bytes";
            } else {
                return null;
            }
            break;

        case BLOB:
            if (desiredClass == com.amazon.carbonado.lob.Blob.class) {
                actualClass = java.sql.Blob.class;
                suffix = "Blob";
            } else {
                return null;
            }
            break;

        case CLOB:
            if (desiredClass == com.amazon.carbonado.lob.Clob.class) {
                actualClass = java.sql.Clob.class;
                suffix = "Clob";
            } else {
                return null;
            }
            break;
        }

        return new AccessInfo(suffix, actualClass);
    }
423424
function () {
    return validateData.apply(this, [this.options,
        undefined].concat(Array.prototype.slice.call(arguments)));
  }
476123
function readData(datapath, layer, callback) {
  var features = [];

  var options = {
    delimiter: ',',
    columns: true
  };

  fs.createReadStream(path.join(datapath, 'meta', `wof-${layer}-latest.csv`))
    .pipe(parse(options))
    .pipe(loadJSON.create(datapath))
    .pipe(isActiveRecord.create())
    .pipe(filterOutNamelessRecords.create())
    .pipe(filterOutUnimportantRecords.create())
    .pipe(extractFields.create())
    .pipe(simplifyGeometry.create())
    .pipe(sink.obj(function(feature) {
      features.push(feature);
    }))
    .on('finish', function() {
      callback(features);
    });

}
504981
function getResult(attrNode, dataSourceName, context) {
    const resultId = attrNode.dataSources[dataSourceName].resultId;
    if (typeof resultId === 'undefined') {
        const attrPath = context.attrPath.length > 0 ? context.attrPath.join('.') : '{root}';
        throw new ImplementationError(`Result for "${attrPath}" (DataSource "${dataSourceName}") missing`);
    }
    return context.rawResults[resultId];
}
770903
function(data) {
            var paramArray = [],
                key, value;
        // TODO: use `object` module
            for (key in data) {
                value = data[key];
                key = ENCODE_URI_COMPONENT(key);
                paramArray.push((value === null) ? key : (key + '=' + ENCODE_URI_COMPONENT(value)));
            }
            console.log(NAME, '_toQueryString --> '+paramArray.join('&'));
            return paramArray.join('&');
        }
7301
function() {
            return {
                dataModel: this.dataModelObject.dataModel.name,
                baseClass: this.dataModelObject.name,
                rows: this.rows,
                columns: this.columns,
                cells: this.cells,
                filters: this.filters
            };
        }
967967
function(obj) {
        var context = {};
        var layers = obj.layers;
        if (obj.CLASS_NAME == "OpenLayers.Map") {
            var metadata = obj.metadata || {};
            context.size = obj.getSize();
            context.bounds = obj.getExtent();
            context.projection = obj.projection;
            context.title = obj.title;
            context.keywords = metadata.keywords;
            context["abstract"] = metadata["abstract"];
            context.logo = metadata.logo;
            context.descriptionURL = metadata.descriptionURL;
            context.contactInformation = metadata.contactInformation;
            context.maxExtent = obj.maxExtent;
        } else {
            // copy all obj properties except the "layers" property
            OpenLayers.Util.applyDefaults(context, obj);
            if (context.layers != undefined) {
                delete(context.layers);
            }
        }

        if (context.layersContext == undefined) {
            context.layersContext = [];
        }

        // let's convert layers into layersContext object (if any)
        if (layers != undefined && OpenLayers.Util.isArray(layers)) {
            for (var i=0, len=layers.length; i<len; i++) {
                var layer = layers[i];
                if (layer instanceof OpenLayers.Layer.WMS) {
                    context.layersContext.push(this.layerToContext(layer));
                }
            }
        }
        return context;
    }
1243416
void mapOut(String out, Object comp, String comp_out) {
        if (comp == ca.getComponent()) {
            throw new ComponentException("cannot connect 'Out' with itself for " + out);
        }
        ComponentAccess ac_dest = lookup(comp);
        FieldAccess destAccess = (FieldAccess) ac_dest.output(comp_out);
        FieldAccess srcAccess = (FieldAccess) ca.output(out);
        checkFA(destAccess, comp, comp_out);
        checkFA(srcAccess, ca.getComponent(), out);

        FieldContent data = srcAccess.getData();
        data.tagLeaf();
        data.tagOut();

        destAccess.setData(data);
        dataSet.add(data);

        if (log.isLoggable(Level.CONFIG)) {
            log.log(Level.CONFIG, String.format("@Out(%s) -> @Out(%s)", srcAccess, destAccess));
        }
//        ens.fireMapOut(srcAccess, destAccess);
    }
1198240
function dataLayer_init($element, thisID) {
      // Grab this Paragraph from our cached array
      var thisParagraph = allRows[thisID];
      // Construct object to push to datalayer, staring with Other Amount field
      var ecommerceObj = {
        'ecommerce': {
          'currencyCode': 'GBP',
          'impressions': [{
            id:'manual-entry',      
            name:'manual-entry',      
            price:0.00,       
            category: thisParagraph['cart_id'],
            position: 0,
            list: thisParagraph['client_id'] + '_' + thisID,
            dimenstion10: thisParagraph['giving_type'],
          }],
        }
      };

      /*  Construct obj to represent each moneybuy button
          use 1-index, not zero as it maps to our btn 'position' values */
      for (i = 1; i < thisParagraph['buttons'].length; i++) {

        var thisAmount = parseFloat(parseFloat(thisParagraph['buttons'][i]['amount']).toFixed(2));

        var thisObj = {
          id:'moneybuy-' + thisParagraph['buttons'][i]['amount'],
          name:'moneybuy-' + thisParagraph['buttons'][i]['amount'],
          price: thisAmount,
          brand: allRows[thisID]['giving_type'],
          category: thisParagraph['cart_id'],   
          position: thisParagraph['buttons'][i]['position'],
          list: thisParagraph['client_id'] + '_' + thisID,
          dimenstion10: thisParagraph['giving_type']
        };

        // Add this 'button' object to the impressions array
        ecommerceObj['ecommerce']['impressions'].push(thisObj);
      };

      // Push to the data layer
      dataLayer.push(ecommerceObj);

      // If we have a default 'active' button, store the position value
      var $activeBtn = $element.find('.select-amount-btn.active');

      if ($activeBtn.length > 0) {
        lastBtnPos = $activeBtn.data('position');
      }
    }
1253816
function(source, domap, thisp) {
		var result = {},
			mapping;
		this.each(source, function(key, value) {
			mapping = domap.call(thisp, key, value);
			if (mapping !== undefined) {
				result[key] = mapping;
			}
		});
		return result;
	}
1012499
function getDomain(data, accessor) {
      return data
        .map(function (item) {
          return accessor.call(this, item);
        })
        .filter(function (item, index, array) {
          return array.indexOf(item) === index;
        });
    }
279508
function(newData) {
          // we use a one-directional loop to avoid feedback with 3-way bindings
          // since set() is applied locally anyway, this is still performant
          var def = $wilddogUtils.defer();
          this.$ref().set($wilddogUtils.toJSON(newData), $wilddogUtils.makeNodeResolver(def));
          return def.promise;
        }
1352825
function(dataObj) {
        var queryList = [];

        _.each(dataObj, function(value, name) {
            if (!_.isString(value) && !_.isNumber(value)) {
                value = JSON.stringify(value);
            }
            value = encodeURIComponent(unescape(value));
            if (value) {
                queryList.push(name + '=' + value);
            }
        });

        return queryList.join('&');
    }
451170
function serialize (layersCollection, dataviewsCollection) {
  var analysisList = AnalysisService.getAnalysisList(layersCollection, dataviewsCollection);
  return _generateUniqueAnalysisList(analysisList);
}
587589
function getResultsList(dataList) {
  if (isObject(dataList)) {
    if (isArray(dataList)) {
      return dataList.map(function(v) {
        return v[0]; //v[0] contains full string
      });
    }
    else {
      /*
       * Example dataList:
       *
       * data: [{a: 10, b: ['dude', 'd', '', 'ude'], c:['dumb', 'd', '', 'umb']}, {a: 10, b: ['dude man', 'd', '', 'ude man'], c: null}]
       * searchInProps: ['b', 'c']
       */
      var tempDataList = clone(dataList);

      tempDataList.data = tempDataList.data.map(function(data) {
        tempDataList.searchInProps.forEach(function(key) {
          if (data[key]) data[key] = data[key][0];
        });
        return data;
      });
      return tempDataList;
    }
  }
  else throw new SyntaxError(messages.DataMustBeArrayOrObject);
}