text:
package org.teavm.interop.c;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface Include {
    String value();

    boolean isSystem() default true;
}

redpajama_set_name: RedPajamaGithub


text:
package google;

import org.junit.Test;

public class GoogleAuthenticatorTest {

    @Test
    public void test() {
        String secret = GoogleAuthenticator2.genSecret();
        System.out.println(secret);

        System.out.println(GoogleAuthenticator2.authcode("613522", "I5OFMYTTR3F2GUNY"));
    }

    //当测试authTest时候,把genSecretTest生成的secret值赋值给它
    private static String secret = "R2Q3S52RNXBTFTOM";

    @Test
    public void genSecretTest() {// 生成密钥
        secret = GoogleAuthenticator.generateSecretKey();
        // 把这个qrcode生成二维码,用google身份验证器扫描二维码就能添加成功
        String qrcode = GoogleAuthenticator.getQRBarcode("2816661736@qq.com", secret);
        System.out.println("qrcode:" + qrcode + ",key:" + secret);
    }

    /**
     * 对app的随机生成的code,输入并验证
     */
    @Test
    public void verifyTest() {
        long code = 630725;
        long t = System.currentTimeMillis();
        GoogleAuthenticator ga = new GoogleAuthenticator();
        ga.setWindowSize(5);
        boolean r = ga.check_code(secret, code, t);
        System.out.println("检查code是否正确?" + r);
    }
}


text:
require 'test_helper'

class PollTest < ActiveSupport::TestCase
  # test "the truth" do
  #   assert true
  # end
end


text:
package org.apache.flink.table.planner.runtime.harness

import org.apache.flink.api.common.time.Time
import org.apache.flink.api.scala._
import org.apache.flink.streaming.api.TimeCharacteristic
import org.apache.flink.streaming.runtime.streamrecord.StreamRecord
import org.apache.flink.table.api.scala._
import org.apache.flink.table.api.scala.internal.StreamTableEnvironmentImpl
import org.apache.flink.table.api.{EnvironmentSettings, Types}
import org.apache.flink.table.planner.runtime.utils.StreamingWithStateTestBase.StateBackendMode
import org.apache.flink.table.runtime.util.RowDataHarnessAssertor
import org.apache.flink.table.runtime.util.StreamRecordUtils.{binaryrow, row}
import org.apache.flink.types.Row
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.{Before, Test}

import java.lang.{Long => JLong}
import java.util.concurrent.ConcurrentLinkedQueue

import scala.collection.mutable

@RunWith(classOf[Parameterized])
class OverWindowHarnessTest(mode: StateBackendMode) extends HarnessTestBase(mode) {

  @Before
  override def before(): Unit = {
    super.before()
    val setting = EnvironmentSettings.newInstance().inStreamingMode().build()
    val config = new TestTableConfig
    this.tEnv = StreamTableEnvironmentImpl.create(env, setting, config)
  }

