當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript plywood.AttributeInfo類代碼示例

本文整理匯總了TypeScript中plywood.AttributeInfo的典型用法代碼示例。如果您正苦於以下問題:TypeScript AttributeInfo類的具體用法?TypeScript AttributeInfo怎麽用?TypeScript AttributeInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AttributeInfo類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: it

    it('adds new dimensions', () => {
      var columns: any = [
        { "name": "__time", "type": "TIME" },
        { "name": "added", "makerAction": { "action": "sum", "expression": { "name": "added", "op": "ref" }}, "type": "NUMBER", "unsplitable": true },
        { "name": "count", "makerAction": { "action": "count"}, "type": "NUMBER", "unsplitable": true },
        { "name": "delta_hist", "special": "histogram", "type": "NUMBER" },
        { "name": "page", "type": "STRING" },
        { "name": "page_unique", "special": "unique", "type": "STRING" }
      ];

      var dataCube1 = dataCube.addAttributes(AttributeInfo.fromJSs(columns));

      expect(dataCube1.toJS().dimensions).to.deep.equal([
        {
          "kind": "time",
          "name": "__time",
          "title": "Time",
          "formula": "$__time"
        },
        {
          "kind": "string",
          "name": "page",
          "title": "Page",
          "formula": "$page"
        }
      ]);

      columns.push({ "name": "channel", "type": "STRING" });
      var dataCube2 = dataCube1.addAttributes(AttributeInfo.fromJSs(columns));

      expect(dataCube2.toJS().dimensions).to.deep.equal([
        {
          "kind": "time",
          "name": "__time",
          "title": "Time",
          "formula": "$__time"
        },
        {
          "kind": "string",
          "name": "page",
          "title": "Page",
          "formula": "$page"
        },
        {
          "kind": "string",
          "name": "channel",
          "title": "Channel",
          "formula": "$channel"
        }
      ]);

    });
開發者ID:djfwan,項目名稱:pivot,代碼行數:52,代碼來源:data-cube.mocha.ts

示例3: it

 it('works with max', () => {
   var attribute = AttributeInfo.fromJS({
     "name": "unique_page",
     "special": "unique",
     "type": "STRING"
   });
   var measures = Measure.measuresFromAttributeInfo(attribute).map((m => m.toJS()));
   expect(measures).to.deep.equal([
     {
       "expression": {
         "action": {
           "action": "countDistinct",
           "expression": {
             "name": "unique_page",
             "op": "ref"
           }
         },
         "expression": {
           "name": "main",
           "op": "ref"
         },
         "op": "chain"
       },
       "name": "unique_page",
       "title": "Unique Page"
     }
   ]);
 });
開發者ID:coconutpalm,項目名稱:pivot,代碼行數:28,代碼來源:measure.mocha.ts

示例4: it

 it('works with histogram', () => {
   var attribute = AttributeInfo.fromJS({
     "name": "delta_hist",
     "special": "histogram",
     "type": "NUMBER"
   });
   var measures = Measure.measuresFromAttributeInfo(attribute).map((m => m.toJS()));
   expect(measures).to.deep.equal([]);
 });
開發者ID:codeaudit,項目名稱:pivot,代碼行數:9,代碼來源:measure.mocha.ts

示例5: 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.override(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:coconutpalm,項目名稱:pivot,代碼行數:56,代碼來源:executor.ts

示例6: 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.override(attributes, dataSource.attributeOverrides);
  }

  return attributes;
}
開發者ID:coconutpalm,項目名稱:pivot,代碼行數:45,代碼來源:executor.ts

示例7:

 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:coconutpalm,項目名稱:pivot,代碼行數:13,代碼來源:executor.ts

示例8: it

 it('works with unique', () => {
   var attribute = AttributeInfo.fromJS({
     "name": "unique_page",
     "special": "unique",
     "type": "STRING"
   });
   var measures = Measure.measuresFromAttributeInfo(attribute).map((m => m.toJS()));
   expect(measures).to.deep.equal([
     {
       "name": "unique_page",
       "title": "Unique Page",
       "formula": "$main.countDistinct($unique_page)"
     }
   ]);
 });
開發者ID:djfwan,項目名稱:pivot,代碼行數:15,代碼來源:measure.mocha.ts


注:本文中的plywood.AttributeInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。