本文整理匯總了TypeScript中plywood.AttributeInfo.fromJS方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AttributeInfo.fromJS方法的具體用法?TypeScript AttributeInfo.fromJS怎麽用?TypeScript AttributeInfo.fromJS使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類plywood.AttributeInfo
的用法示例。
在下文中一共展示了AttributeInfo.fromJS方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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"
}
]);
});
示例2: 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([]);
});
示例3:
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;
});
示例4: it
it('works with theta', () => {
var attribute = AttributeInfo.fromJS({
"name": "page_theta",
"special": "theta",
"type": "STRING"
});
var measures = Measure.measuresFromAttributeInfo(attribute).map((m => m.toJS()));
expect(measures).to.deep.equal([
{
"name": "page_theta",
"title": "Page Theta",
"formula": "$main.countDistinct($page_theta)"
}
]);
});
示例5: it
it("works in basic case (no count)", () => {
var dataSourceStub = DataSource.fromJS({
name: 'wiki',
title: 'Wiki',
engine: 'druid',
source: 'wiki',
subsetFilter: null,
introspection: 'autofill-all',
defaultTimezone: 'Etc/UTC',
defaultFilter: { op: 'literal', value: true },
defaultPinnedDimensions: [],
refreshRule: {
refresh: "PT1M",
rule: "fixed"
}
});
var attributes = [
AttributeInfo.fromJS({ name: '__time', type: 'TIME' }),
AttributeInfo.fromJS({ name: 'page', type: 'STRING' }),
AttributeInfo.fromJS({ name: 'added', type: 'NUMBER' }),
AttributeInfo.fromJS({ name: 'unique_user', special: 'unique' })
];
expect(dataSourceStub.setAttributes(attributes).toJS()).to.deep.equal(
{
"name": "wiki",
"title": "Wiki",
"engine": "druid",
"source": "wiki",
"refreshRule": {
"refresh": "PT1M",
"rule": "fixed"
},
"subsetFilter": null,
"defaultDuration": "P1D",
"defaultFilter": { "op": "literal", "value": true },
"defaultPinnedDimensions": [],
"defaultSortMeasure": "added",
"defaultTimezone": "Etc/UTC",
"introspection": "no-autofill",
"timeAttribute": '__time',
"attributes": [
{ name: '__time', type: 'TIME' },
{ name: 'page', type: 'STRING' },
{ name: 'added', type: 'NUMBER' },
{ name: 'unique_user', special: 'unique', "type": "STRING" }
],
"dimensions": [
{
"expression": {
"name": "__time",
"op": "ref"
},
"kind": "time",
"name": "__time",
"title": "Time"
},
{
"expression": {
"name": "page",
"op": "ref"
},
"kind": "string",
"name": "page",
"title": "Page"
}
],
"measures": [
{
"expression": {
"action": {
"action": "sum",
"expression": {
"name": "added",
"op": "ref"
}
},
"expression": {
"name": "main",
"op": "ref"
},
"op": "chain"
},
"name": "added",
"title": "Added"
},
{
"expression": {
"action": {
"action": "countDistinct",
"expression": {
"name": "unique_user",
"op": "ref"
}
},
"expression": {
"name": "main",
"op": "ref"
},
//.........這裏部分代碼省略.........