Java Apache波束中的伽马分布

Java Apache波束中的伽马分布,java,google-cloud-platform,apache-beam,Java,Google Cloud Platform,Apache Beam,我试图在ApacheBeam中实现Gamma分布。首先,我正在使用Apache beam的TextIO类读取一个CSV文件CSV文件: Pipeline p = Pipeline.create(); p.apply(TextIO.read().from("gs://path/to/file.csv")); 之后,我应用一个转换,该转换将解析CSV文件中的每一行并返回一个对象。这里只有我正在尝试执行Gamma分布操作: .apply(ParDo.of(new DoFn<String

我试图在ApacheBeam中实现Gamma分布。首先,我正在使用Apache beam的TextIO类读取一个CSV文件CSV文件:

Pipeline p = Pipeline.create();  
p.apply(TextIO.read().from("gs://path/to/file.csv"));  
之后,我应用一个转换,该转换将解析CSV文件中的每一行并返回一个对象。这里只有我正在尝试执行Gamma分布操作:

.apply(ParDo.of(new DoFn<String, Entity>() {
@ProcessElement
public void processElement(ProcessContext c) {
    String[] strArr = c.element().split(",");
    ClassxNorms xn = new ClassxNorms();
    xn.setDuration(Double.parseDouble(strArr[0]));
    xn.setAlpha(Double.parseDouble(strArr[1]));
    xn.setBeta(Double.parseDouble(strArr[2]));
    GammaDistribution gdValue = new GammaDistribution(Double.parseDouble(strArr[0]), Double.parseDouble(strArr[1]), Double.parseDouble(strArr[2]));
    System.out.println("gdValue : " + gdValue);
    c.output(xn);
}
}));
.apply(ParDo.of(new DoFn)(){
@过程元素
公共void processElement(ProcessContext c){
字符串[]strArr=c.element().split(“,”);
ClassxNorms xn=新的ClassxNorms();
xn.setDuration(Double.parseDouble(strArr[0]));
xn.setAlpha(Double.parseDouble(strArr[1]));
xn.setBeta(Double.parseDouble(strArr[2]));
GammaDistribution gdValue=新的GammaDistribution(Double.parseDouble(strArr[0])、Double.parseDouble(strArr[1])、Double.parseDouble(strArr[2]);
System.out.println(“gdValue:+gdValue”);
c、 输出(xn);
}
}));
我正在创建一个beam记录,下一步我将把beam记录转换成字符串,将最终输出写入Google存储:

PCollection<String> gs_output_final = xnorm_trig.apply(ParDo.of(new DoFn<BeamRecord, String>() {
                    private static final long serialVersionUID = 1L;
                    @ProcessElement
                    public void processElement(ProcessContext c) {
                        c.output(c.element().toString());
                        System.out.println(c.element().toString());
                    }
                })); 
   gs_output_final.apply(TextIO.write().to("gs://output/op_1/Q40test111"));  
PCollection gs\u output\u final=xnorm\u trig.apply(ParDo.of(new DoFn)(){
私有静态最终长serialVersionUID=1L;
@过程元素
公共void processElement(ProcessContext c){
c、 输出(c.element().toString());
System.out.println(c.element().toString());
}
})); 
gs_output_final.apply(TextIO.write().to)(“gs://output/op_1/Q40test111”);

我得到了输出,但是伽马分布操作没有得到实现。任何帮助都将不胜感激。

我能够在apache beam中实现gamma分发。以下是供参考的代码片段:

.apply(ParDo.of(new DoFn<String, ClassxNorms>() { 
    @ProcessElement
    public void processElement(ProcessContext c) throws ParseException {
      String[] strArr = c.element().split(",");
      ClassxNorms xn = new ClassxNorms();
      double sample = new GammaDistribution(Double.parseDouble(strArr[11]), Double.parseDouble(strArr[12])).cumulativeProbability(Double.parseDouble(strArr[6]));
      xn.setDuration(Double.parseDouble(strArr[6]));
      xn.setAlpha(Double.parseDouble(strArr[11]));
      xn.setBeta(Double.parseDouble(strArr[12]));
      xn.setVolume(Double.parseDouble(strArr[13]));
      xn.setSpend(Double.parseDouble(strArr[14]));
      xn.setEfficiency(Double.parseDouble(strArr[15]));
      xn.setXnorm(Double.parseDouble(strArr[16]));
      xn.setKey(strArr[17]);
      xn.setGamma(sample);
      c.output(xn);
    }
  }));
.apply(ParDo.of(new DoFn(){
@过程元素
public void processElement(ProcessContext c)引发ParseException异常{
字符串[]strArr=c.element().split(“,”);
ClassxNorms xn=新的ClassxNorms();
double sample=new GammaDistribution(double.parseDouble(strArr[11])、double.parseDouble(strArr[12])、累积概率(double.parseDouble(strArr[6]);
xn.setDuration(Double.parseDouble(strArr[6]));
xn.setAlpha(Double.parseDouble(strArr[11]);
xn.setBeta(Double.parseDouble(strArr[12]));
xn.setVolume(Double.parseDouble(strArr[13]));
xn.setSpend(Double.parseDouble(strArr[14]);
xn.setEfficiency(Double.parseDouble(strArr[15]));
setXnorm(Double.parseDouble(strArr[16]);
xn.设置键(strArr[17]);
xn.setGamma(样品);
c、 输出(xn);
}
}));

ClassxNorms在做什么?另外,您正在使用
gdValue
创建gamma分布,但是,我看不到您将其传递到下一步。注意:在谷歌云中,除非您使用记录器或direct runner,否则在数据流中运行时不会保留屏幕打印。