text:
module.exports.register = function (context) {

  var defaultNodeSize = 72;
  var defaultNodeRadius = 8;

  var TheGraph = context.TheGraph;

  var moduleVars = {
    // nodeSize and nodeRadius are deprecated, use TheGraph.config.(nodeSize/nodeRadius)
    nodeSize: defaultNodeSize,
    nodeRadius: defaultNodeRadius,
    nodeSide: 56,
    // Context menus
    contextPortSize: 36,
    // Zoom breakpoints
    zbpBig: 1.2,
    zbpNormal: 0.4,
    zbpSmall: 0.01,
    config: {
      nodeSize: defaultNodeSize,
      nodeWidth: defaultNodeSize,
      nodeRadius: defaultNodeRadius,
      nodeHeight: defaultNodeSize,
      autoSizeNode: true,
      maxPortCount: 9,
      nodeHeightIncrement: 12,
      focusAnimationDuration: 1500
    },
  };
  for (var key in moduleVars) {
    TheGraph[key] = moduleVars[key];
  }

  if (typeof window !== 'undefined') {
    // rAF shim
    window.requestAnimationFrame = window.requestAnimationFrame ||
      window.webkitRequestAnimationFrame ||
      window.mozRequestAnimationFrame ||
      window.msRequestAnimationFrame;
  }

  TheGraph.findMinMax = function (graph, nodes) {
    var inports, outports;
    if (nodes === undefined) {
      nodes = graph.nodes.map( function (node) {
        return node.id;
      });
      // Only look at exports when calculating the whole graph
      inports = graph.inports;
      outports = graph.outports;
    }
    if (nodes.length < 1) {
      return undefined;
    }
    var minX = Infinity;
    var minY = Infinity;
    var maxX = -Infinity;
    var maxY = -Infinity;

    // Loop through nodes
    var len = nodes.length;
    for (var i=0; i<len; i++) {
      var key = nodes[i];
      var node = graph.getNode(key);
      if (!node || !node.metadata) {
        continue;
      }
      if (node.metadata.x < minX) { minX = node.metadata.x; }
      if (node.metadata.y < minY) { minY = node.metadata.y; }
      var x = node.metadata.x + node.metadata.width;
      var y = node.metadata.y + node.metadata.height;
      if (x > maxX) { maxX = x; }
      if (y > maxY) { maxY = y; }
    }
    // Loop through exports
    var keys, exp;
    if (inports) {
      keys = Object.keys(inports);
      len = keys.length;
      for (i=0; i<len; i++) {
        exp = inports[keys[i]];
        if (!exp.metadata) { continue; }
        if (exp.metadata.x < minX) { minX = exp.metadata.x; }
        if (exp.metadata.y < minY) { minY = exp.metadata.y; }
        if (exp.metadata.x > maxX) { maxX = exp.metadata.x; }
        if (exp.metadata.y > maxY) { maxY = exp.metadata.y; }
      }
    }
    if (outports) {
      keys = Object.keys(outports);
      len = keys.length;
      for (i=0; i<len; i++) {
        exp = outports[keys[i]];
        if (!exp.metadata) { continue; }
        if (exp.metadata.x < minX) { minX = exp.metadata.x; }
        if (exp.metadata.y < minY) { minY = exp.metadata.y; }
        if (exp.metadata.x > maxX) { maxX = exp.metadata.x; }
        if (exp.metadata.y > maxY) { maxY = exp.metadata.y; }
      }
    }

    if (!isFinite(minX) || !isFinite(minY) || !isFinite(maxX) || !isFinite(maxY)) {
      return null;
    }
    return {
      minX: minX,
      minY: minY,
      maxX: maxX,
      maxY: maxY
    };
  };

  TheGraph.findFit = function (graph, width, height) {
    var limits = TheGraph.findMinMax(graph);
    if (!limits) {
      return {x:0, y:0, scale:1};
    }
    limits.minX -= TheGraph.config.nodeSize;
    limits.minY -= TheGraph.config.nodeSize;
    limits.maxX += TheGraph.config.nodeSize * 2;
    limits.maxY += TheGraph.config.nodeSize * 2;

    var gWidth = limits.maxX - limits.minX;
    var gHeight = limits.maxY - limits.minY;

    var scaleX = width / gWidth;
    var scaleY = height / gHeight;

    var scale, x, y;
    if (scaleX < scaleY) {
      scale = scaleX;
      x = 0 - limits.minX * scale;
      y = 0 - limits.minY * scale + (height-(gHeight*scale))/2;
    } else {
      scale = scaleY;
      x = 0 - limits.minX * scale + (width-(gWidth*scale))/2;
      y = 0 - limits.minY * scale;
    }

    return {
      x: x,
      y: y,
      scale: scale
    };
  };

  TheGraph.findAreaFit = function (point1, point2, width, height) {
    var limits = {
      minX: point1.x < point2.x ? point1.x : point2.x,
      minY: point1.y < point2.y ? point1.y : point2.y,
      maxX: point1.x > point2.x ? point1.x : point2.x,
      maxY: point1.y > point2.y ? point1.y : point2.y
    };

    limits.minX -= TheGraph.config.nodeSize;
    limits.minY -= TheGraph.config.nodeSize;
    limits.maxX += TheGraph.config.nodeSize * 2;
    limits.maxY += TheGraph.config.nodeSize * 2;

    var gWidth = limits.maxX - limits.minX;
    var gHeight = limits.maxY - limits.minY;

    var scaleX = width / gWidth;
    var scaleY = height / gHeight;

    var scale, x, y;
    if (scaleX < scaleY) {
      scale = scaleX;
      x = 0 - limits.minX * scale;
      y = 0 - limits.minY * scale + (height-(gHeight*scale))/2;
    } else {
      scale = scaleY;
      x = 0 - limits.minX * scale + (width-(gWidth*scale))/2;
      y = 0 - limits.minY * scale;
    }

    return {
      x: x,
      y: y,
      scale: scale
    };
  };

  TheGraph.findNodeFit = function (node, width, height) {
    var limits = {
      minX: node.metadata.x - TheGraph.config.nodeSize,
      minY: node.metadata.y - TheGraph.config.nodeSize,
      maxX: node.metadata.x + TheGraph.config.nodeSize * 2,
      maxY: node.metadata.y + TheGraph.config.nodeSize * 2
    };

    var gWidth = limits.maxX - limits.minX;
    var gHeight = limits.maxY - limits.minY;

    var scaleX = width / gWidth;
    var scaleY = height / gHeight;

    var scale, x, y;
    if (scaleX < scaleY) {
      scale = scaleX;
      x = 0 - limits.minX * scale;
      y = 0 - limits.minY * scale + (height-(gHeight*scale))/2;
    } else {
      scale = scaleY;
      x = 0 - limits.minX * scale + (width-(gWidth*scale))/2;
      y = 0 - limits.minY * scale;
    }

    return {
      x: x,
      y: y,
      scale: scale
    };
  };

  // Reusable React classes
  TheGraph.SVGImage = React.createFactory( React.createClass({
    displayName: "TheGraphSVGImage",
    render: function() {
        var html = '<image ';
        html = html +'xlink:href="'+ this.props.src + '"';
        html = html +'x="' + this.props.x + '"';
        html = html +'y="' + this.props.y + '"';
        html = html +'width="' + this.props.width + '"';
        html = html +'height="' + this.props.height + '"';
        html = html +'/>';

        return React.DOM.g({
            className: this.props.className,
            dangerouslySetInnerHTML:{__html: html}
        });
    }
  }));

  TheGraph.TextBG = React.createFactory( React.createClass({
    displayName: "TheGraphTextBG",
    render: function() {
      var text = this.props.text;
      if (!text) {
        text = "";
      }
      var height = this.props.height;
      var width = text.length * this.props.height * 2/3;
      var radius = this.props.height/2;

      var textAnchor = "start";
      var dominantBaseline = "central";
      var x = this.props.x;
      var y = this.props.y - height/2;

      if (this.props.halign === "center") {
        x -= width/2;
        textAnchor = "middle";
      }
      if (this.props.halign === "right") {
        x -= width;
        textAnchor = "end";
      }

      return React.DOM.g(
        {
          className: (this.props.className ? this.props.className : "text-bg"),
        },
        React.DOM.rect({
          className: "text-bg-rect",
          x: x,
          y: y,
          rx: radius,
          ry: radius,
          height: height * 1.1,
          width: width
        }),
        React.DOM.text({
          className: (this.props.textClassName ? this.props.textClassName : "text-bg-text"),
          x: this.props.x,
          y: this.props.y,
          children: text
        })
      );
    }
  }));

  TheGraph.getOffset = function(domNode){
    var getElementOffset = function(element){
      var offset = { top: 0, left: 0},
          parentOffset;
      if(!element){
        return offset;
      }
      offset.top += (element.offsetTop || 0);
      offset.left += (element.offsetLeft || 0);
      parentOffset = getElementOffset(element.offsetParent);
      offset.top += parentOffset.top;
      offset.left += parentOffset.left;
      return offset;
    };
    try{
      return getElementOffset( domNode );
    }catch(e){
      return getElementOffset();
    }
  };

};


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sample_5.BLL;