  @Test
  def testProcTimeBoundedRowsOver(): Unit = {

    val data = new mutable.MutableList[(Long, String, Long)]
    val t = env.fromCollection(data).toTable(tEnv, 'currtime, 'b, 'c, 'proctime.proctime)
    tEnv.registerTable("T", t)

    val sql =
      """
        |SELECT currtime, b, c,
        | min(c) OVER
        |   (PARTITION BY b ORDER BY proctime ROWS BETWEEN 1 PRECEDING AND CURRENT ROW),
        | max(c) OVER
        |   (PARTITION BY b ORDER BY proctime ROWS BETWEEN 1 PRECEDING AND CURRENT ROW)
        |FROM T
      """.stripMargin
    val t1 = tEnv.sqlQuery(sql)

    tEnv.getConfig.setIdleStateRetentionTime(Time.seconds(2), Time.seconds(4))
    val testHarness = createHarnessTester(t1.toAppendStream[Row], "OverAggregate")
    val assertor = new RowDataHarnessAssertor(
      Array(Types.LONG, Types.STRING, Types.LONG, Types.LONG, Types.LONG, Types.LONG, Types.LONG))

    testHarness.open()

    // register cleanup timer with 3001
    testHarness.setProcessingTime(1)

    testHarness.processElement(new StreamRecord(
      binaryrow(1L: JLong, "aaa", 1L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(1L: JLong, "bbb", 10L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(1L: JLong, "aaa", 2L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(1L: JLong, "aaa", 3L: JLong, null)))

    // register cleanup timer with 4100
    testHarness.setProcessingTime(1100)
    testHarness.processElement(new StreamRecord(
      binaryrow(1L: JLong, "bbb", 20L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(1L: JLong, "aaa", 4L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(1L: JLong, "aaa", 5L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(1L: JLong, "aaa", 6L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(1L: JLong, "bbb", 30L: JLong, null)))

    // register cleanup timer with 6001
    testHarness.setProcessingTime(3001)
    testHarness.processElement(new StreamRecord(
      binaryrow(2L: JLong, "aaa", 7L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(2L: JLong, "aaa", 8L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(2L: JLong, "aaa", 9L: JLong, null)))

    // trigger cleanup timer and register cleanup timer with 9002
    testHarness.setProcessingTime(6002)
    testHarness.processElement(new StreamRecord(
      binaryrow(2L: JLong, "aaa", 10L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(2L: JLong, "bbb", 40L: JLong, null)))

    val result = testHarness.getOutput

    val expectedOutput = new ConcurrentLinkedQueue[Object]()

    expectedOutput.add(new StreamRecord(
      row(1L: JLong, "aaa", 1L: JLong, null, 1L: JLong, 1L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(1L: JLong, "bbb", 10L: JLong, null, 10L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(1L: JLong, "aaa", 2L: JLong, null, 1L: JLong, 2L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(1L: JLong, "aaa", 3L: JLong, null, 2L: JLong, 3L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(1L: JLong, "bbb", 20L: JLong, null, 10L: JLong, 20L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(1L: JLong, "aaa", 4L: JLong, null, 3L: JLong, 4L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(1L: JLong, "aaa", 5L: JLong, null, 4L: JLong, 5L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(1L: JLong, "aaa", 6L: JLong, null, 5L: JLong, 6L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(1L: JLong, "bbb", 30L: JLong, null, 20L: JLong, 30L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(2L: JLong, "aaa", 7L: JLong, null, 6L: JLong, 7L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(2L: JLong, "aaa", 8L: JLong, null, 7L: JLong, 8L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(2L: JLong, "aaa", 9L: JLong, null, 8L: JLong, 9L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(2L: JLong, "aaa", 10L: JLong, null, 9L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(2L: JLong, "bbb", 40L: JLong, null, 40L: JLong, 40L: JLong)))

    assertor.assertOutputEqualsSorted("result mismatch", expectedOutput, result)

    testHarness.close()
  }

  /**
    * NOTE: all elements at the same proc timestamp have the same value per key
    */
  @Test
  def testProcTimeBoundedRangeOver(): Unit = {

    val data = new mutable.MutableList[(Long, String, Long)]
    val t = env.fromCollection(data).toTable(tEnv, 'currtime, 'b, 'c, 'proctime.proctime)
    tEnv.registerTable("T", t)

    val sql =
      """
        |SELECT currtime, b, c,
        | min(c) OVER
        |   (PARTITION BY b ORDER BY proctime
        |   RANGE BETWEEN INTERVAL '4' SECOND PRECEDING AND CURRENT ROW),
        | max(c) OVER
        |   (PARTITION BY b ORDER BY proctime
        |   RANGE BETWEEN INTERVAL '4' SECOND PRECEDING AND CURRENT ROW)
        |FROM T
      """.stripMargin
    val t1 = tEnv.sqlQuery(sql)

    tEnv.getConfig.setIdleStateRetentionTime(Time.seconds(2), Time.seconds(4))
    val testHarness = createHarnessTester(t1.toAppendStream[Row], "OverAggregate")
    val assertor = new RowDataHarnessAssertor(
      Array(Types.LONG, Types.STRING, Types.LONG, Types.LONG, Types.LONG, Types.LONG))
    testHarness.open()

    // register cleanup timer with 3003
    testHarness.setProcessingTime(3)
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 1L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "bbb", 10L: JLong, null)))

    testHarness.setProcessingTime(4)
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 2L: JLong, null)))

    // trigger cleanup timer and register cleanup timer with 6003
    testHarness.setProcessingTime(3003)
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 3L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "bbb", 20L: JLong, null)))

    testHarness.setProcessingTime(5)
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 4L: JLong, null)))

    // register cleanup timer with 9002
    testHarness.setProcessingTime(6002)

    testHarness.setProcessingTime(7002)
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 5L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 6L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "bbb", 30L: JLong, null)))

    // register cleanup timer with 14002
    testHarness.setProcessingTime(11002)
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 7L: JLong, null)))

    testHarness.setProcessingTime(11004)
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 8L: JLong, null)))

    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 9L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 10L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "bbb", 40L: JLong, null)))

    testHarness.setProcessingTime(11006)

    val result = testHarness.getOutput

    val expectedOutput = new ConcurrentLinkedQueue[Object]()

