text:
package org.apache.hc.core5.http.impl.nio;

import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.Internal;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.ConnectionReuseStrategy;
import org.apache.hc.core5.http.ContentLengthStrategy;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
import org.apache.hc.core5.http.impl.Http1StreamListener;
import org.apache.hc.core5.http.nio.NHttpMessageParserFactory;
import org.apache.hc.core5.http.nio.NHttpMessageWriterFactory;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.reactor.ProtocolIOSession;
import org.apache.hc.core5.util.Args;

/**
 * {@link ClientHttp1StreamDuplexer} factory.
 *
 * @since 5.0
 */
@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
@Internal
public final class ClientHttp1StreamDuplexerFactory {

    private final HttpProcessor httpProcessor;
    private final H1Config h1Config;
    private final CharCodingConfig charCodingConfig;
    private final ConnectionReuseStrategy connectionReuseStrategy;
    private final NHttpMessageParserFactory<HttpResponse> responseParserFactory;
    private final NHttpMessageWriterFactory<HttpRequest> requestWriterFactory;
    private final ContentLengthStrategy incomingContentStrategy;
    private final ContentLengthStrategy outgoingContentStrategy;
    private final Http1StreamListener streamListener;

    public ClientHttp1StreamDuplexerFactory(
            final HttpProcessor httpProcessor,
            final H1Config h1Config,
            final CharCodingConfig charCodingConfig,
            final ConnectionReuseStrategy connectionReuseStrategy,
            final NHttpMessageParserFactory<HttpResponse> responseParserFactory,
            final NHttpMessageWriterFactory<HttpRequest> requestWriterFactory,
            final ContentLengthStrategy incomingContentStrategy,
            final ContentLengthStrategy outgoingContentStrategy,
            final Http1StreamListener streamListener) {
        this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
        this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
        this.charCodingConfig = charCodingConfig !=  null ? charCodingConfig : CharCodingConfig.DEFAULT;
        this.connectionReuseStrategy = connectionReuseStrategy != null ? connectionReuseStrategy :
                DefaultConnectionReuseStrategy.INSTANCE;
        this.responseParserFactory = responseParserFactory != null ? responseParserFactory :
                new DefaultHttpResponseParserFactory(h1Config);
        this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory :
                DefaultHttpRequestWriterFactory.INSTANCE;
        this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
                DefaultContentLengthStrategy.INSTANCE;
        this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
                DefaultContentLengthStrategy.INSTANCE;
        this.streamListener = streamListener;
    }

    public ClientHttp1StreamDuplexerFactory(
            final HttpProcessor httpProcessor,
            final H1Config h1Config,
            final CharCodingConfig charCodingConfig,
            final ConnectionReuseStrategy connectionReuseStrategy,
            final NHttpMessageParserFactory<HttpResponse> responseParserFactory,
            final NHttpMessageWriterFactory<HttpRequest> requestWriterFactory,
            final Http1StreamListener streamListener) {
        this(httpProcessor, h1Config, charCodingConfig, connectionReuseStrategy,
                responseParserFactory, requestWriterFactory, null, null, streamListener);
    }

    public ClientHttp1StreamDuplexerFactory(
            final HttpProcessor httpProcessor,
            final H1Config h1Config,
            final CharCodingConfig charCodingConfig,
            final Http1StreamListener streamListener) {
        this(httpProcessor, h1Config, charCodingConfig, null, null, null, streamListener);
    }

    public ClientHttp1StreamDuplexerFactory(
            final HttpProcessor httpProcessor,
            final H1Config h1Config,
            final CharCodingConfig charCodingConfig) {
        this(httpProcessor, h1Config, charCodingConfig, null);
    }

    public ClientHttp1StreamDuplexer create(final ProtocolIOSession ioSession) {
        return new ClientHttp1StreamDuplexer(
                ioSession,
                httpProcessor,
                h1Config,
                charCodingConfig,
                connectionReuseStrategy,
                responseParserFactory.create(),
                requestWriterFactory.create(),
                incomingContentStrategy,
                outgoingContentStrategy,
                streamListener);
    }

}


text:
var broccoliConf = "value";
broccoliConf
let test = testGlobal
test

redpajama_set_name: RedPajamaGithub


text:
<?php

final class DiffusionTagListController extends DiffusionController {

  public function shouldAllowPublic() {
    return true;
  }

  public function handleRequest(AphrontRequest $request) {
    $response = $this->loadDiffusionContext();
    if ($response) {
      return $response;
    }

    $viewer = $this->getViewer();
    $drequest = $this->getDiffusionRequest();
    $repository = $drequest->getRepository();

    $pager = id(new PHUIPagerView())
      ->readFromRequest($request);

    $params = array(
      'limit' => $pager->getPageSize() + 1,
      'offset' => $pager->getOffset(),
    );

    if (strlen($drequest->getSymbolicCommit())) {
      $is_commit = true;
      $params['commit'] = $drequest->getSymbolicCommit();
    } else {
      $is_commit = false;
    }

    switch ($repository->getVersionControlSystem()) {
      case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
        $conduit_result = $this->callConduitWithDiffusionRequest(
          'diffusion.tagsquery',
          $params);
        $tags = DiffusionRepositoryTag::newFromConduit($conduit_result);
        break;
    }
    $tags = $pager->sliceResults($tags);

    $content = null;

    $header = id(new PHUIHeaderView())
      ->setHeader(pht('Tags'))
      ->setHeaderIcon('fa-tags');

    if (!$tags) {
      $content = $this->renderStatusMessage(
        pht('No Tags'),
        $is_commit
          ? pht('This commit has no tags.')
          : pht('This repository has no tags.'));
    } else {
      $commits = id(new DiffusionCommitQuery())
        ->setViewer($viewer)
        ->withRepository($repository)
        ->withIdentifiers(mpull($tags, 'getCommitIdentifier'))
        ->needCommitData(true)
        ->execute();

      $view = id(new DiffusionTagListView())
        ->setTags($tags)
        ->setUser($viewer)
        ->setCommits($commits)
        ->setDiffusionRequest($drequest);

      $phids = $view->getRequiredHandlePHIDs();
      $handles = $this->loadViewerHandles($phids);
      $view->setHandles($handles);

      $content = $view;
    }

    $crumbs = $this->buildCrumbs(
      array(
        'tags' => true,
        'commit' => $drequest->getSymbolicCommit(),
      ));
    $crumbs->setBorder(true);

    $box = id(new PHUIObjectBoxView())
      ->setHeaderText($repository->getDisplayName())
      ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
      ->setTable($view)
      ->setPager($pager);

    $view = id(new PHUITwoColumnView())
      ->setHeader($header)
      ->setFooter(array(
        $box,
      ));

    return $this->newPage()
      ->setTitle(
        array(
          pht('Tags'),
          $repository->getDisplayName(),
        ))
      ->setCrumbs($crumbs)
      ->appendChild($view);
  }

}


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package app.metatron.discovery.domain.workbook;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.core.annotation.HandleBeforeCreate;
import org.springframework.data.rest.core.annotation.HandleBeforeDelete;
import org.springframework.data.rest.core.annotation.HandleBeforeSave;
import org.springframework.data.rest.core.annotation.RepositoryEventHandler;
import org.springframework.security.access.prepost.PreAuthorize;

import java.util.List;

import app.metatron.discovery.domain.images.Image;
import app.metatron.discovery.domain.images.ImageRepository;

/**
 * Created by kyungtaak on 2016. 5. 13..
 */
@RepositoryEventHandler(DashBoard.class)
public class DashBoardEventHandler {

  @Autowired
  DashboardRepository dashBoardRepository;

  @Autowired
  ImageRepository imageRepository;

  @HandleBeforeCreate
  @PreAuthorize("hasPermission(#dashBoard, 'PERM_WORKSPACE_WRITE_BOOK')")
  public void checkBeforeCreate(DashBoard dashBoard) {
    if(dashBoard.getWorkBook() != null) {
      dashBoard.setSeq(dashBoardRepository.countByWorkBook(dashBoard.getWorkBook()));
    }
  }

  @HandleBeforeSave
  @PreAuthorize("hasPermission(#dashBoard, 'PERM_WORKSPACE_WRITE_BOOK')")
  public void checkBeforeUpdate(DashBoard dashBoard) {
    // 이미지 처리
    if (StringUtils.isNotEmpty(dashBoard.getImageUrl())) {
      updateImages(dashBoard.getId());
    }

  }

  @HandleBeforeDelete
  @PreAuthorize("hasPermission(#dashBoard, 'PERM_WORKSPACE_WRITE_BOOK')")
  public void checkBeforeDelete(DashBoard dashBoard) {

    // 이미지 처리
    if (StringUtils.isNotEmpty(dashBoard.getImageUrl())) {
      deleteImages(dashBoard.getId());
    }

  }

  private void updateImages(String id) {
    List<Image> targetImages = imageRepository.findByDomainAndItemIdOrderByModifiedTimeDesc("page", id);
    if (CollectionUtils.isEmpty(targetImages)) {
      return;
    }

    if (targetImages.size() == 1) {
      targetImages.get(0).setEnabled(true);
      imageRepository.save(targetImages.get(0));
    } else {
      // 여러번 사진을 업로드한 경우
      for (int i = 0; i < targetImages.size(); i++) {
        if (i == 0) {
          targetImages.get(i).setEnabled(true);
          imageRepository.save(targetImages.get(i));
        } else {
          imageRepository.delete(targetImages.get(i));
        }
      }
    }
  }

  private void deleteImages(String id) {
    List<Image> targetImages = imageRepository.findByDomainAndItemIdOrderByModifiedTimeDesc("page", id);

    if (CollectionUtils.isEmpty(targetImages)) {
      return;
    }

    imageRepository.delete(targetImages);
  }
}


text:
var plugs = require('../plugs')
var h = require('hyperscript')

