gpt4 book ai didi

olap - 当未选择强制尺寸时,我们如何使后处理器测量不显示数据?

转载 作者:行者123 更新时间:2023-12-01 01:12:03 37 4
gpt4 key购买 nike

我们不希望在未选择某些强制尺寸时执行后处理器。例如,我们有称为风险类型、敏感曲线、期限、货币 1 和显示货币的维度。我们还有称为 Rate.Move 的后处理措施 - 它实现了 doLeafEvaluation。

在我们的客户端中,

  1. 如果未选择敏感曲线,我们不想在风险类型为 RateRisk 时显示 Rate.Move
  2. 如果未选择货币 1,我们不想在风险类型为 BasisSwapRisk 时显示 Rate.Move

最佳答案

在后处理器内部,只有一种方法可以发现用户最初选择的维度和级别(最有可能在 MDX 查询中):您内省(introspection)后处理器评估的位置 .

这是一个小型后处理器示例(它设计用于在 ActivePivot 沙盒应用程序中运行)。后处理器定义了一个上下文维度,在这个例子中是时间维度。如果用户扩展了时间维度,则评估的位置将具有至少 2 的深度(深度 1 意味着仅为该维度选择了 AllMember)。然后,您可以根据该知识决定返回不同的度量或计算。

/*
* (C) Quartet FS 2010
* ALL RIGHTS RESERVED. This material is the CONFIDENTIAL and PROPRIETARY
* property of Quartet Financial Systems Limited. Any unauthorized use,
* reproduction or transfer of this material is strictly prohibited
*/
package com.quartetfs.pivot.sandbox.postprocessor.impl;

import java.util.Properties;

import com.quartetfs.biz.pivot.IActivePivot;
import com.quartetfs.biz.pivot.ILocation;
import com.quartetfs.biz.pivot.impl.Util;
import com.quartetfs.biz.pivot.postprocessing.impl.ABasicPostProcessor;
import com.quartetfs.fwk.QuartetException;
import com.quartetfs.fwk.QuartetExtendedPluginValue;

/**
*
* @author Quartet FS
*
*/
@QuartetExtendedPluginValue(
interfaceName = "com.quartetfs.biz.pivot.postprocessing.IPostProcessor",
key = ContextualPostProcessor.PLUGIN_TYPE
)
public class ContextualPostProcessor extends ABasicPostProcessor<Double> {

/** serialVersionUID */
private static final long serialVersionUID = 4484708084267009957L;

/** Plugin key */
static final String PLUGIN_TYPE = "CTX";

/** Ordinal of the time dimension */
protected int timeDimensionOrdinal = -1;

/** Constructor */
public ContextualPostProcessor(String name, IActivePivot pivot) {
super(name, pivot);
}

@Override
public String getType() { return PLUGIN_TYPE; }

@Override
public void init(Properties properties) throws QuartetException {
super.init(properties);

// Store the ordinal of the time dimension
timeDimensionOrdinal = Util.findDimension(pivot.getDimensions(), "TimeBucket");
}

@Override
protected Double doEvaluation(ILocation location, Object[] underlyingMeasures) throws QuartetException {
if(location.getLevelDepth(timeDimensionOrdinal - 1) > 1) {
return (Double) underlyingMeasures[0];
} else {
return (Double) underlyingMeasures[1];
}
}

}

以下是如何在立方体描述中声明后处理器:

    <measure name="ctx" isIntrospectionMeasure="false">

<!-- This post processor dynamically buckets an underlying measure -->
<!-- It works together with a dynamic bucket dimension. -->
<postProcessor pluginKey="CTX">
<properties>
<entry key="id" value="SUM" />
<entry key="underlyingMeasures" value="pv.SUM,pnl.SUM" />
</properties>
</postProcessor>
</measure>

关于olap - 当未选择强制尺寸时,我们如何使后处理器测量不显示数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13365792/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com