namespace Sample_5
{
    public partial class ChannelScanList : System.Web.UI.Page
    {
        /// <summary>
        /// 渠道扫描记录列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //获取渠道ID
            int id;
            if (int.TryParse(Request.QueryString["id"], out id))
            {
                //获取渠道扫描记录列表数据
                ViewState["ChannelScanDisplayList"] = new ChannelScanBll().GetChannelScanList(id);
            }
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
<?php

use yii\db\Migration;

class m180313_120601_create_table__backend_showing extends Migration
{
    public function safeUp()
    {
        $tableName = 'backend_showing';
        $tableExist = $this->db->getTableSchema($tableName, true);
        if ($tableExist) {
            return true;
        }
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
        }

        $this->createTable($tableName, [
            'id' => $this->primaryKey(),

            'created_by' => $this->integer(),
            'updated_by' => $this->integer(),

            'created_at' => $this->integer(),
            'updated_at' => $this->integer(),

            'name'          => $this->string(255),
            'cms_user_id'   => $this->integer(),
            'is_default'    => $this->integer(1)->notNull()->defaultValue(1),
            'key'           => $this->string(255)->notNull(),
            'priority'      => $this->integer()->notNull()->defaultValue(100),
            'config_jsoned' => $this->text(),

        ], $tableOptions);

        $this->createIndex($tableName.'__updated_by', $tableName, 'updated_by');
        $this->createIndex($tableName.'__created_by', $tableName, 'created_by');
        $this->createIndex($tableName.'__created_at', $tableName, 'created_at');
        $this->createIndex($tableName.'__updated_at', $tableName, 'updated_at');

        $this->createIndex($tableName.'__cms_user_id', $tableName, 'cms_user_id');
        $this->createIndex($tableName.'__is_default', $tableName, 'is_default');
        $this->createIndex($tableName.'__name', $tableName, 'name');
        $this->createIndex($tableName.'__key', $tableName, 'key');
        $this->createIndex($tableName.'__priority', $tableName, 'priority');

        $this->addForeignKey(
            "{$tableName}__created_by", $tableName,
            'created_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
        );

        $this->addForeignKey(
            "{$tableName}__updated_by", $tableName,
            'updated_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
        );

        $this->addForeignKey(
            "{$tableName}__cms_user_id", $tableName,
            'cms_user_id', '{{%cms_user}}', 'id', 'CASCADE', 'CASCADE'
        );
    }

    public function safeDown()
    {
        $this->dropForeignKey("{$tableName}__created_by", $tableName);
        $this->dropForeignKey("{$tableName}__updated_by", $tableName);
        $this->dropForeignKey("{$tableName}__cms_user_id", $tableName);

        $this->dropTable($tableName);
    }
}


text:
"""
This module descibes how to train on a full dataset (when no testset is
built/specified) and how to query for specific predictions.
"""

from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

from surprise import KNNBasic
from surprise import Dataset
from surprise import evaluate

# Load the movielens-100k dataset and split it into 3 folds for
# cross-validation.
data = Dataset.load_builtin('ml-100k')

# Retrieve the trainset.
trainset = data.build_full_trainset()

# Build an algorithm, and train it.
algo = KNNBasic()
algo.train(trainset)

##########################################
# we can now query for specific predicions

uid = str(196)  # raw user id (as in the ratings file). They are **strings**!
iid = str(302)  # raw item id (as in the ratings file). They are **strings**!

# get a prediction for specific users and items.
pred = algo.predict(uid, iid, r_ui=4, verbose=True)

##########################################
# Tired? You can still call the 'split' method!
data.split(n_folds=3)
evaluate(algo, data)


text:
package BIDMach.viz

import BIDMat.{BMat,Mat,SBMat,CMat,DMat,FMat,FFilter,IMat,HMat,GDMat,GFilter,GLMat,GMat,GIMat,GSDMat,GSMat,LMat,SMat,SDMat,TMat,Image}
import BIDMat.MatFunctions._
import BIDMat.MatFunctions
import BIDMat.SciFunctions._
import java.util.concurrent.Future;
import BIDMach.Learner
import BIDMach.networks.Net
import BIDMach.networks.layers._
import javax.swing._;
import javax.swing.event._
import scala.collection.mutable.HashMap
import java.awt.event._;
import java.awt._;
import java.awt.image.BufferedImage
import ptolemy.plot._
import BIDMat.{Plotting,MyPlot,Image}
import jupyter.api.Publish

class ImageArray(name: String = "plot") {
    val id = {ImageArray.tot+=1; ImageArray.tot}
    //var server = {if (ImageArray.server == null) ImageArray.server = new WebServer(); ImageArray.server}
    var img: Image = null;
    val controlPanel: JPanel = new JPanel();
    val frame: JFrame = new JFrame;