module.exports = {
  needs: {menu_items: 'map'},
  gives: {connection_status: true, menu: true},
  create: function (api) {

    var menu_items = api.menu_items //plugs.map(exports.menu_items = [])

    var status = h('div.status.error') //start off disconnected
    var list = h('div.menu.column', {style: 'display: none;'})

    var menu = h('div.column', status, list , {
      onmouseover: function (e) {
        list.style.display = 'flex'
      }, onmouseout: function () {
        list.style.display = 'none'
      }
    })

    setTimeout(function () {
      menu_items().forEach(function (el) {
        if(el)
          list.appendChild(el)
      })
    }, 0)

    return {
      connection_status: function (err) {
        if(err) status.classList.add('error')
        else    status.classList.remove('error')
      },
      menu: function () {
        return menu
      }
    }
  }
}


text:
import EditorUI = require("../EditorUI");
import EditorEvents = require("../../editor/EditorEvents");
import ModalWindow = require("./ModalWindow");

class ResourceSelection extends ModalWindow {

    folderList: Atomic.UIListView;
    callback: (returnObject: any, args: any) => void;
    args: any;
    resourceType: string;

    populate(importerType: string, resourceType: string) {

        var db = ToolCore.assetDatabase;
        var assets = db.getAssetsByImporterType(importerType, resourceType);

        for (var i in assets) {

            var asset = assets[i];

            if (importerType == "JavascriptImporter") {
                if (!(<ToolCore.JavascriptImporter>asset.importer).isComponentFile())
                    continue;
            }

            // TODO: Generalize this for other cache assets
            if (resourceType == "Animation") {

                var modelImporter = <ToolCore.ModelImporter>(asset.importer);
                var animations = modelImporter.getAnimations();

                if (animations.length) {

                    for (var i in animations) {

                        this.folderList.addRootItem(animations[i].animationName + " : " + asset.name, "", animations[i].name);

                    }

                }

            } else {

                this.folderList.addRootItem(asset.relativePath, "", asset.guid);

            }

        }

    }

    constructor(windowText: string, importerType: string, resourceType: string, callback: (asset: ToolCore.Asset, args: any) => void, args: any) {

        super();

        this.resourceType = resourceType;
        this.callback = callback;
        this.args = args;

        this.load("AtomicEditor/editor/ui/resourceselection.tb.txt");

        var foldercontainer = this.getWidget("resourcecontainer");

        var folderList = this.folderList = new Atomic.UIListView();

        folderList.rootList.id = "resourceList_";

        foldercontainer.addChild(folderList);

        this.populate(importerType, resourceType);

        this.text = windowText;
        this.setSize(800, 600);
        this.center();

    }

    handleWidgetEvent(ev: Atomic.UIWidgetEvent) {

        if (ev.count >= 2) {
            var id = ev.target.id;
            if (id == this.folderList.rootList.id) {
                this.selectFile();
            }
        }

        if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
            var id = ev.target.id;

            if (id == "select") {

                return this.selectFile();

            }

            if (id == "cancel") {

                this.hide();

                return true;
            }

        }

    }

    selectFile(): boolean {

        var id = this.folderList.selectedItemID;

        if (this.resourceType == "Animation") {

          if (id.length) {
              this.callback(Atomic.cache.getResource("Animation", id), this.args);
              this.hide();
              return true;
          }

          this.hide();
          return true;

        } else {

            if (id.length) {
                this.callback(ToolCore.assetDatabase.getAssetByGUID(id), this.args);
                this.hide();
                return true;
            }
        }
        return false;
    }
}

export = ResourceSelection;


text:
<?php

namespace Vidal\MainBundle\Entity;

use Doctrine\ORM\EntityRepository;

class DeliveryRepository extends EntityRepository
{
	public function getOrCreate($deliveryName)
	{
		$delivery = $this->_em->createQuery('SELECT d FROM EvrikaMainBundle:Delivery d WHERE d.name = :deliveryName')
			->setParameter('deliveryName', $deliveryName)
			->getOneOrNullResult();

		if (null == $delivery) {
			$delivery = new Delivery;
			$delivery->setName($deliveryName);
			$this->_em->persist($delivery);
			$this->_em->flush($delivery);
			$this->_em->refresh($delivery);
		}

		return $delivery;
	}
}


text:
html, body, div, form, h1, label, input, button {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Tahoma', sans-serif;
    background: url(img/formBackground.jpg) repeat;
}

form {
    width: 400px;
    padding-top: 11px;
    padding-left: 20px;
}

.row {
    border: 1px solid #A4BFDE;
    background-color: rgba(255,255,255,.3);
    float: left;
    margin-bottom: 2px;
    border-radius: 5px;
    width: 327px;
    padding: 5px;
}

h1 {
    font-size: 13px;
    color: #fff;
    float: left;
    margin-bottom: 8px;
    margin-top: 9px;
}

label {
    font-size: 13px;
    max-width: 100px;
    float: left;
    margin-top: 4px;
    margin-bottom: 4px;
    margin-left: 4px;
}

input[type="text"], input[type="email"], input[type="tel"], textarea {
    float: right;
    margin-right: 52px;
    width: 168px;
    font-size: 12px;
    padding: 3px 5px;
    background-color: #fff;
    border: 0 none;
    border-radius: 2px;
    margin-top: 3px;
}
textarea {
    height: 72px;
    margin-top: 2px;
    margin-bottom:8px;
}
input:focus, textarea:focus {
    background-color: #ccc;
}

button {
    float: left;
    margin: 8px 0 0 125px;
    background-color: #04152f;
    border: 0 none;
    border-radius: 20px;
    color: #fff;
    padding: 4px 15px;
    font-weight: normal;
    cursor: pointer;
    width: 90px;
}
button:hover {
    background-color: #142f58;
}

input#visa {
    margin-left: 20px;
}
.card-type input {float: left;}
.card-type label.title {max-width: 290px; width: 290px; padding-left: 0; margin-bottom: 10px; background: none;}
.card-type label {padding-left: 27px; margin-right: 5px; background: url(img/card-types.png) no-repeat;}
.card-type label.visa {background-position: 0 0;}
.card-type label.amex {background-position: 0 -17px;}


text: Please enable JavaScript to view the comments powered by Disqus.


text:
from django.conf.urls.defaults import patterns, url

from .views import IndexView, CreateView, UpdateView

urlpatterns = patterns('horizon.dashboards.admin.users.views',
    url(r'^$', IndexView.as_view(), name='index'),
    url(r'^(?P<user_id>[^/]+)/update/$', UpdateView.as_view(), name='update'),
    url(r'^create/$', CreateView.as_view(), name='create'))


text:
package no.hvl.dat104.dataaccess;

import no.hvl.dat104.model.ShoppingListEntity;

import java.util.List;

public interface IShoppingListEAO {

    void addShoppingList(ShoppingListEntity s);

    ShoppingListEntity findShoppingList(Integer id);

    void updateShoppingList(ShoppingListEntity s);

    void removeShoppingList(ShoppingListEntity id);

    List<ShoppingListEntity> allShoppingListEntity();

    List allItemsInShoppingList(ShoppingListEntity sl_id);
}


text:
package org.power.commons.lang.util;

import com.google.common.collect.Lists;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringEscapeUtils;

import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
 *
 * @author Geiger
 * @version 2013-05-22
 */
public class StringUtils extends org.apache.commons.lang3.StringUtils {
    private static final char[] DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
            .toCharArray();
    private static final char[] DIGITS_NOCASE = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
            .toCharArray();
    private static final char SEPARATOR = '_';
    private static final String CHARSET_NAME = "UTF-8";

    /**
     * 转换为字节数组
     *
     * @param str
     * @return
     */
    public static byte[] getBytes(String str) {
        if (str != null) {
            try {
                return str.getBytes(CHARSET_NAME);
            } catch (UnsupportedEncodingException e) {
                return null;
            }
        } else {
            return null;
        }
    }

    /**
     * 转换为字节数组
     *
     * @param bytes
     * @return
     */
    public static String toString(byte[] bytes) {
        try {
            return new String(bytes, CHARSET_NAME);
        } catch (UnsupportedEncodingException e) {
            return EMPTY;
        }
    }

