当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript AttributeInfo.applyOverrides方法代码示例

本文整理汇总了TypeScript中plywood.AttributeInfo.applyOverrides方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AttributeInfo.applyOverrides方法的具体用法?TypeScript AttributeInfo.applyOverrides怎么用?TypeScript AttributeInfo.applyOverrides使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plywood.AttributeInfo的用法示例。


在下文中一共展示了AttributeInfo.applyOverrides方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: deduceAttributes

/**
 * This function tries to deduce the structure of the dataSource based on the dimensions and measures defined within.
 * It should only be used when for some reason introspection if not available.
 * @param dataSource
 * @returns {Attributes}
 */
function deduceAttributes(dataSource: DataSource): Attributes {
  var attributeJSs: AttributeJSs = [];

  dataSource.dimensions.forEach((dimension) => {
    // ToDo: fix this.
    attributeJSs.push({ name: dimension.name, type: 'STRING' });
  });

  dataSource.measures.forEach((measure) => {
    var expression = measure.expression;
    var references = getReferences(expression);
    var countDistinctReferences = getCountDistinctReferences(expression);
    for (var reference of references) {
      if (reference === 'main') continue;
      if (countDistinctReferences.indexOf(reference) !== -1) {
        attributeJSs.push({ name: reference, special: 'unique' });
      } else {
        attributeJSs.push({ name: reference, type: 'NUMBER' });
      }
    }
  });

  var attributes = AttributeInfo.fromJSs(attributeJSs);
  if (dataSource.options['attributeOverrides']) {
    attributes = AttributeInfo.applyOverrides(attributes, dataSource.options['attributeOverrides']);
  }

  return attributes;
}
开发者ID:fortressll87,项目名称:implydata-pivot,代码行数:35,代码来源:executor.ts

示例2: externalFactory

export function externalFactory(dataSource: DataSource, druidRequester: Requester.PlywoodRequester<any>, timeout: number, introspectionStrategy: string): Q.Promise<External> {
  var countDistinctReferences: string[] = [];
  if (dataSource.measures) {
    countDistinctReferences = [].concat.apply([], dataSource.measures.toArray().map((measure) => {
      return getCountDistinctReferences(measure.expression);
    }));
  }

  var context = {
    timeout
  };

  if (dataSource.introspection === 'none') {
    return Q(new DruidExternal({
      suppress: true,
      dataSource: dataSource.source,
      timeAttribute: dataSource.timeAttribute.name,
      customAggregations: dataSource.options['customAggregations'],
      attributes: AttributeInfo.applyOverrides(deduceAttributes(dataSource), dataSource.attributeOverrides),
      introspectionStrategy,
      filter: dataSource.subsetFilter,
      context,
      requester: druidRequester
    }));
  } else {
    var introspectedExternalPromise = new DruidExternal({
      suppress: true,
      dataSource: dataSource.source,
      timeAttribute: dataSource.timeAttribute.name,
      attributeOverrides: dataSource.attributeOverrides,
      customAggregations: dataSource.options['customAggregations'],
      introspectionStrategy,
      filter: dataSource.subsetFilter,
      context,
      requester: druidRequester
    }).introspect();

    if (!countDistinctReferences) {
      return introspectedExternalPromise;
    }

    return introspectedExternalPromise.then((introspectedExternal) => {
      var attributes = introspectedExternal.attributes;
      for (var attribute of attributes) {
        // This is a metric that should really be a HLL
        if (attribute.type === 'NUMBER' && countDistinctReferences.indexOf(attribute.name) !== -1) {
          introspectedExternal = introspectedExternal.updateAttribute(AttributeInfo.fromJS({
            name: attribute.name,
            special: 'unique'
          }));
        }
      }
      return introspectedExternal;
    });
  }
}
开发者ID:dlutls,项目名称:pivot,代码行数:56,代码来源:executor.ts

示例3: deduceAttributes

/**
 * This function tries to deduce the structure of the dataSource based on the dimensions and measures defined within.
 * It should only be used when, for some reason, introspection if not available.
 * @param dataSource
 * @returns {Attributes}
 */
function deduceAttributes(dataSource: DataSource): Attributes {
  var attributeJSs: AttributeJSs = [];

  var timeAttribute = dataSource.timeAttribute;
  if (timeAttribute) {
    attributeJSs.push({ name: timeAttribute.name, type: 'TIME' });
  }

  dataSource.dimensions.forEach((dimension) => {
    var expression = dimension.expression;
    if (expression.equals(timeAttribute)) return;
    var references = getReferences(expression);
    for (var reference of references) {
      if (reference === 'main') continue;
      attributeJSs.push({ name: reference, type: 'STRING' });
    }
  });

  dataSource.measures.forEach((measure) => {
    var expression = measure.expression;
    var references = getReferences(expression);
    var countDistinctReferences = getCountDistinctReferences(expression);
    for (var reference of references) {
      if (reference === 'main') continue;
      if (countDistinctReferences.indexOf(reference) !== -1) {
        attributeJSs.push({ name: reference, special: 'unique' });
      } else {
        attributeJSs.push({ name: reference, type: 'NUMBER' });
      }
    }
  });

  var attributes = AttributeInfo.fromJSs(attributeJSs);
  if (dataSource.attributeOverrides.length) {
    attributes = AttributeInfo.applyOverrides(attributes, dataSource.attributeOverrides);
  }

  return attributes;
}
开发者ID:dlutls,项目名称:pivot,代码行数:45,代码来源:executor.ts


注:本文中的plywood.AttributeInfo.applyOverrides方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。