    implicit val publish = new Mat.NonNotebook;

    def init(data: FMat) {
        img = Image(data);
        img.show;
        //frame = img.frame;
        frame.getContentPane().add(controlPanel)
        frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.PAGE_AXIS))
        //controlPanel.setLayout(new FlowLayout)//new BoxLayout(controlPanel,BoxLayout.PAGE_AXIS));
        controlPanel.setLayout(new BoxLayout(controlPanel,BoxLayout.PAGE_AXIS));
        frame.pack;
        frame.setVisible(true);
    }

    def plot_image(data_ :Mat, tensorFormat: Int = 1) {
        val data = utils.packImages(data_, tensorFormat)
        if (img == null)
            init(data);
        img.redraw(data);
    }

    def plot_web(data:IMat) {
        //server.send(scala.util.parsing.json.JSONObject())
    }

    def add_slider(name:String,callback:Int=>Float,initV:Int = 50, precision:Int = 2) {
        val p = new JPanel();
        val sliderLabel = new JLabel(name, SwingConstants.CENTER);
        val rangeLabel = new JLabel(("%."+precision+"f") format callback(initV), SwingConstants.CENTER);
        val slider = new JSlider(SwingConstants.HORIZONTAL,0,100,initV);
        slider.addChangeListener(new ChangeListener{
                                    override def stateChanged(e:ChangeEvent){
                                        val source = e.getSource().asInstanceOf[JSlider];
                                        val v = callback(source.getValue());
                                        rangeLabel.setText(("%."+precision+"f") format v)
                                    }})
        p.add(sliderLabel);
        p.add(slider);
        p.add(rangeLabel);
        controlPanel.add(p);
        frame.pack
    }

    def add_combobox(items: Array[String],callback:(Int, String)=>Unit) = {
        //val p = new JPanel();
        //val label = new JLabel("test", SwingConstants.CENTER);
        val box = new JComboBox(items);
        box.addItemListener(new ItemListener{
            override def itemStateChanged(e:ItemEvent){
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    callback(box.getSelectedIndex,e.getItem.toString)
                }
            }
        });
        ///p.add(label);
        //p.add(box);
        controlPanel.add(box);
        //if (frame != null)frame.pack;
        frame.pack
        box
    }

}

object ImageArray{
    var tot = 0
}


text:
package com.heritago.heritandroid.fragments;

import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;

import com.heritago.heritandroid.R;
import com.heritago.heritandroid.adapters.AddHeritageDetailAdapter;
import com.heritago.heritandroid.bus.BusProvider;
import com.heritago.heritandroid.bus.DidRemoveHeritageDetailItemEvent;
import com.heritago.heritandroid.model.HeritageDetail;
import com.squareup.otto.Subscribe;

import java.util.ArrayList;

/**
 * Created by onurtokoglu on 30/03/2017.
 */

public class AddHeritageFragment extends Fragment {
    private static final int CAMERA_PERMISSION_CODE = 1;
    private static final int CAMERA_REQUEST_CODE = 1;

    private ListView mListView;
    private AddHeritageDetailAdapter adapter;
    private ArrayList<HeritageDetail> detailList;

    private ImageButton locationButton;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onResume() {
        super.onResume();
        BusProvider.getInstance().register(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        BusProvider.getInstance().unregister(this);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_add_heritage, container, false);

        detailList = new ArrayList<>();
        adapter = new AddHeritageDetailAdapter(detailList);
        mListView = (ListView) view.findViewById(R.id.heritage_detail_list);
        mListView.setAdapter(adapter);

        Button addButton = (Button) view.findViewById(R.id.add_button);
        addButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                detailList.add(new HeritageDetail());
                adapter.notifyDataSetChanged();
                resizeDetailListView();
            }
        });

        ImageButton camera = (ImageButton) view.findViewById(R.id.camera_button);
        camera.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                openCamera();
            }
        });

        locationButton = (ImageButton) view.findViewById(R.id.location_button);

        return view;
    }

    @Subscribe public void didRemoveHeritageDetailItemEvent(DidRemoveHeritageDetailItemEvent event){
        resizeDetailListView();
    }

    private void resizeDetailListView(){
        Log.d("List",detailList.size()+"");
        if (mListView.getChildCount() > 0){
            int height = mListView.getChildAt(0).getHeight();
            if (mListView.getCount() > 0){
                mListView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height*mListView.getCount()));
            }
        }
    }

    private void openCamera(){
        Toast.makeText(getActivity(), "Open camera", Toast.LENGTH_SHORT).show();
        if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED){
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                requestPermissions(new String[]{Manifest.permission.CAMERA}, CAMERA_PERMISSION_CODE);
            }
        }else{
            Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
            startActivityForResult(intent, CAMERA_REQUEST_CODE);
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        if (requestCode == CAMERA_PERMISSION_CODE){
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
                Toast.makeText(getActivity(), "Permission granted", Toast.LENGTH_SHORT).show();
                openCamera();
            }else{
                Toast.makeText(getActivity(), "Permission denied", Toast.LENGTH_SHORT).show();
            }
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == CAMERA_REQUEST_CODE && resultCode == Activity.RESULT_OK){
            Toast.makeText(getActivity(), "Activity Result", Toast.LENGTH_SHORT).show();
            Bitmap photo = (Bitmap) data.getExtras().get("data");
            locationButton.setImageBitmap(photo);
        }else{
            super.onActivityResult(requestCode, resultCode, data);
        }
    }
}


text:
package io.cdap.plugin.aggregator;

import com.google.common.collect.ImmutableList;
import io.cdap.cdap.api.artifact.ArtifactSummary;
import io.cdap.cdap.api.data.format.StructuredRecord;
import io.cdap.cdap.api.data.schema.Schema;
import io.cdap.cdap.api.dataset.table.Table;
import io.cdap.cdap.datapipeline.DataPipelineApp;
import io.cdap.cdap.datapipeline.SmartWorkflow;
import io.cdap.cdap.etl.api.batch.BatchAggregator;
import io.cdap.cdap.etl.mock.batch.MockSink;
import io.cdap.cdap.etl.mock.batch.MockSource;
import io.cdap.cdap.etl.mock.test.HydratorTestBase;
import io.cdap.cdap.etl.mock.validation.MockFailureCollector;
import io.cdap.cdap.etl.proto.v2.ETLBatchConfig;
import io.cdap.cdap.etl.proto.v2.ETLPlugin;
import io.cdap.cdap.etl.proto.v2.ETLStage;
import io.cdap.cdap.format.StructuredRecordStringConverter;
import io.cdap.cdap.proto.ProgramRunStatus;
import io.cdap.cdap.proto.artifact.AppRequest;
import io.cdap.cdap.proto.id.ApplicationId;
import io.cdap.cdap.proto.id.ArtifactId;
import io.cdap.cdap.proto.id.NamespaceId;
import io.cdap.cdap.test.ApplicationManager;
import io.cdap.cdap.test.DataSetManager;
import io.cdap.cdap.test.TestConfiguration;
import io.cdap.cdap.test.WorkflowManager;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.mockito.internal.util.reflection.FieldSetter;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
 * Test class for Pivot plugin
 */