    /**
     * 是否包含字符串
     *
     * @param str  验证字符串
     * @param strs 字符串组
     * @return 包含返回true
     */
    public static boolean inString(String str, String... strs) {
        if (str != null) {
            for (String s : strs) {
                if (str.equals(trim(s))) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 替换掉HTML标签方法
     */
    public static String replaceHtml(String html) {
        if (isBlank(html)) {
            return "";
        }
        String regEx = "<.+?>";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(html);
        String s = m.replaceAll("");
        return s;
    }

    /**
     * 替换为手机识别的HTML,去掉样式及属性,保留回车。
     *
     * @param html
     * @return
     */
    public static String replaceMobileHtml(String html) {
        if (html == null) {
            return "";
        }
        return html.replaceAll("<([a-z]+?)\\s+?.*?>", "<$1>");
    }

    /**
     * 替换为手机识别的HTML,去掉样式及属性,保留回车。
     *
     * @param txt
     * @return
     */
    public static String toHtml(String txt) {
        if (txt == null) {
            return "";
        }
        return replace(replace(Encodes.escapeHtml(txt), "\n", "
"), "\t", "    ");
    }

    /**
     * 缩略字符串(不区分中英文字符)
     *
     * @param str    目标字符串
     * @param length 截取长度
     * @return
     */
    public static String abbr(String str, int length) {
        if (str == null) {
            return "";
        }
        try {
            StringBuilder sb = new StringBuilder();
            int currentLength = 0;
            for (char c : replaceHtml(StringEscapeUtils.unescapeHtml4(str)).toCharArray()) {
                currentLength += String.valueOf(c).getBytes("UTF-8").length;
                if (currentLength <= length - 3) {
                    sb.append(c);
                } else {
                    sb.append("...");
                    break;
                }
            }
            return sb.toString();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return "";
    }

    public static String abbr2(String param, int length) {
        if (param == null) {
            return "";
        }
        StringBuffer result = new StringBuffer();
        int n = 0;
        char temp;
        boolean isCode = false; // 是不是HTML代码
        boolean isHTML = false; // 是不是HTML特殊字符,如
        for (int i = 0; i < param.length(); i++) {
            temp = param.charAt(i);
            if (temp == '<') {
                isCode = true;
            } else if (temp == '&') {
                isHTML = true;
            } else if (temp == '>' && isCode) {
                n = n - 1;
                isCode = false;
            } else if (temp == ';' && isHTML) {
                isHTML = false;
            }
            try {
                if (!isCode && !isHTML) {
                    n += String.valueOf(temp).getBytes("GBK").length;
                }
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }

            if (n <= length - 3) {
                result.append(temp);
            } else {
                result.append("...");
                break;
            }
        }
        // 取出截取字符串中的HTML标记
        String temp_result = result.toString().replaceAll("(>)[^<>]*(<?)",
                "$1$2");
        // 去掉不需要结素标记的HTML标记
        temp_result = temp_result
                .replaceAll(
                        "</?(AREA|BASE|BASEFONT|BODY|BR|COL|COLGROUP|DD|DT|FRAME|HEAD|HR|HTML|IMG|INPUT|ISINDEX|LI|LINK|META|OPTION|P|PARAM|TBODY|TD|TFOOT|TH|THEAD|TR|area|base|basefont|body|br|col|colgroup|dd|dt|frame|head|hr|html|img|input|isindex|li|link|meta|option|p|param|tbody|td|tfoot|th|thead|tr)[^<>]*/?>",
                        "");
        // 去掉成对的HTML标记
        temp_result = temp_result.replaceAll("<([a-zA-Z]+)[^<>]*>(.*?)</\\1>",
                "$2");
        // 用正则表达式取出标记
        Pattern p = Pattern.compile("<([a-zA-Z]+)[^<>]*>");
        Matcher m = p.matcher(temp_result);
        List<String> endHTML = Lists.newArrayList();
        while (m.find()) {
            endHTML.add(m.group(1));
        }
        // 补全不成对的HTML标记
        for (int i = endHTML.size() - 1; i >= 0; i--) {
            result.append("</");
            result.append(endHTML.get(i));
            result.append(">");
        }
        return result.toString();
    }

    /**
     * 转换为Double类型
     */
    public static Double toDouble(Object val) {
        if (val == null) {
            return 0D;
        }
        try {
            return Double.valueOf(trim(val.toString()));
        } catch (Exception e) {
            return 0D;
        }
    }

    /**
     * 转换为Float类型
     */
    public static Float toFloat(Object val) {
        return toDouble(val).floatValue();
    }

    /**
     * 转换为Long类型
     */
    public static Long toLong(Object val) {
        return toDouble(val).longValue();
    }

    /**
     * 转换为Integer类型
     */
    public static Integer toInteger(Object val) {
        return toLong(val).intValue();
    }

    /**
     * 驼峰命名法工具
     *
     * @return toCamelCase("hello_world") == "helloWorld"
     * toCapitalizeCamelCase("hello_world") == "HelloWorld"
     * toUnderScoreCase("helloWorld") = "hello_world"
     */
    public static String toCamelCase(String s) {
        if (s == null) {
            return null;
        }

        s = s.toLowerCase();

        StringBuilder sb = new StringBuilder(s.length());
        boolean upperCase = false;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);

            if (c == SEPARATOR) {
                upperCase = true;
            } else if (upperCase) {
                sb.append(Character.toUpperCase(c));
                upperCase = false;
            } else {
                sb.append(c);
            }
        }

        return sb.toString();
    }

    /**
     * 驼峰命名法工具
     *
     * @return toCamelCase("hello_world") == "helloWorld"
     * toCapitalizeCamelCase("hello_world") == "HelloWorld"
     * toUnderScoreCase("helloWorld") = "hello_world"
     */
    public static String toCapitalizeCamelCase(String s) {
        if (s == null) {
            return null;
        }
        s = toCamelCase(s);
        return s.substring(0, 1).toUpperCase() + s.substring(1);
    }

    /**
     * 驼峰命名法工具
     *
     * @return toCamelCase("hello_world") == "helloWorld"
     * toCapitalizeCamelCase("hello_world") == "HelloWorld"
     * toUnderScoreCase("helloWorld") = "hello_world"
     */
    public static String toUnderScoreCase(String s) {
        if (s == null) {
            return null;
        }

        StringBuilder sb = new StringBuilder();
        boolean upperCase = false;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);

            boolean nextUpperCase = true;

            if (i < (s.length() - 1)) {
                nextUpperCase = Character.isUpperCase(s.charAt(i + 1));
            }

            if ((i > 0) && Character.isUpperCase(c)) {
                if (!upperCase || !nextUpperCase) {
                    sb.append(SEPARATOR);
                }
                upperCase = true;
            } else {
                upperCase = false;
            }

            sb.append(Character.toLowerCase(c));
        }

        return sb.toString();
    }

    /**
     * 如果不为空,则设置值
     *
     * @param target
     * @param source
     */
    public static void setValueIfNotBlank(String target, String source) {
        if (isNotBlank(source)) {
            target = source;
        }
    }

    /**
     * 转换为JS获取对象值,生成三目运算返回结果
     *
     * @param objectString 对象串
     *                     例如:row.user.id
     *                     返回:!row?'':!row.user?'':!row.user.id?'':row.user.id
     */
    public static String jsGetVal(String objectString) {
        StringBuilder result = new StringBuilder();
        StringBuilder val = new StringBuilder();
        String[] vals = split(objectString, ".");
        for (int i = 0; i < vals.length; i++) {
            val.append("." + vals[i]);
            result.append("!" + (val.substring(1)) + "?'':");
        }
        result.append(val.substring(1));
        return result.toString();
    }

    /**
     * 将字符串转换成pascal case。
     *

     * 如果字符串是null则返回null。
     *

     *

     *

     * StringUtil.toPascalCase(null)  = null
     * StringUtil.toPascalCase("")    = ""
     * StringUtil.toPascalCase("aBc") = "ABc"
     * StringUtil.toPascalCase("aBc def") = "ABcDef"
     * StringUtil.toPascalCase("aBc def_ghi") = "ABcDefGhi"
     * StringUtil.toPascalCase("aBc def_ghi 123") = "aBcDefGhi123"
     *

     *

     *

     *

     * 此方法会保留除了下划线和空白以外的所有分隔符。
     *

     *
     * @param str 要转换的字符串
     * @return pascal case字符串,如果原字符串为null,则返回null
     */
    public static String toPascalCase(String str) {
        return new WordTokenizer() {
            @Override
            protected void startSentence(StringBuilder buffer, char ch) {
                buffer.append(Character.toUpperCase(ch));
            }

            @Override
            protected void startWord(StringBuilder buffer, char ch) {
                buffer.append(Character.toUpperCase(ch));
            }

            @Override
            protected void inWord(StringBuilder buffer, char ch) {
                buffer.append(Character.toLowerCase(ch));
            }

            @Override
            protected void startDigitSentence(StringBuilder buffer, char ch) {
                buffer.append(ch);
            }

            @Override
            protected void startDigitWord(StringBuilder buffer, char ch) {
                buffer.append(ch);
            }

            @Override
            protected void inDigitWord(StringBuilder buffer, char ch) {
                buffer.append(ch);
            }

            @Override
            protected void inDelimiter(StringBuilder buffer, char ch) {
                if (ch != UNDERSCORE) {
                    buffer.append(ch);
                }
            }
        }.parse(str);
    }

    /**
     * 将字符串转换成下划线分隔的大写字符串。
     *

     * 如果字符串是null则返回null。
     *

     *

     *

     * StringUtil.toUpperCaseWithUnderscores(null)  = null
     * StringUtil.toUpperCaseWithUnderscores("")    = ""
     * StringUtil.toUpperCaseWithUnderscores("aBc") = "A_BC"
     * StringUtil.toUpperCaseWithUnderscores("aBc def") = "A_BC_DEF"
     * StringUtil.toUpperCaseWithUnderscores("aBc def_ghi") = "A_BC_DEF_GHI"
     * StringUtil.toUpperCaseWithUnderscores("aBc def_ghi 123") = "A_BC_DEF_GHI_123"
     * StringUtil.toUpperCaseWithUnderscores("__a__Bc__") = "__A__BC__"
     *

     *

     *

     *

     * 此方法会保留除了空白以外的所有分隔符。
     *

     *
     * @param str 要转换的字符串
     * @return 下划线分隔的大写字符串,如果原字符串为null,则返回null
     */
    public static String toUpperCaseWithUnderscores(String str) {
        return new WordTokenizer() {
            @Override
            protected void startSentence(StringBuilder buffer, char ch) {
                buffer.append(Character.toUpperCase(ch));
            }

            @Override
            protected void startWord(StringBuilder buffer, char ch) {
                if (!isDelimiter(buffer.charAt(buffer.length() - 1))) {
                    buffer.append(UNDERSCORE);
                }

                buffer.append(Character.toUpperCase(ch));
            }

            @Override
            protected void inWord(StringBuilder buffer, char ch) {
                buffer.append(Character.toUpperCase(ch));
            }

            @Override
            protected void startDigitSentence(StringBuilder buffer, char ch) {
                buffer.append(ch);
            }

            @Override
            protected void startDigitWord(StringBuilder buffer, char ch) {
                if (!isDelimiter(buffer.charAt(buffer.length() - 1))) {
                    buffer.append(UNDERSCORE);
                }

                buffer.append(ch);
            }

            @Override
            protected void inDigitWord(StringBuilder buffer, char ch) {
                buffer.append(ch);
            }

            @Override
            protected void inDelimiter(StringBuilder buffer, char ch) {
                buffer.append(ch);
            }
        }.parse(str);
    }

    // ==========================================================================
    // 将数字或字节转换成ASCII字符串的函数。
    // ==========================================================================

    /**
     * 将字符串转换成下划线分隔的小写字符串。
     *

     * 如果字符串是null则返回null。
     *

     *

     *

     * StringUtil.toLowerCaseWithUnderscores(null)  = null
     * StringUtil.toLowerCaseWithUnderscores("")    = ""
     * StringUtil.toLowerCaseWithUnderscores("aBc") = "a_bc"
     * StringUtil.toLowerCaseWithUnderscores("aBc def") = "a_bc_def"
     * StringUtil.toLowerCaseWithUnderscores("aBc def_ghi") = "a_bc_def_ghi"
     * StringUtil.toLowerCaseWithUnderscores("aBc def_ghi 123") = "a_bc_def_ghi_123"
     * StringUtil.toLowerCaseWithUnderscores("__a__Bc__") = "__a__bc__"
     *

     *

     *

     *

     * 此方法会保留除了空白以外的所有分隔符。
     *

     *
     * @param str 要转换的字符串
     * @return 下划线分隔的小写字符串,如果原字符串为null,则返回null
     */
    public static String toLowerCaseWithUnderscores(String str) {
        return new WordTokenizer() {
            @Override
            protected void startSentence(StringBuilder buffer, char ch) {
                buffer.append(Character.toLowerCase(ch));
            }

            @Override
            protected void startWord(StringBuilder buffer, char ch) {
                if (!isDelimiter(buffer.charAt(buffer.length() - 1))) {
                    buffer.append(UNDERSCORE);
                }

                buffer.append(Character.toLowerCase(ch));
            }

            @Override
            protected void inWord(StringBuilder buffer, char ch) {
                buffer.append(Character.toLowerCase(ch));
            }

            @Override
            protected void startDigitSentence(StringBuilder buffer, char ch) {
                buffer.append(ch);
            }

            @Override
            protected void startDigitWord(StringBuilder buffer, char ch) {
                if (!isDelimiter(buffer.charAt(buffer.length() - 1))) {
                    buffer.append(UNDERSCORE);
                }

                buffer.append(ch);
            }

            @Override
            protected void inDigitWord(StringBuilder buffer, char ch) {
                buffer.append(ch);
            }

            @Override
            protected void inDelimiter(StringBuilder buffer, char ch) {
                buffer.append(ch);
            }
        }.parse(str);
    }

    /**
     * 将一个长整形转换成62进制的字符串。
     *
     * @param longValue 64位数字
     * @return 62进制的字符串
     */
    public static String longToString(long longValue) {
        return longToString(longValue, false);
    }

    /**
     * 将一个长整形转换成62进制的字符串。
     *
     * @param longValue 64位数字
     * @param noCase    区分大小写
     * @return 62进制的字符串
     */
    public static String longToString(long longValue, boolean noCase) {
        char[] digits = noCase ? DIGITS_NOCASE : DIGITS;
        int digitsLength = digits.length;

        if (longValue == 0) {
            return String.valueOf(digits[0]);
        }

        if (longValue < 0) {
            longValue = -longValue;
        }

        StringBuilder strValue = new StringBuilder();

        while (longValue != 0) {
            int digit = (int) (longValue % digitsLength);
            longValue = longValue / digitsLength;

            strValue.append(digits[digit]);
        }

        return strValue.toString();
    }

    /**
     * 将一个byte数组转换成62进制的字符串。
     *
     * @param bytes 二进制数组
     * @return 62进制的字符串
     */
    public static String bytesToString(byte[] bytes) {
        return bytesToString(bytes, false);
    }

    /**
     * 将一个byte数组转换成62进制的字符串。
     *
     * @param bytes  二进制数组
     * @param noCase 区分大小写
     * @return 62进制的字符串
     */
    public static String bytesToString(byte[] bytes, boolean noCase) {
        char[] digits = noCase ? DIGITS_NOCASE : DIGITS;
        int digitsLength = digits.length;

        if (ArrayUtils.isEmpty(bytes)) {
            return String.valueOf(digits[0]);
        }

        StringBuilder strValue = new StringBuilder();
        int value = 0;
        int limit = Integer.MAX_VALUE >>> 8;
        int i = 0;

        do {
            while (i < bytes.length && value < limit) {
                value = (value << 8) + (0xFF & bytes[i++]);
            }

            while (value >= digitsLength) {
                strValue.append(digits[value % digitsLength]);
                value = value / digitsLength;
            }
        } while (i < bytes.length);

        if (value != 0 || strValue.length() == 0) {
            strValue.append(digits[value]);
        }

        return strValue.toString();
    }

    /**
     * 判断字符串str是否以字符ch结尾
     *
     * @param str 要比较的字符串
     * @param ch  结尾字符
     * @return 如果字符串str是否以字符ch结尾,则返回true
     */
    public static boolean endsWithChar(String str, char ch) {
        if (StringUtils.isEmpty(str)) {
            return false;
        }

        return str.charAt(str.length() - 1) == ch;
    }

    // ==========================================================================
    // 将字符串转化成集合
    // ==========================================================================

    // public static <T> List<T> toArrayList(String value) {
    // if (value == null) {
    // return null;
    // }
    // // FIXME "[ ...N个空格... ]"暂不考虑
    // if (StringUtils.isBlank(value) || value.equals("[]")) {
    // return Collections.emptyList();
    // }
    //
    // // ", "
    // value = StringUtils.substringBetween(value, "[", "]");
    // String[] array = StringUtils.split(value, ", ");
    // List<T>
    //
    // }

    // ==========================================================================
    // 字符串比较相关。
    // ==========================================================================

    /**
     * 判断字符串str是否以字符ch开头
     *
     * @param str 要比较的字符串
     * @param ch  开头字符
     * @return 如果字符串str是否以字符ch 开头,则返回true
     */
    public static boolean startsWithChar(String str, char ch) {
        if (StringUtils.isEmpty(str)) {
            return false;
        }

        return str.charAt(0) == ch;
    }

    public static int indexOfChars(String string, String chars) {
        return indexOfChars(string, chars, 0);
    }

    // ==========================================================================
    // 字符串索引相关。
    // ==========================================================================

    public static int indexOfChars(String string, String chars, int startindex) {
        if (string == null || chars == null) {
            return -1;
        }

        int stringLen = string.length();
        int charsLen = chars.length();

        if (startindex < 0) {
            startindex = 0;
        }

        for (int i = startindex; i < stringLen; i++) {
            char c = string.charAt(i);
            for (int j = 0; j < charsLen; j++) {
                if (c == chars.charAt(j)) {
                    return i;
                }
            }
        }

        return -1;
    }

    public static int indexOfChars(String string, char[] chars) {
        return indexOfChars(string, chars, 0);
    }

    public static int indexOfChars(String string, char[] chars, int startindex) {
        if (string == null || chars == null) {
            return -1;
        }

        int stringLen = string.length();
        int charsLen = chars.length;

        for (int i = startindex; i < stringLen; i++) {
            char c = string.charAt(i);
            for (int j = 0; j < charsLen; j++) {
                if (c == chars[j]) {
                    return i;
                }
            }
        }

        return -1;
    }

    /**
     * 解析出下列语法所构成的SENTENCE。
     *

     *

     *

     *  SENTENCE = WORD (DELIMITER* WORD)*
     *
     *  WORD = UPPER_CASE_WORD | LOWER_CASE_WORD | TITLE_CASE_WORD | DIGIT_WORD
     *
     *  UPPER_CASE_WORD = UPPER_CASE_LETTER+
     *  LOWER_CASE_WORD = LOWER_CASE_LETTER+
     *  TITLE_CASE_WORD = UPPER_CASE_LETTER LOWER_CASE_LETTER+
     *  DIGIT_WORD      = DIGIT+
     *
     *  UPPER_CASE_LETTER = Character.isUpperCase()
     *  LOWER_CASE_LETTER = Character.isLowerCase()
     *  DIGIT             = Character.isDigit()
     *  NON_LETTER_DIGIT  = !Character.isUpperCase() && !Character.isLowerCase() && !Character.isDigit()
     *
     *  DELIMITER = WHITESPACE | NON_LETTER_DIGIT
     *

     */
    private abstract static class WordTokenizer {
        protected static final char UNDERSCORE = '_';

        /**
         * Parse sentence。
         */
        public String parse(String str) {
            if (StringUtils.isEmpty(str)) {
                return str;
            }

            int length = str.length();
            StringBuilder buffer = new StringBuilder(length);

            for (int index = 0; index < length; index++) {
                char ch = str.charAt(index);

                // 忽略空白。
                if (Character.isWhitespace(ch)) {
                    continue;
                }

                // 大写字母开始:UpperCaseWord或是TitleCaseWord。
                if (Character.isUpperCase(ch)) {
                    int wordIndex = index + 1;

                    while (wordIndex < length) {
                        char wordChar = str.charAt(wordIndex);

                        if (Character.isUpperCase(wordChar)) {
                            wordIndex++;
                        } else if (Character.isLowerCase(wordChar)) {
                            wordIndex--;
                            break;
                        } else {
                            break;
                        }
                    }

                    // 1. wordIndex == length,说明最后一个字母为大写,以upperCaseWord处理之。
                    // 2. wordIndex == index,说明index处为一个titleCaseWord。
                    // 3. wordIndex > index,说明index到wordIndex -
                    // 1处全部是大写,以upperCaseWord处理。
                    if (wordIndex == length || wordIndex > index) {
                        index = parseUpperCaseWord(buffer, str, index,
                                wordIndex);
                    } else {
                        index = parseTitleCaseWord(buffer, str, index);
                    }

                    continue;
                }

                // 小写字母开始:LowerCaseWord。
                if (Character.isLowerCase(ch)) {
                    index = parseLowerCaseWord(buffer, str, index);
                    continue;
                }

                // 数字开始:DigitWord。
                if (Character.isDigit(ch)) {
                    index = parseDigitWord(buffer, str, index);
                    continue;
                }

                // 非字母数字开始:Delimiter。
                inDelimiter(buffer, ch);
            }

            return buffer.toString();
        }

        private int parseUpperCaseWord(StringBuilder buffer, String str,
                                       int index, int length) {
            char ch = str.charAt(index++);

            // 首字母,必然存在且为大写。
            if (buffer.length() == 0) {
                startSentence(buffer, ch);
            } else {
                startWord(buffer, ch);
            }

            // 后续字母,必为小写。
            for (; index < length; index++) {
                ch = str.charAt(index);
                inWord(buffer, ch);
            }

            return index - 1;
        }

        private int parseLowerCaseWord(StringBuilder buffer, String str,
                                       int index) {
            char ch = str.charAt(index++);

            // 首字母,必然存在且为小写。
            if (buffer.length() == 0) {
                startSentence(buffer, ch);
            } else {
                startWord(buffer, ch);
            }

            // 后续字母,必为小写。
            int length = str.length();

            for (; index < length; index++) {
                ch = str.charAt(index);

                if (Character.isLowerCase(ch)) {
                    inWord(buffer, ch);
                } else {
                    break;
                }
            }

            return index - 1;
        }

        private int parseTitleCaseWord(StringBuilder buffer, String str,
                                       int index) {
            char ch = str.charAt(index++);

            // 首字母,必然存在且为大写。
            if (buffer.length() == 0) {
                startSentence(buffer, ch);
            } else {
                startWord(buffer, ch);
            }

            // 后续字母,必为小写。
            int length = str.length();

            for (; index < length; index++) {
                ch = str.charAt(index);

                if (Character.isLowerCase(ch)) {
                    inWord(buffer, ch);
                } else {
                    break;
                }
            }

            return index - 1;
        }

        private int parseDigitWord(StringBuilder buffer, String str, int index) {
            char ch = str.charAt(index++);

            // 首字符,必然存在且为数字。
            if (buffer.length() == 0) {
                startDigitSentence(buffer, ch);
            } else {
                startDigitWord(buffer, ch);
            }

            // 后续字符,必为数字。
            int length = str.length();

            for (; index < length; index++) {
                ch = str.charAt(index);

                if (Character.isDigit(ch)) {
                    inDigitWord(buffer, ch);
                } else {
                    break;
                }
            }

            return index - 1;
        }

        protected boolean isDelimiter(char ch) {
            return !Character.isUpperCase(ch) && !Character.isLowerCase(ch)
                    && !Character.isDigit(ch);
        }

        protected abstract void startSentence(StringBuilder buffer, char ch);

        protected abstract void startWord(StringBuilder buffer, char ch);

        protected abstract void inWord(StringBuilder buffer, char ch);

        protected abstract void startDigitSentence(StringBuilder buffer, char ch);

        protected abstract void startDigitWord(StringBuilder buffer, char ch);

        protected abstract void inDigitWord(StringBuilder buffer, char ch);

        protected abstract void inDelimiter(StringBuilder buffer, char ch);
    }

}


text:
#include <aws/lexv2-runtime/model/Shape.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/core/Globals.h>
#include <aws/core/utils/EnumParseOverflowContainer.h>

using namespace Aws::Utils;

namespace Aws
{
  namespace LexRuntimeV2
  {
    namespace Model
    {
      namespace ShapeMapper
      {

        static const int Scalar_HASH = HashingUtils::HashString("Scalar");
        static const int List_HASH = HashingUtils::HashString("List");

        Shape GetShapeForName(const Aws::String& name)
        {
          int hashCode = HashingUtils::HashString(name.c_str());
          if (hashCode == Scalar_HASH)
          {
            return Shape::Scalar;
          }
          else if (hashCode == List_HASH)
          {
            return Shape::List;
          }
          EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
          if(overflowContainer)
          {
            overflowContainer->StoreOverflow(hashCode, name);
            return static_cast<Shape>(hashCode);
          }

          return Shape::NOT_SET;
        }

        Aws::String GetNameForShape(Shape enumValue)
        {
          switch(enumValue)
          {
          case Shape::Scalar:
            return "Scalar";
          case Shape::List:
            return "List";
          default:
            EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
            if(overflowContainer)
            {
              return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue));
            }

            return {};
          }
        }

      } // namespace ShapeMapper
    } // namespace Model
  } // namespace LexRuntimeV2
} // namespace Aws


