Giter Site home page Giter Site logo

flinktutorial's People

Contributors

wushengran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flinktutorial's Issues

flink自定义udaf实现lag函数的问题,老师帮忙看一下

这是我的代码,不知道为什么就是不走accumulate方法,看老师的视频,自己写的求平均值的方法可以正常运行。请老师有时间帮忙看一下,谢谢!

 class PreviousAcc {
    var queue: util.LinkedList[Int] = _
  }

  class PreviousTemp extends AggregateFunction[Int, PreviousAcc] {

    override def getValue(accumulator: PreviousAcc): Int = {
      System.out.println("进入获取结果方法!!!")
      val i1 = accumulator.queue.size()
      System.out.println(i1)
      accumulator.queue.removeLast()
    }

    override def createAccumulator(): PreviousAcc = {
      System.out.println("进入创建方法!!!")
      val value = new PreviousAcc
      value.queue = new util.LinkedList[Int]()
      value
    }

    def accumulate(acc: PreviousAcc, value: Int, length: Int): Unit = {
      System.out.println("进入计算方法!!!")
      acc.queue.addFirst(value)
      val size = acc.queue.size
      if (size < length) {
        for (i <- size until (length + 1)) {
          acc.queue.add(0);
        }
      } else if (size > length) throw new RuntimeException("队列的大小出错了!!")
    }
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.