public class PivotTest extends HydratorTestBase {
  @ClassRule
  public static final TestConfiguration CONFIG = new TestConfiguration("explore.enabled", false);

  private static final ArtifactSummary APP_ARTIFACT_PIPELINE =
    new ArtifactSummary("data-pipeline", "1.0.0");

  @BeforeClass
  public static void setupTestClass() throws Exception {
    ArtifactId parentArtifactPipeline =
      NamespaceId.DEFAULT.artifact(APP_ARTIFACT_PIPELINE.getName(), APP_ARTIFACT_PIPELINE.getVersion());

    setupBatchArtifacts(parentArtifactPipeline, DataPipelineApp.class);

    addPluginArtifact(NamespaceId.DEFAULT.artifact("pivot", "1.0.0"),
                      parentArtifactPipeline, Pivot.class);
  }

  private static final Schema INPUT_SCHEMA = Schema.recordOf(
    "purchase",
    Schema.Field.of("Quarter", Schema.of(Schema.Type.STRING)),
    Schema.Field.of("Product", Schema.of(Schema.Type.STRING)),
    Schema.Field.of("Brand", Schema.of(Schema.Type.STRING)),
    Schema.Field.of("Sales", Schema.of(Schema.Type.INT)),
    Schema.Field.of("ShopID", Schema.of(Schema.Type.INT)));

  List<StructuredRecord> inputData = ImmutableList.of(
    //q1
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q1").set("Product", "Shoes").set("Brand", "Nike")
      .set("Sales", 50).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q1").set("Product", "Shirts").set("Brand", "Nike")
      .set("Sales", 20).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q1").set("Product", "Socks").set("Brand", "Reebok")
      .set("Sales", 40).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q1").set("Product", "Shirts").set("Brand", "Reebok")
      .set("Sales", 60).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q1").set("Product", "Shoes").set("Brand", "Reebok")
      .set("Sales", 50).set("ShopID", 1).build(),

    //q2
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q2").set("Product", "Shoes").set("Brand", "Nike")
      .set("Sales", 20).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q2").set("Product", "Shoes").set("Brand", "Reebok")
      .set("Sales", 30).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q2").set("Product", "Socks").set("Brand", "Nike")
      .set("Sales", 40).set("ShopID", 1).build(),

    //q3
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q3").set("Product", "Shoes").set("Brand", "Nike")
      .set("Sales", 50).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q3").set("Product", "Shoes").set("Brand", "Reebok")
      .set("Sales", 30).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q3").set("Product", "Socks").set("Brand", "Reebok")
      .set("Sales", 40).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q3").set("Product", "Socks").set("Brand", "Nike")
      .set("Sales", 20).set("ShopID", 1).build(),

    //q4
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q4").set("Product", "Shoes").set("Brand", "Reebok")
      .set("Sales", 10).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q4").set("Product", "Shirts").set("Brand", "Reebok")
      .set("Sales", 20).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q4").set("Product", "Socks").set("Brand", "Reebok")
      .set("Sales", 30).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q4").set("Product", "Shoes").set("Brand", "Nike")
      .set("Sales", 40).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q4").set("Product", "Shirts").set("Brand", "Nike")
      .set("Sales", 50).set("ShopID", 1).build(),
    StructuredRecord.builder(INPUT_SCHEMA).set("Quarter", "Q4").set("Product", "Socks").set("Brand", "Nike")
      .set("Sales", 60).set("ShopID", 1).build()
  );

  // SUM By Product per quarter
  private static final Schema EXPECTED_SUM_BY_PRODUCT_PER_QUARTER_SCHEMA = Schema.recordOf(
    "sumbyproductperquarter",
    Schema.Field.of("Product", Schema.of(Schema.Type.STRING)),
    Schema.Field.of("Q1_sum", Schema.nullableOf(Schema.of(Schema.Type.INT))),
    Schema.Field.of("Q2_sum", Schema.nullableOf(Schema.of(Schema.Type.INT))),
    Schema.Field.of("Q3_sum", Schema.nullableOf(Schema.of(Schema.Type.INT))),
    Schema.Field.of("Q4_sum", Schema.nullableOf(Schema.of(Schema.Type.INT)))
  );

  List<StructuredRecord> expectedSumOfSalesByProductPerQuarter = ImmutableList.of(
    StructuredRecord.builder(EXPECTED_SUM_BY_PRODUCT_PER_QUARTER_SCHEMA)
      .set("Product", "Shoes")
      .set("Q1_sum", 100)
      .set("Q2_sum", 50)
      .set("Q3_sum", 80)
      .set("Q4_sum", 50)
      .build(),
    StructuredRecord.builder(EXPECTED_SUM_BY_PRODUCT_PER_QUARTER_SCHEMA)
      .set("Product", "Socks")
      .set("Q1_sum", 40)
      .set("Q2_sum", 40)
      .set("Q3_sum", 60)
      .set("Q4_sum", 90)
      .build(),
    StructuredRecord.builder(EXPECTED_SUM_BY_PRODUCT_PER_QUARTER_SCHEMA)
      .set("Product", "Shirts")
      .set("Q1_sum", 80)
      .set("Q2_sum", null)
      .set("Q3_sum", null)
      .set("Q4_sum", 70)
      .build()
  );

  // SUM By Brand per quarter
  private static final Schema EXPECTED_SUM_BY_BRAND_PER_QUARTER_SCHEMA = Schema.recordOf(
    "sumbyproductperquarter",
    Schema.Field.of("Brand", Schema.of(Schema.Type.STRING)),
    Schema.Field.of("Q1_total", Schema.nullableOf(Schema.of(Schema.Type.INT))),
    Schema.Field.of("Q2_total", Schema.nullableOf(Schema.of(Schema.Type.INT))),
    Schema.Field.of("Q3_total", Schema.nullableOf(Schema.of(Schema.Type.INT))),
    Schema.Field.of("Q4_total", Schema.nullableOf(Schema.of(Schema.Type.INT)))
  );