text:
#ifndef PARTREQ_H
#define PARTREQ_H
/* -*-C++-*-
*************************************************************************
*
* File:         PartReq.h
* Description:  Partitioning Requirements
* Created:      02/27/98
* Language:     C++
*
*
*
*
*************************************************************************
*/

#include "PartFunc.h"
#include "CmpStatement.h"

// ----------------------------------------------------------------------
// contents of this file
// ----------------------------------------------------------------------
class PartitioningRequirement;

class FuzzyPartitioningRequirement;
class FullySpecifiedPartitioningRequirement;
class RequireApproximatelyNPartitions;
class RequireExactlyOnePartition;
class RequireReplicateViaBroadcast;
class RequireReplicateNoBroadcast;
class RequireHash;
class RequireHash2;
class RequireHive;
class RequireHashDist;
class RequireSkewed;
class RequireRange;
class RequireRoundRobin;

class LogicalPartitioningRequirement;

// ----------------------------------------------------------------------
// forward references
// ----------------------------------------------------------------------

// -----------------------------------------------------------------------
// PARTITIONING REQUIREMENTS.
// -----------------------------------------------------------------------

// -----------------------------------------------------------------------
// A partitioning requirement can be an incomplete specification of a
// Partitioning Function. Essentially, it behaves like a wild card for a
// partititioning scheme. A partitioning requirement is specified in the
// Required Physical Properties that are used by Cascades. It allows the
// optimizer to state the desired criterion for partitioning namely,
// either the number of partitions, or the partitioning keys, or both.
// -----------------------------------------------------------------------
class PartitioningRequirement : public NABasicObject
{
protected:
  // --------------------------------------------------------------------
  // Partitioning requirement category identifier.
  // --------------------------------------------------------------------
  enum PartitioningRequirementCategoryEnum
    {
      FULLY_SPECIFIED_PART_REQ,
      FUZZY_PART_REQ
    };

public:

  // --------------------------------------------------------------------
  // Destructor functions
  // --------------------------------------------------------------------
  virtual ~PartitioningRequirement();

  // ---------------------------------------------------------------------
  // Perform type-safe pointer casts.
  // ---------------------------------------------------------------------
  virtual const
  FuzzyPartitioningRequirement*
                   castToFuzzyPartitioningRequirement() const;

  virtual const
  FullySpecifiedPartitioningRequirement*
                   castToFullySpecifiedPartitioningRequirement() const;

  virtual const
  RequireApproximatelyNPartitions*
                   castToRequireApproximatelyNPartitions() const;

  virtual const
  RequireExactlyOnePartition*
                   castToRequireExactlyOnePartition() const;

  virtual const
  RequireReplicateViaBroadcast*
                   castToRequireReplicateViaBroadcast() const;

  virtual const
  RequireReplicateNoBroadcast*
                   castToRequireReplicateNoBroadcast() const;

  virtual const
  RequireHash*
                   castToRequireHash() const;

  virtual const
  RequireHashDist*
                   castToRequireHashDist() const;

  virtual const
  RequireHash2*
                   castToRequireHash2() const;

  virtual const
  RequireSkewed*
                   castToRequireSkewed() const;

  virtual const
  RequireRange*
                   castToRequireRange() const;

  virtual const
  RequireRoundRobin*
                   castToRequireRoundRobin() const;

  virtual const
  RequireHive*
                   castToRequireHive() const;

  // ---------------------------------------------------------------------
  // The number of partitions that will be formed using this scheme.
  // ---------------------------------------------------------------------
  virtual Lng32 getCountOfPartitions() const;

  // Accessor method for the partitioning key
  virtual const ValueIdSet& getPartitioningKey() const;
  virtual const ValueIdSet& getPartialPartitioningKey() const
  { return getPartitioningKey(); };

  virtual NABoolean partitioningKeyIsSpecified() const;

  // ---------------------------------------------------------------------
  // Partitioning Requirement Category Tests
  // ---------------------------------------------------------------------
  NABoolean isRequirementFullySpecified() const
    { return (requirementCategory_ == FULLY_SPECIFIED_PART_REQ); }

  NABoolean isRequirementFuzzy() const
    { return (requirementCategory_ == FUZZY_PART_REQ); }

  virtual NABoolean partReqAndFuncCompatible
                           (const PartitioningFunction* other) const;

  virtual COMPARE_RESULT comparePartReqToReq
                           (const PartitioningRequirement* other) const;

  virtual NABoolean isRequirementApproximatelyN() const
    { return FALSE; }

  virtual NABoolean isRequirementExactlyOne() const
    { return FALSE; }

  virtual NABoolean isRequirementReplicateViaBroadcast() const
    { return FALSE; }

  virtual NABoolean isRequirementReplicateNoBroadcast() const
    { return FALSE; }

  virtual NABoolean isRequirementHash() const
    { return FALSE; }

  virtual NABoolean isRequirementSkewed() const
    { return FALSE; }

  virtual NABoolean isRequirementRange() const
    { return FALSE; }

  virtual NABoolean isRequirementRoundRobin() const
    { return FALSE; }

  virtual NABoolean isRequirementSkewBusterBroadcast() const
    { return FALSE; };

  virtual NABoolean isRequirementHive() const
    { return FALSE; };

  virtual NABoolean isReplicate() const { return FALSE; }

  // --------------------------------------------------------------------
  // Method used by the optimizer for replacing a partitioning
  // requirement with an actual partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningFunction * realize(
       const Context *myContext,
       NABoolean useContextPartitioningRequirements = FALSE,
       const PartitioningRequirement * softRequirements = NULL) ;

  // --------------------------------------------------------------------
  // Copy this partitioning requirement and rewrite the copy in terms of
  // the top or bottom values that are contained in the map.
  // If the parameter mapItUp is set to TRUE, then the partitioning key
  // or function is rewritten in terms of the values in the top map.
  // Otherwise, it is rewritten in terms of values in the bottom map.
  // The virtual function remapIt() implements the remapping.
  // --------------------------------------------------------------------
  PartitioningRequirement* copyAndRemap
                           (ValueIdMap& map, NABoolean mapItUp) const;

  virtual void remapIt(const PartitioningRequirement* opr,
                       ValueIdMap& map, NABoolean mapItUp);

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual const NAString getText() const;
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
                      const char* title = "PartitioningRequirement") const;

  virtual void display() const;

protected:

  // ---------------------------------------------------------------------
  // The following constructors are used by the derived classes and
  // are therefore hidden from public view.
  // ---------------------------------------------------------------------
  PartitioningRequirement(const PartitioningRequirementCategoryEnum rCat)
     : requirementCategory_ (rCat)
  {
  }

  PartitioningRequirement(const PartitioningRequirement& other)
     : requirementCategory_ (other.requirementCategory_)
  {
  }