    // all elements at the same proc timestamp have the same value per key
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 1L: JLong, null, 1L: JLong, 1L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "bbb", 10L: JLong, null, 10L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 2L: JLong, null, 1L: JLong, 2L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 3L: JLong, null, 1L: JLong, 4L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "bbb", 20L: JLong, null, 10L: JLong, 20L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 4L: JLong, null, 1L: JLong, 4L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 5L: JLong, null, 3L: JLong, 6L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 6L: JLong, null, 3L: JLong, 6L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "bbb", 30L: JLong, null, 20L: JLong, 30L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 7L: JLong, null, 7L: JLong, 7L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 8L: JLong, null, 7L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 9L: JLong, null, 7L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 10L: JLong, null, 7L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "bbb", 40L: JLong, null, 40L: JLong, 40L: JLong)))

    assertor.assertOutputEqualsSorted("result mismatch", expectedOutput, result)

    // test for clean-up timer NPE
    testHarness.setProcessingTime(20000)

    // timer registered for 23000
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "ccc", 10L: JLong, null)))

    // update clean-up timer to 25500. Previous timer should not clean up
    testHarness.setProcessingTime(22500)
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "ccc", 10L: JLong, null)))

    // 23000 clean-up timer should fire but not fail with an NPE
    testHarness.setProcessingTime(23001)

    testHarness.close()
  }

  @Test
  def testProcTimeUnboundedOver(): Unit = {

    val data = new mutable.MutableList[(Long, String, Long)]
    val t = env.fromCollection(data).toTable(tEnv, 'currtime, 'b, 'c, 'proctime.proctime)
    tEnv.registerTable("T", t)

    val sql =
      """
        |SELECT currtime, b, c,
        | min(c) OVER
        |   (PARTITION BY b ORDER BY proctime ROWS BETWEEN UNBOUNDED preceding AND CURRENT ROW),
        | max(c) OVER
        |   (PARTITION BY b ORDER BY proctime ROWS BETWEEN UNBOUNDED preceding AND CURRENT ROW)
        |FROM T
      """.stripMargin
    val t1 = tEnv.sqlQuery(sql)

    tEnv.getConfig.setIdleStateRetentionTime(Time.seconds(2), Time.seconds(4))
    val testHarness = createHarnessTester(t1.toAppendStream[Row], "OverAggregate")
    val assertor = new RowDataHarnessAssertor(
      Array(Types.LONG, Types.STRING, Types.LONG, Types.LONG, Types.LONG, Types.LONG))

    testHarness.open()

    // register cleanup timer with 4003
    testHarness.setProcessingTime(1003)

    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 1L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "bbb", 10L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 2L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 3L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "bbb", 20L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 4L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 5L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 6L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "bbb", 30L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 7L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 8L: JLong, null)))

    // trigger cleanup timer and register cleanup timer with 8003
    testHarness.setProcessingTime(5003)
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 9L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "aaa", 10L: JLong, null)))
    testHarness.processElement(new StreamRecord(
      binaryrow(0L: JLong, "bbb", 40L: JLong, null)))

    val result = testHarness.getOutput

    val expectedOutput = new ConcurrentLinkedQueue[Object]()

    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 1L: JLong, null, 1L: JLong, 1L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "bbb", 10L: JLong, null, 10L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 2L: JLong, null, 1L: JLong, 2L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 3L: JLong, null, 1L: JLong, 3L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "bbb", 20L: JLong, null, 10L: JLong, 20L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 4L: JLong, null, 1L: JLong, 4L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 5L: JLong, null, 1L: JLong, 5L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 6L: JLong, null, 1L: JLong, 6L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "bbb", 30L: JLong, null, 10L: JLong, 30L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 7L: JLong, null, 1L: JLong, 7L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 8L: JLong, null, 1L: JLong, 8L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 9L: JLong, null, 9L: JLong, 9L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "aaa", 10L: JLong, null, 9L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(0L: JLong, "bbb", 40L: JLong, null, 40L: JLong, 40L: JLong)))

    assertor.assertOutputEqualsSorted("result mismatch", expectedOutput, result)
    testHarness.close()
  }

  /**
    * all elements at the same row-time have the same value per key
    */
  @Test
  def testRowTimeBoundedRangeOver(): Unit = {

    val data = new mutable.MutableList[(Long, String, Long)]
    env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime)
    val t = env.fromCollection(data).toTable(tEnv, 'rowtime.rowtime, 'b, 'c)
    tEnv.registerTable("T", t)

    val sql =
      """
        |SELECT rowtime, b, c,
        | min(c) OVER
        |   (PARTITION BY b ORDER BY rowtime
        |   RANGE BETWEEN INTERVAL '4' SECOND PRECEDING AND CURRENT ROW),
        | max(c) OVER
        |   (PARTITION BY b ORDER BY rowtime
        |   RANGE BETWEEN INTERVAL '4' SECOND PRECEDING AND CURRENT ROW)
        |FROM T
      """.stripMargin
    val t1 = tEnv.sqlQuery(sql)

    tEnv.getConfig.setIdleStateRetentionTime(Time.seconds(1), Time.seconds(2))
    val testHarness = createHarnessTester(t1.toAppendStream[Row], "OverAggregate")
    val assertor = new RowDataHarnessAssertor(
      Array(Types.LONG, Types.STRING, Types.LONG, Types.LONG, Types.LONG))

    testHarness.open()

    testHarness.processWatermark(1)
    testHarness.processElement(new StreamRecord(
      binaryrow(2L: JLong, "aaa", 1L: JLong)))

    testHarness.processWatermark(2)
    testHarness.processElement(new StreamRecord(
      binaryrow(3L: JLong, "bbb", 10L: JLong)))

    testHarness.processWatermark(4000)
    testHarness.processElement(new StreamRecord(
      binaryrow(4001L: JLong, "aaa", 2L: JLong)))

    testHarness.processWatermark(4001)
    testHarness.processElement(new StreamRecord(
      binaryrow(4002L: JLong, "aaa", 3L: JLong)))

    testHarness.processWatermark(4002)
    testHarness.processElement(new StreamRecord(
      binaryrow(4003L: JLong, "aaa", 4L: JLong)))

    testHarness.processWatermark(4800)
    testHarness.processElement(new StreamRecord(
      binaryrow(4801L: JLong, "bbb", 25L: JLong)))

    testHarness.processWatermark(6500)
    testHarness.processElement(new StreamRecord(
      binaryrow(6501L: JLong, "aaa", 5L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(6501L: JLong, "aaa", 6L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(6501L: JLong, "bbb", 30L: JLong)))

    testHarness.processWatermark(7000)
    testHarness.processElement(new StreamRecord(
      binaryrow(7001L: JLong, "aaa", 7L: JLong)))

    testHarness.processWatermark(8000)
    testHarness.processElement(new StreamRecord(
      binaryrow(8001L: JLong, "aaa", 8L: JLong)))

    testHarness.processWatermark(12000)
    testHarness.processElement(new StreamRecord(
      binaryrow(12001L: JLong, "aaa", 9L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(12001L: JLong, "aaa", 10L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(12001L: JLong, "bbb", 40L: JLong)))

    testHarness.processWatermark(19000)

    // test cleanup
    testHarness.setProcessingTime(1000)
    testHarness.processWatermark(20000)

    // check that state is removed after max retention time
    testHarness.processElement(new StreamRecord(
      binaryrow(20001L: JLong, "ccc", 1L: JLong))) // clean-up 3000
    testHarness.setProcessingTime(2500)
    testHarness.processElement(new StreamRecord(
      binaryrow(20002L: JLong, "ccc", 2L: JLong))) // clean-up 4500
    testHarness.processWatermark(20010) // compute output

    testHarness.setProcessingTime(4499)
    testHarness.setProcessingTime(4500)

    // check that state is only removed if all data was processed
    testHarness.processElement(new StreamRecord(
      binaryrow(20011L: JLong, "ccc", 3L: JLong))) // clean-up 6500

    testHarness.setProcessingTime(6500) // clean-up attempt but rescheduled to 8500

    testHarness.processWatermark(20020) // schedule emission

    testHarness.setProcessingTime(8499) // clean-up
    testHarness.setProcessingTime(8500) // clean-up

    val result = dropWatermarks(testHarness.getOutput.toArray)

    val expectedOutput = new ConcurrentLinkedQueue[Object]()

    // all elements at the same row-time have the same value per key
    expectedOutput.add(new StreamRecord(
      row(2L: JLong, "aaa", 1L: JLong, 1L: JLong, 1L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(3L: JLong, "bbb", 10L: JLong, 10L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4001L: JLong, "aaa", 2L: JLong, 1L: JLong, 2L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4002L: JLong, "aaa", 3L: JLong, 1L: JLong, 3L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4003L: JLong, "aaa", 4L: JLong, 2L: JLong, 4L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4801L: JLong, "bbb", 25L: JLong, 25L: JLong, 25L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(6501L: JLong, "aaa", 5L: JLong, 2L: JLong, 6L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(6501L: JLong, "aaa", 6L: JLong, 2L: JLong, 6L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(7001L: JLong, "aaa", 7L: JLong, 2L: JLong, 7L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(8001L: JLong, "aaa", 8L: JLong, 2L: JLong, 8L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(6501L: JLong, "bbb", 30L: JLong, 25L: JLong, 30L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(12001L: JLong, "aaa", 9L: JLong, 8L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(12001L: JLong, "aaa", 10L: JLong, 8L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(12001L: JLong, "bbb", 40L: JLong, 40L: JLong, 40L: JLong)))

    expectedOutput.add(new StreamRecord(
      row(20001L: JLong, "ccc", 1L: JLong, 1L: JLong, 1L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(20002L: JLong, "ccc", 2L: JLong, 1L: JLong, 2L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(20011L: JLong, "ccc", 3L: JLong, 3L: JLong, 3L: JLong)))

    assertor.assertOutputEqualsSorted("result mismatch", expectedOutput, result)
    testHarness.close()
  }

  @Test
  def testRowTimeBoundedRowsOver(): Unit = {

    val data = new mutable.MutableList[(Long, String, Long)]
    env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime)
    val t = env.fromCollection(data).toTable(tEnv, 'rowtime.rowtime, 'b, 'c)
    tEnv.registerTable("T", t)

    val sql =
      """
        |SELECT rowtime, b, c,
        | min(c) OVER
        |   (PARTITION BY b ORDER BY rowtime
        |   ROWS BETWEEN 2 PRECEDING AND CURRENT ROW),
        | max(c) OVER
        |   (PARTITION BY b ORDER BY rowtime
        |   ROWS BETWEEN 2 PRECEDING AND CURRENT ROW)
        |FROM T
      """.stripMargin
    val t1 = tEnv.sqlQuery(sql)

    tEnv.getConfig.setIdleStateRetentionTime(Time.seconds(1), Time.seconds(2))
    val testHarness = createHarnessTester(t1.toAppendStream[Row], "OverAggregate")
    val assertor = new RowDataHarnessAssertor(
      Array(Types.LONG, Types.STRING, Types.LONG, Types.LONG, Types.LONG))

    testHarness.open()

    testHarness.processWatermark(800)
    testHarness.processElement(new StreamRecord(
      binaryrow(801L: JLong, "aaa", 1L: JLong)))

    testHarness.processWatermark(2500)
    testHarness.processElement(new StreamRecord(
      binaryrow(2501L: JLong, "bbb", 10L: JLong)))

    testHarness.processWatermark(4000)
    testHarness.processElement(new StreamRecord(
      binaryrow(4001L: JLong, "aaa", 2L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(4001L: JLong, "aaa", 3L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(4001L: JLong, "bbb", 20L: JLong)))

    testHarness.processWatermark(4800)
    testHarness.processElement(new StreamRecord(
      binaryrow(4801L: JLong, "aaa", 4L: JLong)))

    testHarness.processWatermark(6500)
    testHarness.processElement(new StreamRecord(
      binaryrow(6501L: JLong, "aaa", 5L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(6501L: JLong, "aaa", 6L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(6501L: JLong, "bbb", 30L: JLong)))

    testHarness.processWatermark(7000)
    testHarness.processElement(new StreamRecord(
      binaryrow(7001L: JLong, "aaa", 7L: JLong)))

    testHarness.processWatermark(8000)
    testHarness.processElement(new StreamRecord(
      binaryrow(8001L: JLong, "aaa", 8L: JLong)))

    testHarness.processWatermark(12000)
    testHarness.processElement(new StreamRecord(
      binaryrow(12001L: JLong, "aaa", 9L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(12001L: JLong, "aaa", 10L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(12001L: JLong, "bbb", 40L: JLong)))

    testHarness.processWatermark(19000)

    // test cleanup
    testHarness.setProcessingTime(1000)
    testHarness.processWatermark(20000)

    // check that state is removed after max retention time
    testHarness.processElement(new StreamRecord(
      binaryrow(20001L: JLong, "ccc", 1L: JLong))) // clean-up 3000
    testHarness.setProcessingTime(2500)
    testHarness.processElement(new StreamRecord(
      binaryrow(20002L: JLong, "ccc", 2L: JLong))) // clean-up 4500
    testHarness.processWatermark(20010) // compute output

    testHarness.setProcessingTime(4499)
    testHarness.setProcessingTime(4500)

    // check that state is only removed if all data was processed
    testHarness.processElement(new StreamRecord(
      binaryrow(20011L: JLong, "ccc", 3L: JLong))) // clean-up 6500

    testHarness.setProcessingTime(6500) // clean-up attempt but rescheduled to 8500

    testHarness.processWatermark(20020) // schedule emission

    testHarness.setProcessingTime(8499) // clean-up
    testHarness.setProcessingTime(8500) // clean-up

    val result = dropWatermarks(testHarness.getOutput.toArray)

    val expectedOutput = new ConcurrentLinkedQueue[Object]()

    expectedOutput.add(new StreamRecord(
      row(801L: JLong, "aaa", 1L: JLong, 1L: JLong, 1L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(2501L: JLong, "bbb", 10L: JLong, 10L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4001L: JLong, "aaa", 2L: JLong, 1L: JLong, 2L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4001L: JLong, "aaa", 3L: JLong, 1L: JLong, 3L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4001L: JLong, "bbb", 20L: JLong, 10L: JLong, 20L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4801L: JLong, "aaa", 4L: JLong, 2L: JLong, 4L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(6501L: JLong, "aaa", 5L: JLong, 3L: JLong, 5L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(6501L: JLong, "aaa", 6L: JLong, 4L: JLong, 6L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(6501L: JLong, "bbb", 30L: JLong, 10L: JLong, 30L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(7001L: JLong, "aaa", 7L: JLong, 5L: JLong, 7L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(8001L: JLong, "aaa", 8L: JLong, 6L: JLong, 8L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(12001L: JLong, "aaa", 9L: JLong, 7L: JLong, 9L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(12001L: JLong, "aaa", 10L: JLong, 8L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(12001L: JLong, "bbb", 40L: JLong, 20L: JLong, 40L: JLong)))

    expectedOutput.add(new StreamRecord(
      row(20001L: JLong, "ccc", 1L: JLong, 1L: JLong, 1L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(20002L: JLong, "ccc", 2L: JLong, 1L: JLong, 2L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(20011L: JLong, "ccc", 3L: JLong, 3L: JLong, 3L: JLong)))

    assertor.assertOutputEqualsSorted("result mismatch", expectedOutput, result)
    testHarness.close()
  }

  /**
    * all elements at the same row-time have the same value per key
    */
  @Test
  def testRowTimeUnboundedRangeOver(): Unit = {

    val data = new mutable.MutableList[(Long, String, Long)]
    env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime)
    val t = env.fromCollection(data).toTable(tEnv, 'rowtime.rowtime, 'b, 'c)
    tEnv.registerTable("T", t)

    val sql =
      """
        |SELECT rowtime, b, c,
        | min(c) OVER
        |   (PARTITION BY b ORDER BY rowtime
        |   RANGE BETWEEN UNBOUNDED preceding AND CURRENT ROW),
        | max(c) OVER
        |   (PARTITION BY b ORDER BY rowtime
        |   RANGE BETWEEN UNBOUNDED preceding AND CURRENT ROW)
        |FROM T
      """.stripMargin
    val t1 = tEnv.sqlQuery(sql)

    tEnv.getConfig.setIdleStateRetentionTime(Time.seconds(1), Time.seconds(2))
    val testHarness = createHarnessTester(t1.toAppendStream[Row], "OverAggregate")
    val assertor = new RowDataHarnessAssertor(
      Array(Types.LONG, Types.STRING, Types.LONG, Types.LONG, Types.LONG))

    testHarness.open()

    testHarness.setProcessingTime(1000)
    testHarness.processWatermark(800)
    testHarness.processElement(new StreamRecord(
      binaryrow(801L: JLong, "aaa", 1L: JLong)))

    testHarness.processWatermark(2500)
    testHarness.processElement(new StreamRecord(
      binaryrow(2501L: JLong, "bbb", 10L: JLong)))

    testHarness.processWatermark(4000)
    testHarness.processElement(new StreamRecord(
      binaryrow(4001L: JLong, "aaa", 2L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(4001L: JLong, "aaa", 3L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(4001L: JLong, "bbb", 20L: JLong)))

    testHarness.processWatermark(4800)
    testHarness.processElement(new StreamRecord(
      binaryrow(4801L: JLong, "aaa", 4L: JLong)))

    testHarness.processWatermark(6500)
    testHarness.processElement(new StreamRecord(
      binaryrow(6501L: JLong, "aaa", 5L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(6501L: JLong, "aaa", 6L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(6501L: JLong, "bbb", 30L: JLong)))

    testHarness.processWatermark(7000)
    testHarness.processElement(new StreamRecord(
      binaryrow(7001L: JLong, "aaa", 7L: JLong)))

    testHarness.processWatermark(8000)
    testHarness.processElement(new StreamRecord(
      binaryrow(8001L: JLong, "aaa", 8L: JLong)))

    testHarness.processWatermark(12000)
    testHarness.processElement(new StreamRecord(
      binaryrow(12001L: JLong, "aaa", 9L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(12001L: JLong, "aaa", 10L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(12001L: JLong, "bbb", 40L: JLong)))

    testHarness.processWatermark(19000)

    // test cleanup
    testHarness.setProcessingTime(2999) // clean up timer is 3000, so nothing should happen
    testHarness.setProcessingTime(3000) // clean up is triggered

    testHarness.processWatermark(20000)
    testHarness.processElement(new StreamRecord(
      binaryrow(20000L: JLong, "ccc", 1L: JLong))) // test for late data

    testHarness.processElement(new StreamRecord(
      binaryrow(20001L: JLong, "ccc", 1L: JLong))) // clean-up 5000
    testHarness.setProcessingTime(2500)
    testHarness.processElement(new StreamRecord(
      binaryrow(20002L: JLong, "ccc", 2L: JLong))) // clean-up 5000

    testHarness.setProcessingTime(5000) // does not clean up, because data left. New timer 7000
    testHarness.processWatermark(20010) // compute output

    testHarness.setProcessingTime(6999) // clean up timer is 3000, so nothing should happen
    testHarness.setProcessingTime(7000) // clean up is triggered

    val result = dropWatermarks(testHarness.getOutput.toArray)

    val expectedOutput = new ConcurrentLinkedQueue[Object]()

    // all elements at the same row-time have the same value per key
    expectedOutput.add(new StreamRecord(
      row(801L: JLong, "aaa", 1L: JLong, 1L: JLong, 1L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(2501L: JLong, "bbb", 10L: JLong, 10L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4001L: JLong, "aaa", 2L: JLong, 1L: JLong, 3L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4001L: JLong, "aaa", 3L: JLong, 1L: JLong, 3L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4001L: JLong, "bbb", 20L: JLong, 10L: JLong, 20L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4801L: JLong, "aaa", 4L: JLong, 1L: JLong, 4L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(6501L: JLong, "aaa", 5L: JLong, 1L: JLong, 6L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(6501L: JLong, "aaa", 6L: JLong, 1L: JLong, 6L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(6501L: JLong, "bbb", 30L: JLong, 10L: JLong, 30L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(7001L: JLong, "aaa", 7L: JLong, 1L: JLong, 7L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(8001L: JLong, "aaa", 8L: JLong, 1L: JLong, 8L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(12001L: JLong, "aaa", 9L: JLong, 1L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(12001L: JLong, "aaa", 10L: JLong, 1L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(12001L: JLong, "bbb", 40L: JLong, 10L: JLong, 40L: JLong)))

    expectedOutput.add(new StreamRecord(
      row(20001L: JLong, "ccc", 1L: JLong, 1L: JLong, 1L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(20002L: JLong, "ccc", 2L: JLong, 1L: JLong, 2L: JLong)))

    assertor.assertOutputEqualsSorted("result mismatch", expectedOutput, result)
    testHarness.close()
  }

  @Test
  def testRowTimeUnboundedRowsOver(): Unit = {

    val data = new mutable.MutableList[(Long, String, Long)]
    env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime)
    val t = env.fromCollection(data).toTable(tEnv, 'rowtime.rowtime, 'b, 'c)
    tEnv.registerTable("T", t)

    val sql =
      """
        |SELECT rowtime, b, c,
        | min(c) OVER
        |   (PARTITION BY b ORDER BY rowtime
        |   ROWS BETWEEN UNBOUNDED preceding AND CURRENT ROW),
        | max(c) OVER
        |   (PARTITION BY b ORDER BY rowtime
        |   ROWS BETWEEN UNBOUNDED preceding AND CURRENT ROW)
        |FROM T
      """.stripMargin
    val t1 = tEnv.sqlQuery(sql)

    tEnv.getConfig.setIdleStateRetentionTime(Time.seconds(1), Time.seconds(2))
    val testHarness = createHarnessTester(t1.toAppendStream[Row], "OverAggregate")
    val assertor = new RowDataHarnessAssertor(
      Array(Types.LONG, Types.STRING, Types.LONG, Types.LONG, Types.LONG))

    testHarness.open()

    testHarness.setProcessingTime(1000)
    testHarness.processWatermark(800)
    testHarness.processElement(new StreamRecord(
      binaryrow(801L: JLong, "aaa", 1L: JLong)))

    testHarness.processWatermark(2500)
    testHarness.processElement(new StreamRecord(
      binaryrow(2501L: JLong, "bbb", 10L: JLong)))

    testHarness.processWatermark(4000)
    testHarness.processElement(new StreamRecord(
      binaryrow(4001L: JLong, "aaa", 2L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(4001L: JLong, "aaa", 3L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(4001L: JLong, "bbb", 20L: JLong)))

    testHarness.processWatermark(4800)
    testHarness.processElement(new StreamRecord(
      binaryrow(4801L: JLong, "aaa", 4L: JLong)))

    testHarness.processWatermark(6500)
    testHarness.processElement(new StreamRecord(
      binaryrow(6501L: JLong, "aaa", 5L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(6501L: JLong, "aaa", 6L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(6501L: JLong, "bbb", 30L: JLong)))

    testHarness.processWatermark(7000)
    testHarness.processElement(new StreamRecord(
      binaryrow(7001L: JLong, "aaa", 7L: JLong)))

    testHarness.processWatermark(8000)
    testHarness.processElement(new StreamRecord(
      binaryrow(8001L: JLong, "aaa", 8L: JLong)))

    testHarness.processWatermark(12000)
    testHarness.processElement(new StreamRecord(
      binaryrow(12001L: JLong, "aaa", 9L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(12001L: JLong, "aaa", 10L: JLong)))
    testHarness.processElement(new StreamRecord(
      binaryrow(12001L: JLong, "bbb", 40L: JLong)))

    testHarness.processWatermark(19000)

    // test cleanup
    testHarness.setProcessingTime(2999) // clean up timer is 3000, so nothing should happen
    testHarness.setProcessingTime(3000) // clean up is triggered

    testHarness.processWatermark(20000)
    testHarness.processElement(new StreamRecord(
      binaryrow(20000L: JLong, "ccc", 2L: JLong))) // test for late data

    testHarness.processElement(new StreamRecord(
      binaryrow(20001L: JLong, "ccc", 1L: JLong))) // clean-up 5000
    testHarness.setProcessingTime(2500)
    testHarness.processElement(new StreamRecord(
      binaryrow(20002L: JLong, "ccc", 2L: JLong))) // clean-up 5000

    testHarness.setProcessingTime(5000) // does not clean up, because data left. New timer 7000
    testHarness.processWatermark(20010) // compute output

    testHarness.setProcessingTime(6999) // clean up timer is 3000, so nothing should happen
    testHarness.setProcessingTime(7000) // clean up is triggered

    val result = dropWatermarks(testHarness.getOutput.toArray)

    val expectedOutput = new ConcurrentLinkedQueue[Object]()

    expectedOutput.add(new StreamRecord(
      row(801L: JLong, "aaa", 1L: JLong, 1L: JLong, 1L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(2501L: JLong, "bbb", 10L: JLong, 10L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4001L: JLong, "aaa", 2L: JLong, 1L: JLong, 2L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4001L: JLong, "aaa", 3L: JLong, 1L: JLong, 3L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4001L: JLong, "bbb", 20L: JLong, 10L: JLong, 20L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(4801L: JLong, "aaa", 4L: JLong, 1L: JLong, 4L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(6501L: JLong, "aaa", 5L: JLong, 1L: JLong, 5L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(6501L: JLong, "aaa", 6L: JLong, 1L: JLong, 6L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(6501L: JLong, "bbb", 30L: JLong, 10L: JLong, 30L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(7001L: JLong, "aaa", 7L: JLong, 1L: JLong, 7L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(8001L: JLong, "aaa", 8L: JLong, 1L: JLong, 8L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(12001L: JLong, "aaa", 9L: JLong, 1L: JLong, 9L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(12001L: JLong, "aaa", 10L: JLong, 1L: JLong, 10L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(12001L: JLong, "bbb", 40L: JLong, 10L: JLong, 40L: JLong)))

    expectedOutput.add(new StreamRecord(
      row(20001L: JLong, "ccc", 1L: JLong, 1L: JLong, 1L: JLong)))
    expectedOutput.add(new StreamRecord(
      row(20002L: JLong, "ccc", 2L: JLong, 1L: JLong, 2L: JLong)))

    assertor.assertOutputEqualsSorted("result mismatch", expectedOutput, result)
    testHarness.close()
  }
}


text:
import os
from setuptools import setup

def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(
    name = "{{name}}",
    # update version whenever you create a new release
    version = "{{version}}",
    author = "{{author}}",
    description = ("{{overview}}"),
    license = "MIT",
    keywords = "{{keywords}}",
    url = "{{url}}",
    packages=[
        '{{name}}',
        '{{name}}.main'
    ],
    package_data={
      '{{name}}' : ['resources/*']
    },
    long_description=read('README.md'),
    classifiers=[
        "License :: OSI Approved :: MIT License",
    ],
)


text: Einträge für diesen Tag


text:
import { SYMBOL } from "../helper/symbols";

export var ITERATE_KEYS = 0;
export var ITERATE_VALUES = 1;
export var ITERATE_ENTRIES = 2;

export var DONE = Object.freeze( { value: undefined, done: true } );

export function getIterator( obj ) {
  var real = SYMBOL.iterator;
  return real ? obj[ real ]() : obj[ "@@iterator" ]();
}

export function getIteratorFn( obj ) {
  var real = SYMBOL.iterator;
  return real ? obj[ real ] : obj[ "@@iterator" ];
}

export function setIteratorFn( obj, func ) {

  var real = SYMBOL.iterator;

  if ( real ) {
    obj[ real ] = func;
  }

  obj[ "@@iterator" ] = func;
}

export function createIterableClass( clazz, IteratorFn, iteratorType ) {
  var proto = clazz.prototype;
  proto.entries = function() {
    return new IteratorFn( this, ITERATE_ENTRIES );
  };
  proto.values = function() {
    return new IteratorFn( this, ITERATE_VALUES );
  };
  proto.keys = function() {
    return new IteratorFn( this, ITERATE_KEYS );
  };
  setIteratorFn( proto, proto[ iteratorType ] );
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:util="http://www.springframework.org/schema/util" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
	    http://www.springframework.org/schema/beans/spring-beans.xsd
	    http://www.springframework.org/schema/context
	    http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/mvc
	    http://www.springframework.org/schema/mvc/spring-mvc.xsd
	    http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util.xsd">

	 <!-- 对静态资源文件的访问,交给default servlet handler处理 -->
    <mvc:default-servlet-handler/>
    <!-- 启用spring mvc 注解 -->
    <context:annotation-config />
    <!-- 默认的注解映射的支持 -->
    <mvc:annotation-driven />
    <!-- 设置使用注解的类所在的包 -->
	<context:component-scan base-package="com.yt.chart"></context:component-scan>
	<!-- 完成请求和注解POJO的映射 -->
	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
	<!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->
	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
	   	<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
	   	<property name="prefix" value="/view/"/>
	   	<property name="suffix" value=".jsp"/>
	</bean>
    <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射, 完成json自动转换
   	<bean id="mappingJackson2HttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
    	<property name="supportedMediaTypes">
        	<list>
                <value>text/html;charset=UTF-8</value>
                <value>text/json;charset=UTF-8</value>
                <value>application/json;charset=UTF-8</value>
            </list>
        </property>
     </bean>
   	-->
</beans>


text:
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MathConversionExtensions.cs" company="Slash Games">
//   Copyright (c) Slash Games. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Slash.Unity.Common.Math
{
    using System;

    using Slash.Math.Algebra.Vectors;
    using Slash.Math.Geometry.Rectangles;

    using UnityEngine;

    /// <summary>
    ///   Contains extension methods to convert from/to Unity/framework mathematical structures.
    /// </summary>
    public static class MathConversionExtensions
    {
        #region Public Methods and Operators

        /// <summary>
        ///   Converts the specified framework rectangle to an Unity rectangle.
        /// </summary>
        /// <param name="rectangle">Rectangle to convert.</param>
        /// <returns>Corresponding Unity rectangle.</returns>
        public static Rect ToRect(this RectangleI rectangle)
        {
            return new Rect(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
        }

        /// <summary>
        ///   Converts the specified framework rectangle to an Unity rectangle.
        /// </summary>
        /// <param name="rectangle">Rectangle to convert.</param>
        /// <returns>Corresponding Unity rectangle.</returns>
        public static Rect ToRect(this RectangleF rectangle)
        {
            return new Rect(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
        }

        /// <summary>
        ///   Converts the specified Unity rectangle to a framework rectangle.
        /// </summary>
        /// <param name="rectangle">Rectangle to convert.</param>
        /// <returns>Corresponding framework rectangle.</returns>
        public static RectangleF ToRectangleF(this Rect rectangle)
        {
            return new RectangleF(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
        }

        /// <summary>
        ///   Converts the specified Unity rectangle to a framework rectangle.
        /// </summary>
        /// <param name="rectangle">Rectangle to convert.</param>
        /// <returns>Corresponding framework rectangle.</returns>
        public static RectangleI ToRectangleI(this Rect rectangle)
        {
            return new RectangleI((int)rectangle.x, (int)rectangle.y, (int)rectangle.width, (int)rectangle.height);
        }

        /// <summary>
        ///   Converts the specified framework vector to an Unity vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <returns>Corresponding Unity vector.</returns>
        public static Vector2 ToVector2(this Vector2I vector)
        {
            return new Vector2(vector.X, vector.Y);
        }

        /// <summary>
        ///   Converts the specified framework vector to an Unity vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <returns>Corresponding Unity vector.</returns>
        public static Vector2 ToVector2(this Vector2F vector)
        {
            return new Vector2(vector.X, vector.Y);
        }

        /// <summary>
        ///   Converts the specified Unity vector to a framework vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <returns>Corresponding framework vector.</returns>
        public static Vector2F ToVector2F(this Vector2 vector)
        {
            return new Vector2F(vector.x, vector.y);
        }

        /// <summary>
        ///   Converts the specified Unity vector to a framework vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <returns>Corresponding framework vector.</returns>
        [Obsolete("Deprecated to make conversion clearer. Use ToVector2FXY instead.")]
        public static Vector2F ToVector2F(this Vector3 vector)
        {
            return new Vector2F(vector.x, vector.y);
        }

        /// <summary>
        ///   Converts the specified Unity vector to a framework vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <returns>Corresponding framework vector.</returns>
        public static Vector2F ToVector2FXY(this Vector3 vector)
        {
            return new Vector2F(vector.x, vector.y);
        }

        /// <summary>
        ///   Converts the specified Unity vector to a framework vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <returns>Corresponding framework vector.</returns>
        public static Vector2F ToVector2FXZ(this Vector3 vector)
        {
            return new Vector2F(vector.x, vector.z);
        }

        /// <summary>
        ///   Converts the specified Unity vector to a framework vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <returns>Corresponding framework vector.</returns>
        public static Vector2I ToVector2I(this Vector2 vector)
        {
            return new Vector2I((int)vector.x, (int)vector.y);
        }

        /// <summary>
        ///   Converts the specified Unity vector to a framework vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <returns>Corresponding framework vector.</returns>
        public static Vector2I ToVector2IXY(this Vector3 vector)
        {
            return new Vector2I((int)vector.x, (int)vector.y);
        }

        /// <summary>
        ///   Converts the specified Unity vector to a framework vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <returns>Corresponding framework vector.</returns>
        public static Vector2I ToVector2IXZ(this Vector3 vector)
        {
            return new Vector2I((int)vector.x, (int)vector.z);
        }

        /// <summary>
        ///   Converts the specified framework vector to an Unity vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <returns>Corresponding Unity vector.</returns>
        public static Vector3 ToVector3(this Vector3F vector)
        {
            return new Vector3(vector.X, vector.Y, vector.Z);
        }

        /// <summary>
        ///   Converts the specified framework vector to an Unity vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <param name="z">Z value.</param>
        /// <returns>Corresponding Unity vector.</returns>
        [Obsolete("Deprecated to make conversion clearer. Use ToVector3XY instead.")]
        public static Vector3 ToVector3(this Vector2F vector, float z = 0)
        {
            return new Vector3(vector.X, vector.Y, z);
        }

        /// <summary>
        ///   Converts the specified framework vector to an Unity vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <param name="z">Z value.</param>
        /// <returns>Corresponding Unity vector.</returns>
        public static Vector3 ToVector3XY(this Vector2F vector, float z = 0)
        {
            return new Vector3(vector.X, vector.Y, z);
        }

        /// <summary>
        ///   Converts the specified framework vector to an Unity vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <param name="y">Y value.</param>
        /// <returns>Corresponding Unity vector.</returns>
        public static Vector3 ToVector3XZ(this Vector2F vector, float y = 0)
        {
            return new Vector3(vector.X, y, vector.Y);
        }

        /// <summary>
        ///   Converts the specified framework vector to an Unity vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <param name="z">Z value.</param>
        /// <returns>Corresponding Unity vector.</returns>
        public static Vector3 ToVector3XY(this Vector2I vector, float z = 0)
        {
            return new Vector3(vector.X, vector.Y, z);
        }

        /// <summary>
        ///   Converts the specified framework vector to an Unity vector.
        /// </summary>
        /// <param name="vector">Vector to convert.</param>
        /// <param name="y">Y value.</param>
        /// <returns>Corresponding Unity vector.</returns>
        public static Vector3 ToVector3XZ(this Vector2I vector, float y = 0)
        {
            return new Vector3(vector.X, y, vector.Y);
        }

        #endregion
    }
}