  // SUM By Brand and Product per quarter
  private static final Schema EXPECTED_SUM_BY_BRAND_AND_PRODUCT_PER_QUARTER_SCHEMA = Schema.recordOf(
    "sumbybrandandproductperquarter",
    Schema.Field.of("Brand", Schema.of(Schema.Type.STRING)),
    Schema.Field.of("Product", Schema.of(Schema.Type.STRING)),
    Schema.Field.of("Q1_total", Schema.nullableOf(Schema.of(Schema.Type.INT))),
    Schema.Field.of("Q2_total", Schema.nullableOf(Schema.of(Schema.Type.INT))),
    Schema.Field.of("Q3_total", Schema.nullableOf(Schema.of(Schema.Type.INT))),
    Schema.Field.of("Q4_total", Schema.nullableOf(Schema.of(Schema.Type.INT)))
  );

  List<StructuredRecord> expectedSumOfSalesByBrandPerQuarter = ImmutableList.of(
    StructuredRecord.builder(EXPECTED_SUM_BY_BRAND_PER_QUARTER_SCHEMA)
      .set("Brand", "Nike")
      .set("Q1_total", 70)
      .set("Q2_total", 60)
      .set("Q3_total", 70)
      .set("Q4_total", 150)
      .build(),
    StructuredRecord.builder(EXPECTED_SUM_BY_BRAND_PER_QUARTER_SCHEMA)
      .set("Brand", "Reebok")
      .set("Q1_total", 150)
      .set("Q2_total", 30)
      .set("Q3_total", 70)
      .set("Q4_total", 60)
      .build()
  );

  List<StructuredRecord> expectedSumOfSalesByBrandAndProductPerQuarter = ImmutableList.of(
    StructuredRecord.builder(EXPECTED_SUM_BY_BRAND_AND_PRODUCT_PER_QUARTER_SCHEMA)
      .set("Brand", "Nike")
      .set("Product", "Shirts")
      .set("Q1_total", 20)
      .set("Q2_total", null)
      .set("Q3_total", null)
      .set("Q4_total", 50)
      .build(),
    StructuredRecord.builder(EXPECTED_SUM_BY_BRAND_AND_PRODUCT_PER_QUARTER_SCHEMA)
      .set("Brand", "Nike")
      .set("Product", "Shoes")
      .set("Q1_total", 50)
      .set("Q2_total", 20)
      .set("Q3_total", 50)
      .set("Q4_total", 40)
      .build(),
    StructuredRecord.builder(EXPECTED_SUM_BY_BRAND_AND_PRODUCT_PER_QUARTER_SCHEMA)
      .set("Brand", "Nike")
      .set("Product", "Socks")
      .set("Q1_total", null)
      .set("Q2_total", 40)
      .set("Q3_total", 20)
      .set("Q4_total", 60)
      .build(),
    StructuredRecord.builder(EXPECTED_SUM_BY_BRAND_AND_PRODUCT_PER_QUARTER_SCHEMA)
      .set("Brand", "Reebok")
      .set("Product", "Shirts")
      .set("Q1_total", 60)
      .set("Q2_total", null)
      .set("Q3_total", null)
      .set("Q4_total", 20)
      .build(),
    StructuredRecord.builder(EXPECTED_SUM_BY_BRAND_AND_PRODUCT_PER_QUARTER_SCHEMA)
      .set("Brand", "Reebok")
      .set("Product", "Shoes")
      .set("Q1_total", 50)
      .set("Q2_total", 30)
      .set("Q3_total", 30)
      .set("Q4_total", 10)
      .build(),
    StructuredRecord.builder(EXPECTED_SUM_BY_BRAND_AND_PRODUCT_PER_QUARTER_SCHEMA)
      .set("Brand", "Reebok")
      .set("Product", "Socks")
      .set("Q1_total", 40)
      .set("Q2_total", null)
      .set("Q3_total", 40)
      .set("Q4_total", 30)
      .build()
  );

  // SUM By Product per quarter
  private static final Schema EXPECTED_SUM_BY_PRODUCT_PER_QUARTER_WITH_ALIAS_SCHEMA = Schema.recordOf(
    "sumbyproductperquarterwithalias",
    Schema.Field.of("Product", Schema.of(Schema.Type.STRING)),
    Schema.Field.of("Quarter_1_sum", Schema.nullableOf(Schema.of(Schema.Type.INT))),
    Schema.Field.of("Quarter_2_sum", Schema.nullableOf(Schema.of(Schema.Type.INT))),
    Schema.Field.of("Q3_sum", Schema.nullableOf(Schema.of(Schema.Type.INT))),
    Schema.Field.of("Q4_sum", Schema.nullableOf(Schema.of(Schema.Type.INT)))
  );
  List<StructuredRecord> expectedSumOfSalesByProductPerQuarterWithDefaults = ImmutableList.of(
    StructuredRecord.builder(EXPECTED_SUM_BY_PRODUCT_PER_QUARTER_WITH_ALIAS_SCHEMA)
      .set("Product", "Shoes")
      .set("Quarter_1_sum", 100)
      .set("Quarter_2_sum", 50)
      .set("Q3_sum", 80)
      .set("Q4_sum", 50)
      .build(),
    StructuredRecord.builder(EXPECTED_SUM_BY_PRODUCT_PER_QUARTER_WITH_ALIAS_SCHEMA)
      .set("Product", "Socks")
      .set("Quarter_1_sum", 40)
      .set("Quarter_2_sum", 40)
      .set("Q3_sum", 60)
      .set("Q4_sum", 90)
      .build(),
    StructuredRecord.builder(EXPECTED_SUM_BY_PRODUCT_PER_QUARTER_WITH_ALIAS_SCHEMA)
      .set("Product", "Shirts")
      .set("Quarter_1_sum", 80)
      .set("Quarter_2_sum", 0)
      .set("Q3_sum", 0)
      .set("Q4_sum", 70)
      .build()
  );

  // MIN/MAX with String value per quarter
  private static final Schema EXPECTED_MIN_MAX_BRAND_PER_QUARTER_SCHEMA = Schema.recordOf(
    "minmaxproductperquarter",
    Schema.Field.of("Product", Schema.of(Schema.Type.STRING)),
    Schema.Field.of("Q1_min", Schema.nullableOf(Schema.of(Schema.Type.STRING))),
    Schema.Field.of("Q2_min", Schema.nullableOf(Schema.of(Schema.Type.STRING))),
    Schema.Field.of("Q3_min", Schema.nullableOf(Schema.of(Schema.Type.STRING))),
    Schema.Field.of("Q4_min", Schema.nullableOf(Schema.of(Schema.Type.STRING))),

    Schema.Field.of("Q1_max", Schema.nullableOf(Schema.of(Schema.Type.STRING))),
    Schema.Field.of("Q2_max", Schema.nullableOf(Schema.of(Schema.Type.STRING))),
    Schema.Field.of("Q3_max", Schema.nullableOf(Schema.of(Schema.Type.STRING))),
    Schema.Field.of("Q4_max", Schema.nullableOf(Schema.of(Schema.Type.STRING)))
  );