private :

  PartitioningRequirementCategoryEnum requirementCategory_;
}; // class PartitioningRequirement

// -----------------------------------------------------------------------
// Classes that are derived directly from PartitioningRequirement.
// -----------------------------------------------------------------------

class FuzzyPartitioningRequirement : public PartitioningRequirement
{
protected:
  // --------------------------------------------------------------------
  // Partitioning requirement type identifier.
  // --------------------------------------------------------------------
  enum FuzzyPartReqTypeEnum
    {
      APPROXIMATELY_N_PART_REQ
    };

public:

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  FuzzyPartitioningRequirement*
                   castToFuzzyPartitioningRequirement() const;

  // ---------------------------------------------------------------------
  // The number of partitions that will be formed using this scheme.
  // ---------------------------------------------------------------------
  virtual Lng32 getCountOfPartitions() const
    {  return numberOfPartitions_; }

  // Accessor method for the partitioning key
  virtual const ValueIdSet& getPartitioningKey() const
    {  return partitioningKeyColumns_; }

  virtual NABoolean partitioningKeyIsSpecified() const
                                   { return partitioningKeyIsSpecified_; }

  virtual NABoolean partReqAndFuncCompatible
                           (const PartitioningFunction* other) const;

  virtual COMPARE_RESULT comparePartReqToReq
                           (const PartitioningRequirement* other) const;

  FuzzyPartReqTypeEnum getPartitioningRequirementType() const
    { return requirementType_;}

  virtual NABoolean isRequirementApproximatelyN() const
    { return (requirementType_ == APPROXIMATELY_N_PART_REQ); }

  virtual void remapIt(const PartitioningRequirement* opr,
                       ValueIdMap& map, NABoolean mapItUp);

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print(FILE* ofd = stdout,
                     const char* indent = DEFAULT_INDENT,
                     const char* title = "FuzzyPartitioningRequirement") const;

  virtual void display() const;

  // helper function on skew property
  virtual const skewProperty& getSkewProperty() const { return skewProperty_; };
  virtual void setSkewProperty(const skewProperty& sk) { skewProperty_ = sk; };

protected:

  // ---------------------------------------------------------------------
  // The following constructors are used by the derived classes and
  // are therefore hidden from public view.
  // ---------------------------------------------------------------------
  FuzzyPartitioningRequirement(const FuzzyPartReqTypeEnum rType,
                               const ValueIdSet& partitioningKeyColumns,
                               Lng32 numberOfPartitions =
                                      ANY_NUMBER_OF_PARTITIONS
                               ,const skewProperty& sk = ANY_SKEW_PROPERTY
                               )
     : PartitioningRequirement(FUZZY_PART_REQ),
       requirementType_ (rType),
       partitioningKeyColumns_(partitioningKeyColumns),
       partitioningKeyIsSpecified_(TRUE),
       numberOfPartitions_ (numberOfPartitions)
     ,skewProperty_(sk)
  {
  }

  FuzzyPartitioningRequirement(const FuzzyPartReqTypeEnum rType,
                               Lng32 numberOfPartitions =
                                      ANY_NUMBER_OF_PARTITIONS
                               ,const skewProperty& sk = ANY_SKEW_PROPERTY
                               )
     : PartitioningRequirement(FUZZY_PART_REQ),
       requirementType_ (rType),
       partitioningKeyIsSpecified_(FALSE),
       numberOfPartitions_ (numberOfPartitions)
     ,skewProperty_(sk)
  {
  }

  FuzzyPartitioningRequirement(const FuzzyPartitioningRequirement& other)
     : PartitioningRequirement(other),
       requirementType_ (other.requirementType_),
       partitioningKeyColumns_(other.partitioningKeyColumns_),
       partitioningKeyIsSpecified_(other.partitioningKeyIsSpecified_),
       numberOfPartitions_ (other.numberOfPartitions_)
     ,skewProperty_(other.skewProperty_)
  {
  }

private :

  FuzzyPartReqTypeEnum requirementType_;
  ValueIdSet partitioningKeyColumns_;
  NABoolean partitioningKeyIsSpecified_;
  Lng32 numberOfPartitions_;
  skewProperty skewProperty_;
}; // class FuzzyPartitioningRequirement

class FullySpecifiedPartitioningRequirement : public PartitioningRequirement
{
public:

  // ---------------------------------------------------------------------
  // The number of partitions that will be formed using this scheme.
  // ---------------------------------------------------------------------
  virtual Lng32 getCountOfPartitions() const
    {  return partitioningFunction_->getCountOfPartitions(); }

  // Accessor method for the partitioning key
  virtual const ValueIdSet& getPartitioningKey() const
    {  return partitioningFunction_->getPartitioningKey(); }

  virtual NABoolean partitioningKeyIsSpecified() const { return TRUE; }

  virtual NABoolean partReqAndFuncCompatible
                           (const PartitioningFunction* other) const;

  virtual COMPARE_RESULT comparePartReqToReq
                           (const PartitioningRequirement* other) const;

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  FullySpecifiedPartitioningRequirement*
                   castToFullySpecifiedPartitioningRequirement() const;

  PartitioningFunction* getPartitioningFunction() const
    { return partitioningFunction_; }

  void setPartitioningFunction (PartitioningFunction * partFunc)
    { partitioningFunction_ = partFunc; }

  virtual NABoolean isRequirementExactlyOne() const
    { return
       getPartitioningFunction()->isASinglePartitionPartitioningFunction();
    }

  virtual NABoolean isRequirementReplicateViaBroadcast() const
    { return
       getPartitioningFunction()->
         isAReplicateViaBroadcastPartitioningFunction();
    }

  virtual NABoolean isRequirementReplicateNoBroadcast() const
    { return
       getPartitioningFunction()->
         isAReplicateNoBroadcastPartitioningFunction();
    }

  virtual NABoolean isRequirementHash() const
    { return
       getPartitioningFunction()->isAHashPartitioningFunction();
    }

  virtual NABoolean isRequirementRange() const
    { return
       getPartitioningFunction()->isARangePartitioningFunction();
    }

  virtual NABoolean isRequirementRoundRobin() const
    { return
       getPartitioningFunction()->isARoundRobinPartitioningFunction();
    }

  virtual NABoolean isRequirementSkewBusterBroadcast() const;

  // --------------------------------------------------------------------
  // Method used by the optimizer for replacing a partitioning
  // requirement with an actual partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningFunction * realize(
       const Context *myContext,
       NABoolean useContextPartitioningRequirements = FALSE,
       const PartitioningRequirement * softRequirements = NULL) ;

  virtual void remapIt(const PartitioningRequirement* opr,
                       ValueIdMap& map, NABoolean mapItUp);

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
            const char* title = "FullySpecifiedPartitioningRequirement") const;

  virtual void display() const;

protected:

  // ---------------------------------------------------------------------
  // The following constructors are used by the derived classes and
  // are therefore hidden from public view.
  // ---------------------------------------------------------------------
  FullySpecifiedPartitioningRequirement(PartitioningFunction* partFunc)
     : PartitioningRequirement(FULLY_SPECIFIED_PART_REQ),
       partitioningFunction_(partFunc)
  {
  }

  FullySpecifiedPartitioningRequirement()
     : PartitioningRequirement(FULLY_SPECIFIED_PART_REQ),
       partitioningFunction_(NULL)
  {
  }

  FullySpecifiedPartitioningRequirement
          (const FullySpecifiedPartitioningRequirement& other)
     : PartitioningRequirement(other),
       partitioningFunction_(other.partitioningFunction_)
  {
  }

private :

  PartitioningFunction* partitioningFunction_;

}; // class FullySpecifiedPartitioningRequirement

// -----------------------------------------------------------------------
// Classes that are derived from FuzzyPartitioningRequirement.
// -----------------------------------------------------------------------

class RequireApproximatelyNPartitions : public FuzzyPartitioningRequirement
{
public:

  RequireApproximatelyNPartitions (const ValueIdSet& partitioningKeyColumns,
                                   float numOfPartsAllowedDeviation =
                                     CURRSTMT_OPTDEFAULTS->numberOfPartitionsDeviation(),
                                   Lng32 numberOfPartitions =
                                          ANY_NUMBER_OF_PARTITIONS,
                                   NABoolean requireHash2Only = FALSE
                                   ,const skewProperty& sk = ANY_SKEW_PROPERTY
                                   );

  RequireApproximatelyNPartitions (float numOfPartsAllowedDeviation =
                                     CURRSTMT_OPTDEFAULTS->numberOfPartitionsDeviation(),
                                   Lng32 numberOfPartitions =
                                          ANY_NUMBER_OF_PARTITIONS,
                                   NABoolean requireHash2Only = FALSE
                                   ,const skewProperty& sk = ANY_SKEW_PROPERTY
                                   );

  RequireApproximatelyNPartitions
      (const RequireApproximatelyNPartitions& other)
     : FuzzyPartitioningRequirement(other),
       numOfPartsAllowedDeviation_ (other.numOfPartsAllowedDeviation_),
       requireHash2Only_(other.requireHash2Only_)
  {
  }

  virtual NABoolean partReqAndFuncCompatible
                           (const PartitioningFunction* other) const;

  virtual COMPARE_RESULT comparePartReqToReq
                           (const PartitioningRequirement* other) const;

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  RequireApproximatelyNPartitions*
                   castToRequireApproximatelyNPartitions() const;

  // accesor method for the allowable deviation
  float getAllowedDeviation() const
    { return numOfPartsAllowedDeviation_; }

  // check whether an actual number of partitions is within the
  // range for the allowed number of partitions
  NABoolean isPartitionCountWithinRange(Lng32 numOfParts) const;

  // accesor method for the lower bound of the range for the
  // allowed number of partitions
  Lng32 getCountOfPartitionsLowBound() const;

  NABoolean isRequireHash2Only() const { return requireHash2Only_; }

  // --------------------------------------------------------------------
  // Method used by the optimizer for replacing a partitioning
  // requirement with an actual partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningFunction * realize(
       const Context *myContext,
       NABoolean useContextPartitioningRequirements = FALSE,
       const PartitioningRequirement * softRequirements = NULL) ;

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
                  const char* title = "RequireApproximatelyNPartitions") const;

  virtual void display() const;