  List<StructuredRecord> expectedMinMaxProductPerQuarter = ImmutableList.of(
    StructuredRecord.builder(EXPECTED_MIN_MAX_BRAND_PER_QUARTER_SCHEMA)
      .set("Product", "Shirts")
      .set("Q1_min", "Nike")
      .set("Q2_min", null)
      .set("Q3_min", null)
      .set("Q4_min", "Nike")
      .set("Q1_max", "Reebok")
      .set("Q2_max", null)
      .set("Q3_max", null)
      .set("Q4_max", "Reebok")
      .build(),
    StructuredRecord.builder(EXPECTED_MIN_MAX_BRAND_PER_QUARTER_SCHEMA)
      .set("Product", "Shoes")
      .set("Q1_min", "Nike")
      .set("Q2_min", "Nike")
      .set("Q3_min", "Nike")
      .set("Q4_min", "Nike")
      .set("Q1_max", "Reebok")
      .set("Q2_max", "Reebok")
      .set("Q3_max", "Reebok")
      .set("Q4_max", "Reebok")
      .build(),
    StructuredRecord.builder(EXPECTED_MIN_MAX_BRAND_PER_QUARTER_SCHEMA)
      .set("Product", "Socks")
      .set("Q1_min", "Reebok")
      .set("Q2_min", "Nike")
      .set("Q3_min", "Nike")
      .set("Q4_min", "Nike")
      .set("Q1_max", "Reebok")
      .set("Q2_max", "Nike")
      .set("Q3_max", "Reebok")
      .set("Q4_max", "Reebok")
      .build()
  );

  private List<StructuredRecord> stageSetup(Map<String, String> properties) throws Exception {
    String inputDataset = UUID.randomUUID().toString();
    String outputDateset = UUID.randomUUID().toString();
    ETLBatchConfig config = ETLBatchConfig.builder()
      .addStage(new ETLStage("source", MockSource.getPlugin(inputDataset, INPUT_SCHEMA)))
      .addStage(new ETLStage("pivot", new ETLPlugin("Pivot",
                                                    BatchAggregator.PLUGIN_TYPE, properties)))
      .addStage(new ETLStage("sink", MockSink.getPlugin(outputDateset)))
      .addConnection("source", "pivot")
      .addConnection("pivot", "sink")
      .build();

    AppRequest<ETLBatchConfig> appRequest = new AppRequest<>(
      new ArtifactSummary(APP_ARTIFACT_PIPELINE.getName(), APP_ARTIFACT_PIPELINE.getVersion()), config);
    ApplicationId appId = NamespaceId.DEFAULT.app("pivot");
    ApplicationManager appManager = deployApplication(appId, appRequest);
    DataSetManager<Table> inputManager = getDataset(inputDataset);
    MockSource.writeInput(inputManager, inputData);

    WorkflowManager workflowManager = appManager.getWorkflowManager(SmartWorkflow.NAME);
    workflowManager.startAndWaitForRun(ProgramRunStatus.COMPLETED, 3, TimeUnit.MINUTES);

    DataSetManager<Table> outputManager = getDataset(outputDateset);
    return MockSink.readOutput(outputManager);
  }

  /**
   * Converts list of {@link StructuredRecord} to list of json strings
   *
   * @param structuredRecords {@link List<StructuredRecord>}
   * @return {@link List<String>}
   */
  private List<String> convertStructuredRecordListToJson(List<StructuredRecord> structuredRecords) {
    return structuredRecords.stream().map(s -> {
      try {
        return StructuredRecordStringConverter.toJsonString(s);
      } catch (IOException e) {
        Assert.fail(e.getMessage());
      }
      return null;
    }).sorted().collect(Collectors.toList());
  }

  @Test
  public void testSalesSumByProductPerQuarter() throws Exception {

    // Config props
    Map<String, String> properties = new HashMap<>();
    properties.put("pivotColumns", "Quarter=Q1,Q2,Q3,Q4");
    properties.put("pivotRow", "Product");
    properties.put("aggregates", "sum: sum(Sales)");

    // Run pipeline
    List<StructuredRecord> output = stageSetup(properties);

    Assert.assertEquals(expectedSumOfSalesByProductPerQuarter.size(), output.size());
    Assert.assertEquals(convertStructuredRecordListToJson(expectedSumOfSalesByProductPerQuarter),
                        convertStructuredRecordListToJson(output));
  }

  @Test
  public void testSalesSumByBrandPerQuarter() throws Exception {

    // Config props
    Map<String, String> properties = new HashMap<>();
    properties.put("pivotColumns", "Quarter=Q1,Q2,Q3,Q4");
    properties.put("pivotRow", "Brand");
    properties.put("aggregates", "total: sum(Sales)");

    // Run pipeline
    List<StructuredRecord> output = stageSetup(properties);

    Assert.assertEquals(expectedSumOfSalesByBrandPerQuarter.size(), output.size());
    List<String> expected = convertStructuredRecordListToJson(expectedSumOfSalesByBrandPerQuarter);
    List<String> actual = convertStructuredRecordListToJson(output);
    Assert.assertEquals(expected, actual);
  }

  @Test
  public void testMinMaxFunctionWithStringValue() throws Exception {

    // Config props
    Map<String, String> properties = new HashMap<>();
    properties.put("pivotColumns", "Quarter=Q1,Q2,Q3,Q4");
    properties.put("pivotRow", "Product");
    properties.put("aggregates", "min: min(Brand),max: max(Brand)");

    // Run pipeline
    List<StructuredRecord> output = stageSetup(properties);

    Assert.assertEquals(expectedMinMaxProductPerQuarter.size(), output.size());
    List<String> expected = convertStructuredRecordListToJson(expectedMinMaxProductPerQuarter);
    List<String> actual = convertStructuredRecordListToJson(output);
    Assert.assertEquals(expected, actual);
  }

  @Test
  public void testSalesSumByProductPerQuarterWithDefaultsAndAlias() throws Exception {

    // Config props
    Map<String, String> properties = new HashMap<>();
    properties.put("pivotColumns", "Quarter=Q1,Q2,Q3,Q4");
    properties.put("pivotRow", "Product");
    properties.put("aggregates", "sum: sum(Sales)");
    properties.put("defaultValue", "0");
    properties.put("fieldAliases", "Q1_sum:Quarter_1_sum,Q2_sum:Quarter_2_sum");

    // Run pipeline
    List<StructuredRecord> output = stageSetup(properties);

    Assert.assertEquals(expectedSumOfSalesByProductPerQuarterWithDefaults.size(), output.size());
    Assert.assertEquals(convertStructuredRecordListToJson(expectedSumOfSalesByProductPerQuarterWithDefaults),
                        convertStructuredRecordListToJson(output));
  }