private :

  float numOfPartsAllowedDeviation_;
  NABoolean requireHash2Only_;

}; // class RequireApproximatelyNPartitions

// -----------------------------------------------------------------------
// Classes that are derived from FullySpecifiedPartitioningRequirement.
// -----------------------------------------------------------------------

class RequireExactlyOnePartition : public FullySpecifiedPartitioningRequirement
{
public:

  RequireExactlyOnePartition (PartitioningFunction* partFunc)
     : FullySpecifiedPartitioningRequirement(partFunc)
  {
    CMPASSERT(partFunc->isASinglePartitionPartitioningFunction());
  }

  RequireExactlyOnePartition (NABoolean withNodeMap=FALSE);

  RequireExactlyOnePartition (const RequireExactlyOnePartition& other)
    :  FullySpecifiedPartitioningRequirement (other)
  {
  }

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  RequireExactlyOnePartition*
                   castToRequireExactlyOnePartition() const;

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
                      const char* title = "RequireExactlyOnePartition") const;

  virtual void display() const;

}; // class RequireExactlyOnePartition

class RequireReplicateViaBroadcast :
        public FullySpecifiedPartitioningRequirement
{
public:

  RequireReplicateViaBroadcast (PartitioningFunction* partFunc)
     : FullySpecifiedPartitioningRequirement(partFunc)
  {
    CMPASSERT(partFunc->isAReplicateViaBroadcastPartitioningFunction());
  }

  RequireReplicateViaBroadcast (Lng32 numOfReplicas);

  RequireReplicateViaBroadcast (PartitioningFunction *childPF,
                                NABoolean useChildsNodeMap);

  RequireReplicateViaBroadcast (const RequireReplicateViaBroadcast& other)
    :  FullySpecifiedPartitioningRequirement (other)
  {
  }

  virtual COMPARE_RESULT comparePartReqToReq
                           (const PartitioningRequirement* other) const;

  NABoolean isReplicate() const { return TRUE; }

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  RequireReplicateViaBroadcast*
                   castToRequireReplicateViaBroadcast() const;

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
                      const char* title =
                                    "RequireReplicateViaBroadcast") const;

  virtual void display() const;

private :

}; // class RequireReplicateViaBroadcast

class RequireReplicateNoBroadcast :
        public FullySpecifiedPartitioningRequirement
{
public:

  RequireReplicateNoBroadcast (PartitioningFunction* partFunc)
    : FullySpecifiedPartitioningRequirement(partFunc),
      parentPartFunc_(NULL)
  {
    CMPASSERT(partFunc->isAReplicateNoBroadcastPartitioningFunction());
  }

  RequireReplicateNoBroadcast (PartitioningFunction *parentPF,
                               NABoolean useParentsNodeMap);

  RequireReplicateNoBroadcast (const RequireReplicateNoBroadcast& other)
    :  FullySpecifiedPartitioningRequirement (other),
       parentPartFunc_(other.getParentPartFunc())
  {
  }

  virtual COMPARE_RESULT comparePartReqToReq
                           (const PartitioningRequirement* other) const;

  NABoolean isReplicate() const { return TRUE; }

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  RequireReplicateNoBroadcast*
                   castToRequireReplicateNoBroadcast() const;

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
                      const char* title =
                                    "RequireReplicateNoBroadcast") const;

  virtual void display() const;

  const PartitioningFunction *getParentPartFunc() const {return parentPartFunc_;};

private :

  // The partitioning function of the operator which is placing this
  // Rep-N requirement on its child.  This is used to determine if
  // each instance of the operator will access all the children or
  // just a group of the children.  Ultimately used to determine the
  // total number of PAs used by the PAPA.
  const PartitioningFunction *parentPartFunc_;

}; // class RequireReplicateNoBroadcast

class RequireHash : public FullySpecifiedPartitioningRequirement
{
public:

  RequireHash (PartitioningFunction* partFunc)
     : FullySpecifiedPartitioningRequirement(partFunc)
  {
    CMPASSERT(partFunc->isAHashPartitioningFunction());
    CMPASSERT(NOT partFunc->isASkewedDataPartitioningFunction());
  }

  RequireHash (const RequireHash& other)
    :  FullySpecifiedPartitioningRequirement (other)
  {
  }

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  RequireHash*
                   castToRequireHash() const;

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
                      const char* title = "RequireHash") const;

  virtual void display() const;

}; // class RequireHash

class RequireHashDist : public FullySpecifiedPartitioningRequirement
{
public:

  RequireHashDist (PartitioningFunction* partFunc)
     : FullySpecifiedPartitioningRequirement(partFunc)
  {
    CMPASSERT(partFunc->isAHashDistPartitioningFunction());
    CMPASSERT(NOT partFunc->isASkewedDataPartitioningFunction());
  }

  RequireHashDist (const RequireHashDist& other)
    :  FullySpecifiedPartitioningRequirement (other)
  {
  }

  virtual NABoolean partReqAndFuncCompatible
                           (const PartitioningFunction* other) const;

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  RequireHashDist* castToRequireHashDist() const;

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
                      const char* title = "RequireHashDist") const;

  virtual void display() const;

}; // class RequireHashDist

class RequireHash2 : public FullySpecifiedPartitioningRequirement
{
public:

  RequireHash2 (PartitioningFunction* partFunc)
     : FullySpecifiedPartitioningRequirement(partFunc)
  {
    CMPASSERT(partFunc->isAHash2PartitioningFunction());
    CMPASSERT(NOT partFunc->isASkewedDataPartitioningFunction());
  }

  RequireHash2 (const RequireHash2& other)
    :  FullySpecifiedPartitioningRequirement (other)
  {
  }

  virtual NABoolean partReqAndFuncCompatible
                           (const PartitioningFunction* other) const;

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  RequireHash2* castToRequireHash2() const;

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
                      const char* title = "RequireHash2") const;

  virtual void display() const;

}; // class RequireHash2

class RequireSkewed : public FullySpecifiedPartitioningRequirement
{
public:

  RequireSkewed (PartitioningFunction* partFunc)
     : FullySpecifiedPartitioningRequirement(partFunc)
  {
    CMPASSERT(partFunc->isASkewedDataPartitioningFunction());
  }

  RequireSkewed (const RequireSkewed& other)
    :  FullySpecifiedPartitioningRequirement (other)
  {
  }

  const ValueIdSet& getPartialPartitioningKey() const;

  NABoolean isRequirementSkewed() const { return TRUE; }

  COMPARE_RESULT
  comparePartReqToReq(const PartitioningRequirement* other) const;

  virtual NABoolean partReqAndFuncCompatible
                           (const PartitioningFunction* other) const;

  NABoolean isReplicate() const { return getSkewProperty().isBroadcasted(); }

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  RequireSkewed* castToRequireSkewed() const;

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // Compare skew data property contained in this object with those
  // contained in a partitioning function
  NABoolean compareSkewRequirement(const PartitioningFunction& other) const;

  virtual const skewProperty& getSkewProperty() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
                      const char* title = "RequireSkewed") const;

  virtual void display() const;

protected:
}; // class RequireSkewed

class RequireRange : public FullySpecifiedPartitioningRequirement
{
public:

  RequireRange (PartitioningFunction* partFunc)
     : FullySpecifiedPartitioningRequirement(partFunc)
  {
    CMPASSERT(partFunc->isARangePartitioningFunction());
  }

  RequireRange (const RequireRange& other)
    :  FullySpecifiedPartitioningRequirement (other)
  {
  }

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  RequireRange*
                   castToRequireRange() const;

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
                      const char* title = "RequireRange") const;

  virtual void display() const;

}; // class RequireRange

class RequireRoundRobin : public FullySpecifiedPartitioningRequirement
{
public:

  RequireRoundRobin (PartitioningFunction* partFunc)
     : FullySpecifiedPartitioningRequirement(partFunc)
  {
    CMPASSERT(partFunc->isARoundRobinPartitioningFunction());
  }

  RequireRoundRobin (const RequireRoundRobin& other)
    :  FullySpecifiedPartitioningRequirement (other)
  {
  }

  virtual NABoolean partReqAndFuncCompatible
                           (const PartitioningFunction* other) const;

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  RequireRoundRobin*
                   castToRequireRoundRobin() const;

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const;

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
                      const char* title = "RequireRoundRobin") const;

  virtual void display() const;

}; // class RequireRoundRobin

class RequireHive : public FullySpecifiedPartitioningRequirement
{
public:

  RequireHive (PartitioningFunction* partFunc)
     : FullySpecifiedPartitioningRequirement(partFunc)
  {
    CMPASSERT(partFunc->isAHivePartitioningFunction());
  }

  RequireHive(const RequireHive& other)
    :  FullySpecifiedPartitioningRequirement (other)
  {
  }

  // ---------------------------------------------------------------------
  // Perform a type-safe pointer cast.
  // ---------------------------------------------------------------------
  virtual const
  RequireHive* castToRequireHive() const { return this; };

  virtual NABoolean isRequirementHive() const { return TRUE; };

  // --------------------------------------------------------------------
  // A method for copying the partitioning function.
  // --------------------------------------------------------------------
  virtual PartitioningRequirement* copy() const
   { return new (CmpCommon::statementHeap()) RequireHive(*this);}

  // ---------------------------------------------------------------------
  // Print.
  // ---------------------------------------------------------------------
  virtual void print( FILE* ofd = stdout,
                      const char* indent = DEFAULT_INDENT,
                      const char* title = "RequireHive") const
  { FullySpecifiedPartitioningRequirement::print(ofd, indent, title); }

  virtual void display() const { print(); };

}; // class RequireHash

// -----------------------------------------------------------------------
// LOGICAL PARTITIONING REQUIREMENT
// -----------------------------------------------------------------------