  @Test
  public void testConfigWithInvalidPivotColumns() throws NoSuchFieldException {
    // Config props
    MockFailureCollector mockFailureCollector = new MockFailureCollector();
    PivotConfig config = new PivotConfig();
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("pivotColumns"),
                         "QuarterQ1,Q2,Q3,Q4");
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("pivotRow"),
                         "Product");
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("aggregates"),
                         "sum: sum(Sales)");
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("defaultValue"),
                         "0");
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("fieldAliases"),
                         "Q1_sum:Quarter_1_sum,Q2_sum:Quarter_2_sum");
    try {
      config.validate(INPUT_SCHEMA, mockFailureCollector);
      Assert.fail();
    } catch (Exception exception) {
      Assert.assertEquals(2, mockFailureCollector.getValidationFailures().size());
      Assert.assertEquals(PivotConfig.FIELD_NAME_PIVOT_COLUMNS, mockFailureCollector.getValidationFailures()
        .get(0).getCauses().get(0).getAttribute("stageConfig"));
    }
  }

  @Test
  public void testConfigWithInvalidAliasField() throws NoSuchFieldException {
    // Config props
    MockFailureCollector mockFailureCollector = new MockFailureCollector();
    PivotConfig config = new PivotConfig();
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("pivotColumns"),
                         "Quarter=Q1,Q2,Q3,Q4");
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("pivotRow"),
                         "Product");
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("aggregates"),
                         "sum: sum(Sales)");
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("defaultValue"),
                         "0");
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("fieldAliases"),
                         "Q1_sumQuarter_1_sum,Q2_sum:Quarter_2_sum");
    try {
      config.validate(INPUT_SCHEMA, mockFailureCollector);
      Assert.fail();
    } catch (Exception exception) {
      Assert.assertEquals(1, mockFailureCollector.getValidationFailures().size());
      Assert.assertEquals(PivotConfig.FIELD_NAME_FIELD_ALIASES, mockFailureCollector.getValidationFailures()
        .get(0).getCauses().get(0).getAttribute("stageConfig"));
    }
  }

  @Test
  public void testConfigWithInvalidAggregateField() throws NoSuchFieldException {
    // Config props
    MockFailureCollector mockFailureCollector = new MockFailureCollector();
    PivotConfig config = new PivotConfig();
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("pivotColumns"),
                         "Quarter=Q1,Q2,Q3,Q4");
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("pivotRow"),
                         "Product");
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("aggregates"),
                         "sum: sum()");
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("defaultValue"),
                         "0");
    FieldSetter.setField(config, PivotConfig.class.getDeclaredField("fieldAliases"),
                         "Q1_sum:Quarter_1_sum,Q2_sum:Quarter_2_sum");
    try {
      config.validate(INPUT_SCHEMA, mockFailureCollector);
      Assert.fail();
    } catch (Exception exception) {
      Assert.assertEquals(2, mockFailureCollector.getValidationFailures().size());
      Assert.assertEquals(PivotConfig.FIELD_NAME_AGGREGATES, mockFailureCollector.getValidationFailures()
        .get(0).getCauses().get(0).getAttribute("stageConfig"));
    }
  }

  @Test
  public void testSalesSumByBrandAndProductPerQuarter() throws Exception {
    // Config props
    Map<String, String> properties = new HashMap<>();
    properties.put("pivotColumns", "Quarter=Q1,Q2,Q3,Q4");
    properties.put("pivotRow", "Brand,Product");
    properties.put("aggregates", "total: sum(Sales)");

    // Run pipeline
    List<StructuredRecord> output = stageSetup(properties);

    Assert.assertEquals(expectedSumOfSalesByBrandAndProductPerQuarter.size(), output.size());
    List<String> expected = convertStructuredRecordListToJson(expectedSumOfSalesByBrandAndProductPerQuarter);
    List<String> actual = convertStructuredRecordListToJson(output);
    Assert.assertEquals(expected, actual);
  }
}


text:
package org.apache.flink.api.common.state;

import org.apache.flink.annotation.PublicEvolving;
import org.apache.flink.api.common.functions.AggregateFunction;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.common.typeutils.TypeSerializer;

import static org.apache.flink.util.Preconditions.checkNotNull;

/**
 * A StateDescriptor for {@link AggregatingState}.
 *
 *
The type internally stored in the state is the type of the {@code Accumulator} of the
 * {@code AggregateFunction}.
 *
 * @param <IN> The type of the values that are added to the state.
 * @param <ACC> The type of the accumulator (intermediate aggregation state).
 * @param <OUT> The type of the values that are returned from the state.
 */
@PublicEvolving
public class AggregatingStateDescriptor<IN, ACC, OUT> extends StateDescriptor<AggregatingState<IN, OUT>, ACC> {
	private static final long serialVersionUID = 1L;

	/** The aggregation function for the state */
	private final AggregateFunction<IN, ACC, OUT> aggFunction;

	/**
	 * Creates a new state descriptor with the given name, function, and type.
	 *
	 *
If this constructor fails (because it is not possible to describe the type via a class),
	 * consider using the {@link #AggregatingStateDescriptor(String, AggregateFunction, TypeInformation)} constructor.
	 *
	 * @param name The (unique) name for the state.
	 * @param aggFunction The {@code AggregateFunction} used to aggregate the state.
	 * @param stateType The type of the accumulator. The accumulator is stored in the state.
	 */
	public AggregatingStateDescriptor(
			String name,
			AggregateFunction<IN, ACC, OUT> aggFunction,
			Class<ACC> stateType) {

		super(name, stateType, null);
		this.aggFunction = checkNotNull(aggFunction);
	}

	/**
	 * Creates a new {@code ReducingStateDescriptor} with the given name and default value.
	 *
	 * @param name The (unique) name for the state.
	 * @param aggFunction The {@code AggregateFunction} used to aggregate the state.
	 * @param stateType The type of the accumulator. The accumulator is stored in the state.
	 */
	public AggregatingStateDescriptor(
			String name,
			AggregateFunction<IN, ACC, OUT> aggFunction,
			TypeInformation<ACC> stateType) {

		super(name, stateType, null);
		this.aggFunction = checkNotNull(aggFunction);
	}

	/**
	 * Creates a new {@code ValueStateDescriptor} with the given name and default value.
	 *
	 * @param name The (unique) name for the state.
	 * @param aggFunction The {@code AggregateFunction} used to aggregate the state.
	 * @param typeSerializer The serializer for the accumulator. The accumulator is stored in the state.
	 */
	public AggregatingStateDescriptor(
			String name,
			AggregateFunction<IN, ACC, OUT> aggFunction,
			TypeSerializer<ACC> typeSerializer) {

		super(name, typeSerializer, null);
		this.aggFunction = checkNotNull(aggFunction);
	}

	// ------------------------------------------------------------------------

	@Override
	public AggregatingState<IN, OUT> bind(StateBinder stateBinder) throws Exception {
		return stateBinder.createAggregatingState(this);
	}

	/**
	 * Returns the aggregate function to be used for the state.
	 */
	public AggregateFunction<IN, ACC, OUT> getAggregateFunction() {
		return aggFunction;
	}

	@Override
	public Type getType() {
		return Type.AGGREGATING;
	}

	// ------------------------------------------------------------------------

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		else if (o != null && getClass() == o.getClass()) {
			AggregatingStateDescriptor<?, ?, ?> that = (AggregatingStateDescriptor<?, ?, ?>) o;
			return serializer.equals(that.serializer) && name.equals(that.name);
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		int result = serializer.hashCode();
		result = 31 * result + name.hashCode();
		return result;
	}

	@Override
	public String toString() {
		return "AggregatingStateDescriptor{" +
				"serializer=" + serializer +
				", aggFunction=" + aggFunction +
				'}';
	}
}


text:
using System;

namespace Xamarin.Forms.Controls
{
	public class AutomationIdGallery : ContentPage
	{

		public AutomationIdGallery ()
		{
			var scrollView = new ScrollView { AutomationId = "scrollMain" };
			var rootLayout = new StackLayout { AutomationId = "stckMain" };

			var btn = new Button {
				AutomationId = "btnTest1",
				Text = "Test1",
				Command = new Command (async () => await Navigation.PushModalAsync (new TestPage1 ()))
			};

			var btn2 = new Button {
				AutomationId = "btnTest2",
				Text = "Test2",
				Command = new Command (async () => await Navigation.PushModalAsync (new TestPage2 ()))
			};

			rootLayout.Children.Add (btn);
			rootLayout.Children.Add (btn2);

			var toolBarItem = new ToolbarItem { AutomationId = "tbItemHello", Text= "Hello", Command = new Command(async ()=> { await DisplayAlert("Hello","","ok"); }) };
			var toolBarItem2 = new ToolbarItem { AutomationId = "tbItemHello2", Order= ToolbarItemOrder.Secondary, Text= "Hello2", Command = new Command(async ()=> { await DisplayAlert("Hello2","","ok"); }) };

			ToolbarItems.Add (toolBarItem);
			ToolbarItems.Add (toolBarItem2);

			scrollView.Content = rootLayout;
			Content = scrollView;
		}

		internal class TestPage1 : ContentPage
		{
			public TestPage1 ()
			{
				var rootLayout = new StackLayout { AutomationId = "stckMain" };
				var btn = new Button {
					AutomationId = "popModal",
					Text = "Pop",
					Command = new Command (async () => await Navigation.PopModalAsync ())
				};
				rootLayout.Children.Add (btn);
				rootLayout.Children.Add (new ActivityIndicator { AutomationId = "actHello", IsRunning = true });
				rootLayout.Children.Add (new BoxView {
					AutomationId = "bxvHello",
					WidthRequest = 40,
					HeightRequest = 40,
					BackgroundColor = Color.Red
				});
				rootLayout.Children.Add (new Button { AutomationId = "btnHello", Text = "Hello" });
				rootLayout.Children.Add (new DatePicker { AutomationId = "dtPicker", Date = DateTime.Parse ("01/01/2014") });
				rootLayout.Children.Add (new TimePicker { AutomationId = "tPicker", Time = new TimeSpan (14, 45, 50)  });
				rootLayout.Children.Add (new Label { AutomationId = "lblHello", Text = "Hello Label" });
				rootLayout.Children.Add (new Editor { AutomationId = "editorHello", Text = "Hello Editor" });
				rootLayout.Children.Add (new Entry { AutomationId = "entryHello", Text = "Hello Entry" });

				Content = rootLayout;
			}
		}

		internal class TestPage2 : ContentPage
		{
			public TestPage2 ()
			{
				var rootLayout = new StackLayout { AutomationId = "stckMain" };
				var btn = new Button {
					AutomationId = "popModal",
					Text = "Pop",
					Command = new Command (async () => await Navigation.PopModalAsync ())
				};
				rootLayout.Children.Add (btn);
				rootLayout.Children.Add (new Image { AutomationId = "imgHello", Source = "menuIcon" });
				rootLayout.Children.Add (new ListView {
					AutomationId = "lstView",
					ItemsSource = new string[2] { "one", "two" },
					HeightRequest = 50
				});
				rootLayout.Children.Add (new Picker { AutomationId = "pickerHello", Items = { "one", "two" } });
				rootLayout.Children.Add (new ProgressBar { AutomationId = "progressHello", Progress = 2 });
				rootLayout.Children.Add (new SearchBar { AutomationId = "srbHello", Text = "Hello Search" });
				rootLayout.Children.Add (new Slider { AutomationId = "sliHello", Value = 0.5 });
				rootLayout.Children.Add (new Stepper { AutomationId = "stepperHello", Value = 5 });
				rootLayout.Children.Add (new Switch { AutomationId = "switchHello" });
				rootLayout.Children.Add (new WebView {
					AutomationId = "webviewHello",
					WidthRequest = 100,
					HeightRequest = 50,
					Source = new UrlWebViewSource { Url = "http://blog.xamarin.com/" }
				});

				Content = rootLayout;
			}
		}

	}
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<TITLE>
org.jbox2d.common
</TITLE>

<META NAME="keywords" CONTENT="org.jbox2d.common package">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">

org.jbox2d.common

Classes

Color3f

Mat22

MathUtils

Settings

Sweep

Vec2

XForm


text:
<resources>
    <string name="app_name">RealSense Native Example</string>
</resources>


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Voice</title>
    <link rel="root" href=""/>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/jquery-ui-redmond.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style-vis.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/hint.css"/>

          home

          edit page
          issue tracker

          <gcse:search></gcse:search>

        This page pertains to UD version 2.

            It appears that you have Javascript disabled.
            Please consider enabling Javascript for this page to see the visualizations.

Voice: voice

  Values:
  Mid
  Cau
  MidCau

Voice is a

Mid: Middle

The middle voice

Examples

  ""

Cau: Causative

Contiguity is more often associated with

Examples

  ""

MidCau: Middle Causative

The middle causative voice.
Verbs assigned MidCau carry the middle ge and the causative at

Examples

ag̃okatkat o'-je-tayxi-da-at wamõat pe  "The man was married by the shaman" (Gomes 2006: 8 (46c))

Diffs

Prague Dependency Treebank

The PDT tagset does not distinguish Ptan from Plur and Coll from Sing,
therefore this distinction is not being made in the converted data.

Voice in other languages:

[abq]

[am]

[arr]

[bej]

[bg]

[ceb]

[cs]

[el]

[eme]

[en]

[fi]

[fr]

[gn]

[gub]

[hu]

[hy]

[myu]

[qpm]

[qtd]

[quc]

[ru]

[sv]

[tl]

[tpn]

[tr]

[tt]

[u]

[uk]

[urb]

[urj]

© 2014–2021
            Universal Dependencies contributors.
            Site powered by Annodoc and brat
.