// -----------------------------------------------------------------------
// This is a small helper class for passing logical partitioning
// requirements from the DP2 exchange to the DP2 scan node. This class
// is NOT part of the PartitioningRequirement class hierarchy.
// A LogicalPartitioningRequirement can be added to a ReqdPhysicalProperty
// object. That should only be done by an exchange when it creates a
// context for a DP2 child. Each DP2 operator should pass its logical
// partitioning requirement on to its child.
// -----------------------------------------------------------------------
class LogicalPartitioningRequirement : public NABasicObject
{
public:

  // constructor
  LogicalPartitioningRequirement(
       PartitioningRequirement *logPartReq,
       LogPhysPartitioningFunction::logPartType logPartType =
                    LogPhysPartitioningFunction::ANY_LOGICAL_PARTITIONING,
       Lng32 numClients = ANY_NUMBER_OF_PARTITIONS,
       NABoolean mustUsePapa = FALSE,
       NABoolean numPAsForced = FALSE) :
     logPartReq_(logPartReq),
     logPartType_(logPartType),
     numClients_(numClients),
     mustUsePapa_(mustUsePapa),
     numPAsForced_(numPAsForced)
  {}

  // copy constructor
  inline LogicalPartitioningRequirement(
       LogicalPartitioningRequirement &other) :
     logPartReq_(other.logPartReq_),
     logPartType_(other.logPartType_),
     numClients_(other.numClients_),
     mustUsePapa_(other.mustUsePapa_),
     numPAsForced_(other.numPAsForced_)
  {}

  // accessors

  PartitioningRequirement * getLogReq() const
                                                  { return logPartReq_; }
  LogPhysPartitioningFunction::logPartType getLogPartTypeReq() const
                                                  { return logPartType_; }
  Lng32 getNumClientsReq() const                   { return numClients_; }

  void setNumClientsReq(Lng32 n) {numClients_ = n;}

  NABoolean isNumberOfPAsForced() const { return numPAsForced_; }

  NABoolean getMustUsePapa() const                { return mustUsePapa_; }

  // comparison
  COMPARE_RESULT compareLogPartRequirements(
       const LogicalPartitioningRequirement &other) const;

  NABoolean satisfied(const RelExpr * const physExpr,
		      const PhysicalProperty * const physProp) const;

private:

  // ---------------------------------------------------------------------
  // The logical partitioning requirement is the partitioning requirement
  // of the DP2 exchange
  // ---------------------------------------------------------------------
  PartitioningRequirement            *logPartReq_;

  // ---------------------------------------------------------------------
  // The type of logical partitioning to be done by the DP2 fragment.
  // This is usually only set when
  // ---------------------------------------------------------------------
  LogPhysPartitioningFunction::logPartType logPartType_;

  // ---------------------------------------------------------------------
  // How many PA nodes do we want to have working on the DP2 fragment.
  // This is the total number of PAs in all ESPs, not the number of PAs
  // per ESP.
  // ---------------------------------------------------------------------
  Lng32                                     numClients_;

  // ---------------------------------------------------------------------
  // Do we have to use a PAPA node? TRUE forces one, FALSE allows one.
  // ---------------------------------------------------------------------
  NABoolean                                mustUsePapa_;

  // Is number of PAs forced by CQS?
  NABoolean                                 numPAsForced_;
};

#endif /* PARTREQ_H */


text:
#ifndef ANALYZER_GOOD_EKF_H
#define ANALYZER_GOOD_EKF_H

/*
 * analyzer_good_ekf
 *
 */

#include "analyzer.h"
#include "data_sources.h"
#include "analyzer_good_kf.h"

class Analyzer_Good_EKF : public Analyzer_Good_KF {

public:

    // borrow the constructor:
    using Analyzer_Good_KF::Analyzer_Good_KF;

    const std::string name() const override { return "Good EKF"; }
    const std::string description() const override {
        return "The Extended Kalman Filter (EKF) has many built-in checks to ensure that it is functioning correctly.  This test will FAIL or WARN if EKF variances exceed the respective thresholds, or FAIL if the EKF status flags indicate errors.";
    }

    const std::string shortname_lc() const override { return "ekf"; }
    const std::string shortname() const override { return "EKF"; }

    uint64_t variance_T(std::string name) const override {
        return _vehicle->ekf_variance_T(name);
    }
    uint64_t flags_T() const override {
        return _vehicle->ekf_flags_T();
    }
    uint16_t flags() const override {
        return _vehicle->ekf_flags();
    }

    std::map<const std::string, double> variances() {
        return _vehicle->ekf_variances();
    }

private:

};

#endif


text:
package test.dataportal.functional;

/**
 * Test case to run jetty server. It just starts jetty server and waits for an
 * enter on the console. Useful to test with jmeter
 *
 * @author fergonco
 */
public class JettyStarter extends AbstractFunctionalTest {

	public void testRunJetty() throws Exception {
		String userName = "fergonco@doesnot.exist";
		Services services = new Services();
		services.register(userName, "testpass");
		services.activate(userName);
		System.in.read();
	}

}


text:
//Problem 6. The Biggest of Five Numbers

//Write a program that finds the biggest of five numbers by using only five if statements.

using System;
using System.Threading;
using System.Globalization;

class TheBiggestОfFiveNumbers
{
    static void Main()
    {
        string str;
        double a;
        double b;
        double c;
        double d;
        double e;
        Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

        do
        {
            Console.Write("Please enter a number: ");
            str = Console.ReadLine();
            Console.Clear();

        } while (!double.TryParse(str, out a));

        do
        {
            Console.Write("Please enter a second number: ");
            str = Console.ReadLine();
            Console.Clear();

        } while (!double.TryParse(str, out b));

        do
        {
            Console.Write("Please enter a third number: ");
            str = Console.ReadLine();
            Console.Clear();

        } while (!double.TryParse(str, out c));

        do
        {
            Console.Write("Please enter a fourth number: ");
            str = Console.ReadLine();
            Console.Clear();

        } while (!double.TryParse(str, out d));

        do
        {
            Console.Write("Please enter a fifth number: ");
            str = Console.ReadLine();
            Console.Clear();

        } while (!double.TryParse(str, out e));

        //I'm gonna solve it using 5 if statments, other solution would be just one line: Math.Max(a, Math.Max(Math.Max(b, c), Math.Max(c, d)))

        double? biggest = null;

        if (a > b)
        {
            biggest = a;
        }

        if (b > a)
        {
            biggest = b;
        }

        if (c > biggest)
        {
            biggest = c;
        }

        if (d > biggest)
        {
            biggest = d;
        }

        if (e > biggest)
        {
            biggest = e;
        }

        Console.WriteLine("The biggest number is: {0}", biggest);
    }
}


text:
set -ex

echo =============================================================================
echo "DART DEV COMPILER (DDC) BUILD"
echo =============================================================================

# go to project dir
SCRIPT_DIR=$(dirname $0)
source $SCRIPT_DIR/env_dart.sh
cd $SCRIPT_DIR/../..

# Variables
DDC_TOTAL_WARNING_CAP="210"
DDC_TOTAL_ERROR_CAP="0"
DDC_DIR=`pwd`/tmp/dev_compiler
DDC_VERSION="0.1.20"

# Get DDC
mkdir -p tmp
rm -rf tmp/dev_compiler
git clone https://github.com/dart-lang/dev_compiler.git tmp/dev_compiler
(cd $DDC_DIR && \
  git checkout tags/$DDC_VERSION && \
  $PUB get)

# Convert TypeScript to Dart
./node_modules/.bin/gulp build/packages.dart
./node_modules/.bin/gulp build.dart.material.css
./node_modules/.bin/gulp build/pubspec.dart
node ./scripts/ci/dart_ddc/pubspec_for_ddc.js \
    --pubspec-file=dist/dart/playground/pubspec.yaml

# Compile playground
cd dist/dart/playground
$PUB build --mode=debug
cd build/web
LOG_FILE="analyzer.log"
set +e
$DART_SDK/bin/dart $DDC_DIR/bin/dartdevc.dart \
  --dart-sdk=$DART_SDK_LIB_SEARCH_PATH -o out \
  src/animate/index.dart \
  src/async/index.dart \
  src/gestures/index.dart \
  src/hash_routing/index.dart \
  src/hello_world/index.dart \
  src/key_events/index.dart \
  src/material/button/index.dart \
  src/material/checkbox/index.dart \
  src/material/dialog/index.dart \
  src/material/grid_list/index.dart \
  src/material/input/index.dart \
  src/material/progress-linear/index.dart \
  src/material/radio/index.dart \
  src/material/switcher/index.dart \
  src/model_driven_forms/index.dart \
  src/observable_models/index.dart \
  src/order_management/index.dart \
  src/person_management/index.dart \
  src/relative_assets/index.dart \
  src/routing/index.dart \
  src/sourcemap/index.dart \
  src/svg/index.dart \
  src/template_driven_forms/index.dart \
  src/todo/index.dart \
  src/zippy_component/index.dart \
  >$LOG_FILE
EXIT_CODE=`echo $?`
set -e

# Analyzer exits with 1 when there are warnings and something crazy
# like 255 when it crashes. We don't want to fail the build if its
# only warnings (until our code is warning-free).
if [[ "$EXIT_CODE" -ne "0" && "$EXIT_CODE" -ne "1" ]]
then
  echo "DDC compiler crashed with exit code $EXIT_CODE"
  exit 1
fi

cat $LOG_FILE
EXIT_CODE=0

# TODO remove  `grep -v template.dart` after Tobias new compiler lands.

WARNING_COUNT=$(cat $LOG_FILE | grep -E '^warning.*' | grep -v template.dart | wc -l | sed -e 's/^[[:space:]]*//' || true)
ERROR_COUNT=$(cat $LOG_FILE | grep -E '^severe.*' | wc -l | sed -e 's/^[[:space:]]*//' || true)

if [[ "$ERROR_COUNT" -gt "$DDC_TOTAL_ERROR_CAP" ]]
then
  echo "Found severe errors in angular2 package"
  EXIT_CODE=1
fi

if [[ "$WARNING_COUNT" -gt "$DDC_TOTAL_WARNING_CAP" ]]
then
  echo "Too many warnings: $WARNING_COUNT"
  EXIT_CODE=1
else
  echo "Warning count ok"
fi

echo 'Dart DDC build finished'
exit $EXIT_CODE