text:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project

     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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#F5F5F5"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/track"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/album"
            android:layout_width="190dip"
            android:layout_height="190dip"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="24dip"
            android:background="@drawable/album_border_large" />

        <RelativeLayout
            android:layout_width="190dip"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="12dip"
            android:background="@android:color/transparent" >

            <ImageButton
                android:id="@+id/curplaylist"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:background="@android:color/transparent"
                android:src="@drawable/ic_mp_current_playlist_btn" />

            <ImageButton
                android:id="@+id/shuffle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="@android:color/transparent" />

            <ImageButton
                android:id="@+id/repeat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:background="@android:color/transparent" />
        </RelativeLayout>

        <LinearLayout
            android:layout_width="190dip"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:background="@android:color/transparent"
            android:orientation="horizontal"
            android:paddingTop="12dip" >

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="1dip"
                android:background="@drawable/play_devider" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="190dip"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:baselineAligned="false"
            android:orientation="horizontal"
            android:paddingTop="12dip" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="12dip"
                android:src="@drawable/ic_mp_artist_playback" />

            <TextView
                android:id="@+id/artistname"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:ellipsize="end"
                android:singleLine="true"
                android:textColor="@color/dim_foreground_dark"
                android:textSize="14dp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="190dip"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:baselineAligned="false"
            android:paddingTop="12dip" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="12dip"
                android:src="@drawable/ic_mp_album_playback" />

            <TextView
                android:id="@+id/albumname"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:ellipsize="end"
                android:singleLine="true"
                android:textColor="@color/dim_foreground_dark"
                android:textSize="14dp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="190dip"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:baselineAligned="false"
            android:paddingTop="12dip" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="12dip"
                android:src="@drawable/ic_mp_song_playback" />

            <TextView
                android:id="@+id/trackname"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:ellipsize="end"
                android:singleLine="true"
                android:textColor="@color/dim_foreground_dark"
                android:textSize="14dp" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="64dip"
        android:layout_alignParentBottom="true" >

        <RelativeLayout
            android:id="@+id/track_info"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <LinearLayout
                android:layout_width="265dip"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dip"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/lrc_artistname"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:gravity="center_vertical"
                    android:paddingBottom="2dip"
                    android:paddingLeft="24dip"
                    android:paddingRight="10dip"
                    android:singleLine="true"
                    android:textColor="#000000"
                    android:textSize="18dp" />

                <TextView
                    android:id="@+id/lrc_trackname"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:gravity="center_vertical"
                    android:paddingBottom="0dip"
                    android:paddingLeft="24dip"
                    android:paddingRight="10dip"
                    android:paddingTop="0dip"
                    android:singleLine="true"
                    android:textColor="@color/dim_foreground_dark"
                    android:textSize="14dp" />
            </LinearLayout>

            <ImageView
                android:id="@+id/lyric_expend_icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="24dip"
                android:background="@null"
                android:src="@drawable/lyric_display" />
        </RelativeLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/lyric_container"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:orientation="vertical"
        android:visibility="gone" >

        <com.sprd.music.lrc.LyricListView
            android:id="@+id/lyric_list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:cacheColorHint="#e91e63"
            android:clickable="false"
            android:divider="@null"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:longClickable="true"
            android:minHeight="200dip"
            android:scrollbars="none" />

        <TextView
            android:id="@+id/nolrc_notifier"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:paddingBottom="10dip"
            android:paddingLeft="10dip"
            android:paddingRight="10dip"
            android:paddingTop="10dip"
            android:text="@string/nolrc"
            android:visibility="gone" />
    </LinearLayout>

    <include layout="@layout/audio_player_common" />

</LinearLayout>


text: from . import chance, chance_proc

redpajama_set_name: RedPajamaGithub


text: Compilation of solver bots for the algorithm visualization platform quiz questions.


text:
#ifndef GREYSCALEFILTER_H
#define GREYSCALEFILTER_H

#include "abstractimagefilter.h"

#include <QThread>

class GreyscaleFilter : public AbstractImageFilter
{
    Q_OBJECT
public:
    explicit GreyscaleFilter(QObject *parent = 0);
    QString name() const;

protected:
    AbstractImageFilterWorker *createWorker();

};

#endif // GREYSCALEFILTER_H


text:
<?php

/**
 * Created by PhpStorm.
 * User: sglushko
 * Date: 19.10.2017
 * Time: 13:45
 */

namespace reinvently\ondemand\core\vendor\tasker\daemon;

class Params
{
    const PARAMS_UPDATE_INTERVAL = 1;
    const PARAMS_NUMBERS_OF_TASKER = 2;
    const PARAMS_TASKER_SLEEP_INTERVAL = 3;

    /** @var array */
    protected static $params;

    /** @var int */
    protected static $timeNextUpdate;

    /** @var array */
    protected static $paramsDefault;

    /**
     *
     */
    public static function init()
    {
        static::$paramsDefault = [
            [static::PARAMS_UPDATE_INTERVAL, 60],
            [static::PARAMS_NUMBERS_OF_TASKER, 2],
            [static::PARAMS_TASKER_SLEEP_INTERVAL, 5],
        ];

        static::update();
    }

    /**
     * @param $id
     * @return mixed
     */
    public static function get($id)
    {
        static::checkUpdate();
        if (key_exists($id, static::$params)) {
            return static::$params[$id];
        }
        return null;
    }

    /**
     *
     */
    protected static function checkUpdate()
    {
        if (static::$timeNextUpdate < time()) {
            static::update();
        }
    }

    /**
     *
     */
    protected static function update()
    {
        $t = Tasker::getInstance();

        $res = $t->db->query(<<<SQL
SELECT id, `value`
FROM tasker_params
SQL
);

        static::$params = static::$paramsDefault;
        foreach ($res as $param) {
            static::$params[$param['id']] = $param['value'];
        }
        static::$timeNextUpdate = time() + static::$params[static::PARAMS_UPDATE_INTERVAL];
    }

}


text:
id: 56533eb9ac21ba0edf2244d8
title: Comparisons with the Logical And Operator
challengeType: 1
videoUrl: ''
localeTitle: Comparaciones con lo lógico y el operador.
---

## Description

 A veces necesitará probar más de una cosa a la vez. La <dfn>lógica y el</dfn> operador ( && ) devuelven true si y solo si los <dfn>operandos</dfn> a su izquierda y derecha son verdaderos. El mismo efecto podría lograrse anidando una instrucción if dentro de otra si:
 if (num> 5) {
 si (num <10) {
 devuelve "Sí";
 }
 }
 devuelve "No";
 solo devolverá "Sí" si num es mayor que 5 y menor que 10 . La misma lógica se puede escribir como:
 if (num> 5 && num <10) {
 devuelve "Sí";
 }
 devuelve "No";

## Instructions

 Combine las dos declaraciones if en una declaración que devolverá "Yes" si val es menor o igual a 50 y mayor o igual a 25 . De lo contrario, devolverá "No" .

## Tests

```yml
tests:
  - text: Debe usar el operador <code>&&</code> una vez
    testString: 'assert(code.match(/&&/g).length === 1, "You should use the <code>&&</code> operator once");'
  - text: Sólo debe tener una declaración <code>if</code>
    testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement");'
  - text: <code>testLogicalAnd(0)</code> debe devolver "No"
    testString: 'assert(testLogicalAnd(0) === "No", "<code>testLogicalAnd(0)</code> should return "No"");'
  - text: <code>testLogicalAnd(24)</code> debe devolver "No"
    testString: 'assert(testLogicalAnd(24) === "No", "<code>testLogicalAnd(24)</code> should return "No"");'
  - text: <code>testLogicalAnd(25)</code> debe devolver "Sí"
    testString: 'assert(testLogicalAnd(25) === "Yes", "<code>testLogicalAnd(25)</code> should return "Yes"");'
  - text: <code>testLogicalAnd(30)</code> debe devolver "Sí"
    testString: 'assert(testLogicalAnd(30) === "Yes", "<code>testLogicalAnd(30)</code> should return "Yes"");'
  - text: <code>testLogicalAnd(50)</code> debe devolver "Sí"
    testString: 'assert(testLogicalAnd(50) === "Yes", "<code>testLogicalAnd(50)</code> should return "Yes"");'
  - text: <code>testLogicalAnd(51)</code> debe devolver "No"
    testString: 'assert(testLogicalAnd(51) === "No", "<code>testLogicalAnd(51)</code> should return "No"");'
  - text: <code>testLogicalAnd(75)</code> debe devolver "No"
    testString: 'assert(testLogicalAnd(75) === "No", "<code>testLogicalAnd(75)</code> should return "No"");'
  - text: <code>testLogicalAnd(80)</code> debe devolver "No"
    testString: 'assert(testLogicalAnd(80) === "No", "<code>testLogicalAnd(80)</code> should return "No"");'

```

## Challenge Seed

```js
function testLogicalAnd(val) {
  // Only change code below this line

  if (val) {
    if (val) {
      return "Yes";
    }
  }

  // Only change code above this line
  return "No";
}

// Change this value to test
testLogicalAnd(10);

```

## Solution

```js
// solution required
```


text:
require 'url_extractor'

describe UrlExtractor::HTML do
  def html_wrapped_string(string)
    "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\n#{string}\n\n"
  end

  it 'returns a string with the modified URLs that were returned in the block' do
    extractor = UrlExtractor::HTML.new
    text = html_wrapped_string('foo bar Google')

    actual = extractor.replace_urls(text) do |extracted|
      'http://foo.bar'
    end

    actual.should == html_wrapped_string("foo bar Google")
  end

  it 'ignores urls that match patterns provided' do
    extractor = UrlExtractor::HTML.new([/google/])
    text = html_wrapped_string('foo bar Stuff Google')

    actual = extractor.replace_urls(text) do |extracted|
      'http://foo.bar'
    end

    actual.should == html_wrapped_string("foo bar Stuff Google")
  end

  it "ignores URLs that don't match http or https" do
    extractor = UrlExtractor::HTML.new
    text = html_wrapped_string("foo bar Hi")

    actual = extractor.replace_urls(text) do |extracted|
      'http://foo.bar'
    end

    actual.should == text
  end

end


text:
/*
 * p654~p656
 *
 * 基于 I/O 多路复用的并发 echo 服务器。每次服务器迭代都回送来自每个准备好的描述
 * 符的文本行
 *
 * unix> make echoservers
 * unix> ./echoservers
 */

#include "csapp.h"

typedef struct {                /* Represents a pool of connected descriptors */

    int maxfd;              /* Largest descriptor in read_set */
    fd_set read_set;        /* Set of all active descriptors */

    fd_set ready_set;       /* Subset of descriptors ready for reading */
    int nready;             /* Number of ready descriptors from select */

    int maxi;               /* Highwater index into client array */
    int clientfd[FD_SETSIZE]; /* Set of active descriptors */
    rio_t clientrio[FD_SETSIZE]; /* Set of active read buffers */
} pool;

int byte_cnt = 0;               /* Counts total bytes received by server */

void init_pool(int listenfd, pool *p) {
    /* Initially, there are no connected descriptors */
    int i;
    p->maxi = -1;
    for (i = 0; i < FD_SETSIZE; i++)
        p->clientfd[i] = -1;

    /* Initially, listenfd is only member of select read set */
    p->maxfd = listenfd;
    FD_ZERO(&p->read_set);
    FD_SET(listenfd, &p->read_set);
}

void add_client(int connfd, pool *p) {
    int i;
    p->nready--;
    for (i = 0; i < FD_SETSIZE; i++) /* Find an available slot */
        if (p->clientfd[i] < 0) {
            /* Add connected descriptor to the pool */
            p->clientfd[i] = connfd;
            Rio_readinitb(&p->clientrio[i], connfd);

            /* Add the descriptor to descriptor set */
            FD_SET(connfd, &p->read_set);

            /* Update max descriptor and pool highwater mark */
            if (connfd > p->maxfd)
                p->maxfd = connfd;
            if (i > p->maxi)
                p->maxi = i;
            break;
        }
    if (i == FD_SETSIZE)    /* Couldn't find an empty slot */
        app_error("add_client error: Too many clients");
}

void check_client(pool *p) {
    int i, connfd, n;
    char buf[MAXLINE];
    rio_t rio;

    for (i = 0; (i <= p->maxi) && (p->nready > 0); i++) {
        connfd = p->clientfd[i];
        rio = p->clientrio[i];

        /* If the descriptor is ready, echo a text line from it */
        if ((connfd > 0) && (FD_ISSET(connfd, &p->ready_set))) {
            p->nready--;
            if ((n = Rio_readlineb(&rio, buf, MAXLINE)) != 0) {
                byte_cnt += n;
                printf("Server received %d (%d total) bytes on fd %d\n",
                       n, byte_cnt, connfd);
                Rio_writen(connfd, buf, n);
            }

                /* EOF detected, remove descriptor from pool */
            else {
                Close(connfd);
                FD_CLR(connfd, &p->read_set);
                p->clientfd[i] = -1;
            }
        }
    }
}

int main(int argc, char **argv) {
    int listenfd, connfd, port;
    socklen_t clientlen = sizeof(struct sockaddr_in);
    struct sockaddr_in clientaddr;
    static pool pool;

    if (argc != 2) {
        fprintf(stderr, "usage: %s <port>\n", argv[0]);
        exit(0);
    }
    port = atoi(argv[1]);

    listenfd = Open_listenfd(port);
    init_pool(listenfd, &pool);

    while (1) {
        /* Wait for listening/connected descriptor(s) to become ready */
        pool.ready_set = pool.read_set;
        pool.nready = Select(pool.maxfd + 1, &pool.ready_set, NULL, NULL, NULL);

        /* If listening descriptor ready, add new client to pool */
        if (FD_ISSET(listenfd, &pool.ready_set)) {
            connfd = Accept(listenfd, (SA * ) & clientaddr, &clientlen);
            add_client(connfd, &pool);
        }

        /* Echo a text line from each ready connected descriptor */
        check_client(&pool);
    }
}


text:
require_relative '../pig_latin'

class TerminalClient

  def self.start
    puts 'Hello, I speak igpay atinlay!'
    puts 'Type any english word to translate to Pig Latin:'
    get_command
  end

  def self.get_command
    while true
      input = gets.chomp
      PigLatin.create_input(input)
    end
    start
  end

end

TerminalClient.start

# $ bundle exec ruby pig_client.rb


text:
package yang.weiwei.util;

import yang.weiwei.util.format.Fourmat;

public class Word implements Comparable<Word>
{
	private String word;
	private double weight;

	public String getWord()
	{
		return word;
	}

	public double getWeight()
	{
		return weight;
	}

	public Word(String word, double weight)
	{
		this.word=word;
		this.weight=weight;
	}

	public String toString()
	{
		return word+":"+Fourmat.format(weight);
	}

	public int compareTo(Word o)
	{
		return -Double.compare(this.weight, o.weight);
	}

	public boolean equals(Object o)
	{
		if (!(o instanceof Word)) return false;
		return word.equals(((Word)o).word);
	}
}


text:
package org.apache.datasketches.quantiles;

import static org.apache.datasketches.Util.LS;

import java.util.Comparator;

import org.apache.datasketches.ArrayOfItemsSerDe;
import org.apache.datasketches.memory.Memory;

/**
 * The API for Union operations for generic ItemsSketches
 *
 * @param <T> type of item
 *
 * @author Lee Rhodes
 * @author Alexander Saydakov
 */
public final class ItemsUnion<T> {

  protected final int maxK_;
  protected final Comparator<? super T> comparator_;
  protected ItemsSketch<T> gadget_;

  private ItemsUnion(final int maxK, final Comparator<? super T> comparator,
      final ItemsSketch<T> gadget) {
    maxK_ = maxK;
    comparator_ = comparator;
    gadget_ = gadget;
  }

  /**
   * Create an instance of ItemsUnion with the default k
   * @param <T> type of item
   * @param comparator to compare items
   * @return an instance of ItemsUnion
   */
  public static <T> ItemsUnion<T> getInstance(final Comparator<? super T> comparator) {
    return new ItemsUnion<T>(PreambleUtil.DEFAULT_K, comparator, null);
  }

  /**
   * Create an instance of ItemsUnion
   * @param <T> type of item
   * @param maxK determines the accuracy and size of the union and is a maximum value.
   * The effective k can be smaller due to unions with smaller k sketches.
   * It is recommended that maxK be a power of 2 to enable unioning of sketches with
   * different values of k.
   * @param comparator to compare items
   * @return an instance of ItemsUnion
   */
  public static <T> ItemsUnion<T> getInstance(final int maxK, final Comparator<? super T> comparator) {
    return new ItemsUnion<>(maxK, comparator, null);
  }

  /**
   * Heapify the given srcMem into a Union object.
   * @param <T> type of item
   * @param srcMem the given srcMem.
   * A reference to srcMem will not be maintained internally.
   * @param comparator to compare items
   * @param serDe an instance of ArrayOfItemsSerDe
   * @return an instance of ItemsUnion
   */
  public static <T> ItemsUnion<T> getInstance(final Memory srcMem,
      final Comparator<? super T> comparator, final ArrayOfItemsSerDe<T> serDe) {
    final ItemsSketch<T> gadget = ItemsSketch.getInstance(srcMem, comparator, serDe);
    return new ItemsUnion<>(gadget.getK(), gadget.getComparator(), gadget);
  }

  /**
   * Create an instance of ItemsUnion based on ItemsSketch
   * @param <T> type of item
   * @param sketch the basis of the union
   * @return an instance of ItemsUnion
   */
  public static <T> ItemsUnion<T> getInstance(final ItemsSketch<T> sketch) {
    return new ItemsUnion<>(sketch.getK(), sketch.getComparator(), ItemsSketch.copy(sketch));
  }

  /**
   * Iterative union operation, which means this method can be repeatedly called.
   * Merges the given sketch into this union object.
   * The given sketch is not modified.
   * It is required that the ratio of the two K values be a power of 2.
   * This is easily satisfied if each of the K values is already a power of 2.
   * If the given sketch is null or empty it is ignored.
   *
   *
It is required that the results of the union operation, which can be obtained at any time,
   * is obtained from {@link #getResult() }.

   *
   * @param sketchIn the sketch to be merged into this one.
   */
  public void update(final ItemsSketch<T> sketchIn) {
    gadget_ = updateLogic(maxK_, comparator_, gadget_, sketchIn);
  }

  /**
   * Iterative union operation, which means this method can be repeatedly called.
   * Merges the given Memory image of a ItemsSketch into this union object.
   * The given Memory object is not modified and a link to it is not retained.
   * It is required that the ratio of the two K values be a power of 2.
   * This is easily satisfied if each of the K values is already a power of 2.
   * If the given sketch is null or empty it is ignored.
   *
   *
It is required that the results of the union operation, which can be obtained at any time,
   * is obtained from {@link #getResult() }.

   * @param srcMem Memory image of sketch to be merged
   * @param serDe an instance of ArrayOfItemsSerDe
   */
  public void update(final Memory srcMem, final ArrayOfItemsSerDe<T> serDe) {
    final ItemsSketch<T> that = ItemsSketch.getInstance(srcMem, comparator_, serDe);
    gadget_ = updateLogic(maxK_, comparator_, gadget_, that);
  }

  /**
   * Update this union with the given double (or float) data Item.
   *
   * @param dataItem The given datum.
   */
  public void update(final T dataItem) {
    if (dataItem == null) { return; }
    if (gadget_ == null) {
      gadget_ = ItemsSketch.getInstance(maxK_, comparator_);
    }
    gadget_.update(dataItem);
  }

  /**
   * Gets the result of this Union operation as a copy of the internal state.
   * This enables further union update operations on this state.
   * @return the result of this Union operation
   */
  public ItemsSketch<T> getResult() {
    if (gadget_ == null) {
      return ItemsSketch.getInstance(maxK_, comparator_);
    }
    return ItemsSketch.copy(gadget_); //can't have any externally owned handles.
  }

  /**
   * Gets the result of this Union operation (without a copy) and resets this Union to the
   * virgin state.
   *
   * @return the result of this Union operation and reset.
   */
  public ItemsSketch<T> getResultAndReset() {
    if (gadget_ == null) { return null; } //Intentionally return null here for speed.
    final ItemsSketch<T> hqs = gadget_;
    gadget_ = null;
    return hqs;
  }

  /**
   * Resets this Union to a virgin state.
   */
  public void reset() {
    gadget_ = null;
  }

  /**
   * Returns true if this union is empty
   * @return true if this union is empty
   */
  public boolean isEmpty() {
    return (gadget_ == null) || gadget_.isEmpty();
  }

  /**
   * Returns true if this union is direct
   * @return true if this union is direct
   */
  public boolean isDirect() {
    return (gadget_ != null) && gadget_.isDirect();
  }

  /**
   * Returns the configured maxK of this Union.
   * @return the configured maxK of this Union.
   */
  public int getMaxK() {
    return maxK_;
  }

  /**
   * Returns the effective k of this Union.
   * @return the effective k of this Union.
   */
  public int getEffectiveK() {
    return (gadget_ != null) ? gadget_.getK() : maxK_;
  }

  /**
   * Returns summary information about the backing sketch.
   */
  @Override
  public String toString() {
    return toString(true, false);
  }

  /**
   * Returns summary information about the backing sketch. Used for debugging.
   * @param sketchSummary if true includes sketch summary
   * @param dataDetail if true includes data detail
   * @return summary information about the sketch.
   */
  public String toString(final boolean sketchSummary, final boolean dataDetail) {
    final StringBuilder sb = new StringBuilder();
    final String thisSimpleName = this.getClass().getSimpleName();
    final int maxK = this.getMaxK();
    final String kStr = String.format("%,d", maxK);
    sb.append(Util.LS).append("### Quantiles ").append(thisSimpleName).append(LS);
    sb.append("   maxK                         : ").append(kStr);
    if (gadget_ == null) {
      sb.append(ItemsSketch.getInstance(maxK_, comparator_).toString());
      return sb.toString();
    }
    sb.append(gadget_.toString(sketchSummary, dataDetail));
    return sb.toString();
  }

  /**
   * Serialize this union to a byte array. Result is an ItemsSketch, serialized in an
   * unordered, non-compact form. The resulting byte[] can be passed to getInstance for either a
   * sketch or union.
   *
   * @param serDe an instance of ArrayOfItemsSerDe
   * @return byte array of this union
   */
  public byte[] toByteArray(final ArrayOfItemsSerDe<T> serDe) {
    if (gadget_ == null) {
      final ItemsSketch<T> sketch = ItemsSketch.getInstance(maxK_, comparator_);
      return sketch.toByteArray(serDe);
    }
    return gadget_.toByteArray(serDe);
  }

  //@formatter:off
  @SuppressWarnings({"null", "unchecked"})
  static <T> ItemsSketch<T> updateLogic(final int myMaxK, final Comparator<? super T> comparator,
      final ItemsSketch<T> myQS, final ItemsSketch<T> other) {
    int sw1 = ((myQS   == null) ? 0 :   myQS.isEmpty() ? 4 : 8);
    sw1 |=    ((other  == null) ? 0 :  other.isEmpty() ? 1 : 2);
    int outCase = 0; //0=null, 1=NOOP, 2=copy, 3=merge
    switch (sw1) {
      case 0:  outCase = 0; break; //myQS = null,  other = null ; return null
      case 1:  outCase = 4; break; //myQS = null,  other = empty; create empty-heap(myMaxK)
      case 2:  outCase = 2; break; //myQS = null,  other = valid; stream or downsample to myMaxK
      case 4:  outCase = 1; break; //myQS = empty, other = null ; no-op
      case 5:  outCase = 1; break; //myQS = empty, other = empty; no-op
      case 6:  outCase = 3; break; //myQS = empty, other = valid; merge
      case 8:  outCase = 1; break; //myQS = valid, other = null ; no-op
      case 9:  outCase = 1; break; //myQS = valid, other = empty: no-op
      case 10: outCase = 3; break; //myQS = valid, other = valid; merge
      //default: //This cannot happen and cannot be tested
    }
    ItemsSketch<T> ret = null;
    switch (outCase) {
      case 0: ret = null; break;
      case 1: ret = myQS; break;
      case 2: { //myQS = null,  other = valid; stream or downsample to myMaxK
        assert other != null;
        if (!other.isEstimationMode()) { //other is exact, stream items in
          ret = ItemsSketch.getInstance(myMaxK, comparator);
          final int otherCnt = other.getBaseBufferCount();
          final Object[] combBuf = other.getCombinedBuffer();
          for (int i = 0; i < otherCnt; i++) {
            ret.update((T) combBuf[i]);
          }
        }
        else { //myQS = null, other is est mode
          ret = (myMaxK < other.getK())
              ? other.downSample(myMaxK)
              : ItemsSketch.copy(other); //required because caller has handle
        }
        break;
      }
      case 3: { //myQS = empty/valid, other = valid; merge
        assert other != null;
        assert myQS != null;
        if (!other.isEstimationMode()) { //other is exact, stream items in
          ret = myQS;
          final int otherCnt = other.getBaseBufferCount();
          final Object[] combBuf = other.getCombinedBuffer();
          for (int i = 0; i < otherCnt; i++) {
            ret.update((T) combBuf[i]);
          }
        }
        else { //myQS = empty/valid, other = valid and in est mode
          if (myQS.getK() <= other.getK()) { //I am smaller or equal, thus the target
            ItemsMergeImpl.mergeInto(other, myQS);
            ret = myQS;
          }
          else { //Bigger: myQS.getK() > other.getK(), must reverse roles
            //must copy other as it will become mine and can't have any externally owned handles.
            ret = ItemsSketch.copy(other);
            ItemsMergeImpl.mergeInto(myQS, ret);
          }
        }
        break;
      }
      case 4: {
        assert other != null;
        ret = ItemsSketch.getInstance(Math.min(myMaxK, other.getK()), comparator);
        break;
      }
      //default: //This cannot happen and cannot be tested
    }
    return ret;
  }
  //@formatter:on

}


text:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/details_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:visibility="invisible">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <android.support.v4.view.ViewPager
            android:id="@+id/photos_view_pager"
            android:layout_width="match_parent"
            android:layout_height="@dimen/details_image_height"/>

        <me.relex.circleindicator.CircleIndicator
            android:id="@+id/photos_pager_indicator"
            android:layout_width="match_parent"
            android:layout_height="@dimen/pager_indicator_height"/>

        <include
            android:id="@+id/block_name"
            layout="@layout/block_name"/>
        <include
            android:id="@+id/block_rating"
            layout="@layout/block_rating"/>
        <include
            android:id="@+id/block_address"
            layout="@layout/block_address"/>
        <include
            android:id="@+id/block_phone"
            layout="@layout/block_phone"/>
        <include
            android:id="@+id/block_website"
            layout="@layout/block_website"/>
        <include
            android:id="@+id/block_more"
            layout="@layout/block_more"/>
    </LinearLayout>

</ScrollView>


text:
<?php echo __('Search member');?>

<?php echo __('There are all %1% members',array('%1%'=>$total_member))?>

      <?php
    $options = array(
      //'title'  => __('Search Members'),
      'url'    => url_for('@member_search'),
      'button' => __('Search'),
      'method' => 'get'
    );
    /*Form search member*/
    op_include_form('comm_search', $filters, $options,'formMember');
    ?>
    <?php if ($pager->getNbResults()): ?>
    <?php
    $list = array();
    foreach ($pager->getResults() as $key => $member)
    {
      $list[$key] = array();
      $list[$key][__('%nickname%', array('%nickname%' => $op_term['nickname']->titleize()))] = $member->getName();
      $introduction = $member->getProfile('op_preset_self_introduction', true);
      if ($introduction)
      {
        $list[$key][__('Self Introduction')] = $introduction;
      }
      $list[$key][__('Last Login')] = op_format_last_login_time($member->getLastLoginTime());
    }

    $options = array(
     // 'title'          =>  __('Search Results'),
      'pager'          => $pager,
      'link_to_page'   => '@member_search?page=%d',
      'link_to_detail' => '@member_profile?id=%d',
      'list'           => $list,
      'use_op_link_to_member' => true,
    );
    ?>

<?php echo __('Member search result' )?>

    <?php
    op_include_parts('searchResultList1', 'searchCommunityResult', $options);
    ?>
    <?php else: ?>
    <?php op_include_box('searchMemberResult', __('Your search queries did not match any members.'), array('title' => __('Search Results'))) ?>
    <?php endif; ?>


text:
package org.opencompare.api.java.impl.value;

import org.opencompare.api.java.PCMElement;
import org.opencompare.api.java.PCMFactory;
import org.opencompare.api.java.impl.ValueImpl;
import org.opencompare.api.java.util.PCMVisitor;
import org.opencompare.api.java.value.NotAvailable;

/**
 * Created by gbecan on 14/10/14.
 */
public class NotAvailableImpl extends ValueImpl implements NotAvailable {

    private org.opencompare.model.NotAvailable kNotAvailable;

    public NotAvailableImpl(org.opencompare.model.NotAvailable kNotAvailable) {
        super(kNotAvailable);
        this.kNotAvailable = kNotAvailable;
    }

    public org.opencompare.model.NotAvailable getkNotAvailable() {
        return kNotAvailable;
    }

    @Override
    public void accept(PCMVisitor visitor) {
        visitor.visit(this);
    }

    @Override
    public PCMElement clone(PCMFactory factory) {
        NotAvailable copy = factory.createNotAvailable();
        return copy;
    }
}


text: CKEDITOR.plugins.setLang("templates","el",{button:"Πρότυπα",emptyListMsg:"(Δεν έχουν καθοριστεί πρότυπα)",insertOption:"Αντικατάσταση υπάρχοντων περιεχομένων",options:"Επιλογές Προτύπου",selectPromptMsg:"Παρακαλώ επιλέξτε πρότυπο για εισαγωγή στο πρόγραμμα",title:"Πρότυπα Περιεχομένου"});


text:
<?php echo $head;?>

		<?php echo $header;?>

Add Coupon

					<?php
						$sess_notify = $this->session->userdata('has_error');
						if(isset($sess_notify) & $sess_notify){
					?>

						<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
						<?php echo $this->session->userdata('couponedit_notification');?>

					<?php }
						$this->session->unset_userdata('has_error');
						$this->session->unset_userdata('couponedit_notification');
					?>

									<form action="<?php echo base_url('admin/coupon/edit_coupon');?>" method="POST" role="form" novalidate>

											Coupon Code *
											<input class="form-control" type="text" name="coupon_code" placeholder="Enter Coupon Code" value="<?php if(isset($coupon_details->coupon_code) && $coupon_details->coupon_code){echo $coupon_details->coupon_code;}?>">

											Discount *
											<input class="form-control" type="text" name="discount" placeholder="Enter Discount" value="<?php if(isset($coupon_details->discount) && $coupon_details->discount){echo $coupon_details->discount;}?>">

											Status

												<input type="radio" name="is_active" value="1" <?php if(isset($coupon_details->is_active)){if($coupon_details->is_active){echo 'checked';}}else{echo 'checked';}?>>Active

												<input type="radio" name="is_active" value="0" <?php if(isset($coupon_details->is_active)){if(!$coupon_details->is_active){echo 'checked';}}else{echo 'checked';}?>>Inactive

										<input type="hidden" name="old_coupon_code" value="<?php echo $coupon_details->coupon_code;?>">
										<input type="hidden" name="coupon_id" value="<?php echo $coupon_details->coupon_id;?>">
										<button type="submit" class="btn btn-primary">Save Changes</button>
									</form>

	<?php echo $footer; ?>


text:
package org.apache.flink.table.sources;

import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.io.CsvInputFormat;
import org.apache.flink.api.java.io.RowCsvInputFormat;
import org.apache.flink.api.java.typeutils.RowTypeInfo;
import org.apache.flink.core.fs.FileInputSplit;
import org.apache.flink.core.fs.Path;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.DataTypes;
import org.apache.flink.table.api.TableSchema;
import org.apache.flink.table.functions.AsyncTableFunction;
import org.apache.flink.table.functions.FunctionContext;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.table.types.DataType;
import org.apache.flink.table.types.utils.TypeConversions;
import org.apache.flink.types.Row;

import java.io.Serializable;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.IntStream;

import static org.apache.flink.table.types.utils.TypeConversions.fromDataTypeToLegacyInfo;

/**
 * A {@link StreamTableSource} and {@link BatchTableSource} for simple CSV files with a
 * (logically) unlimited number of fields.
 */
public class CsvTableSource
	implements StreamTableSource<Row>, BatchTableSource<Row>, LookupableTableSource<Row>,
	ProjectableTableSource<Row> {

	private final CsvInputFormatConfig config;

	/**
	 * A {@link InputFormatTableSource} and {@link LookupableTableSource} for simple CSV files with
	 * a (logically) unlimited number of fields.
	 *
	 * @param path       The path to the CSV file.
	 * @param fieldNames The names of the table fields.
	 * @param fieldTypes The types of the table fields.
	 */
	public CsvTableSource(String path, String[] fieldNames, TypeInformation<?>[] fieldTypes) {
		this(path, fieldNames, fieldTypes,
				IntStream.range(0, fieldNames.length).toArray(),
				CsvInputFormat.DEFAULT_FIELD_DELIMITER, CsvInputFormat.DEFAULT_LINE_DELIMITER,
				null, false, null, false);
	}

	/**
	 * A {@link InputFormatTableSource} and {@link LookupableTableSource} for simple CSV files with
	 * a (logically) unlimited number of fields.
	 *
	 * @param path            The path to the CSV file.
	 * @param fieldNames      The names of the table fields.
	 * @param fieldTypes      The types of the table fields.
	 * @param fieldDelim      The field delimiter, "," by default.
	 * @param lineDelim       The row delimiter, "\n" by default.
	 * @param quoteCharacter  An optional quote character for String values, null by default.
	 * @param ignoreFirstLine Flag to ignore the first line, false by default.
	 * @param ignoreComments  An optional prefix to indicate comments, null by default.
	 * @param lenient         Flag to skip records with parse error instead to fail, false by
	 *                        default.
	 */
	public CsvTableSource(
			String path,
			String[] fieldNames,
			TypeInformation<?>[] fieldTypes,
			String fieldDelim,
			String lineDelim,
			Character quoteCharacter,
			boolean ignoreFirstLine,
			String ignoreComments,
			boolean lenient) {
		this(path, fieldNames, fieldTypes,
				IntStream.range(0, fieldNames.length).toArray(),
				fieldDelim, lineDelim, quoteCharacter,
				ignoreFirstLine, ignoreComments, lenient);
	}

	/**
	 * A {@link InputFormatTableSource} and {@link LookupableTableSource} for simple CSV files with
	 * a (logically) unlimited number of fields.
	 *
	 * @param path            The path to the CSV file.
	 * @param fieldNames      The names of the table fields.
	 * @param fieldTypes      The types of the table fields.
	 * @param selectedFields  The fields which will be read and returned by the table source. If
	 *                        None, all fields are returned.
	 * @param fieldDelim      The field delimiter, "," by default.
	 * @param lineDelim       The row delimiter, "\n" by default.
	 * @param quoteCharacter  An optional quote character for String values, null by default.
	 * @param ignoreFirstLine Flag to ignore the first line, false by default.
	 * @param ignoreComments  An optional prefix to indicate comments, null by default.
	 * @param lenient         Flag to skip records with parse error instead to fail, false by
	 *                        default.
	 */
	public CsvTableSource(
			String path,
			String[] fieldNames,
			TypeInformation<?>[] fieldTypes,
			int[] selectedFields,
			String fieldDelim,
			String lineDelim,
			Character quoteCharacter,
			boolean ignoreFirstLine,
			String ignoreComments,
			boolean lenient) {
		this(new CsvInputFormatConfig(
				path, fieldNames, TypeConversions.fromLegacyInfoToDataType(fieldTypes), selectedFields,
				fieldDelim, lineDelim, quoteCharacter, ignoreFirstLine,
				ignoreComments, lenient, false));
	}

	private CsvTableSource(CsvInputFormatConfig config) {
		this.config = config;
	}

	/**
	 * Return a new builder that builds a CsvTableSource. For example:
	 * <pre>
	 * CsvTableSource source = new CsvTableSource.builder()
	 *     .path("/path/to/your/file.csv")
	 *     .field("myfield", Types.STRING)
	 *     .field("myfield2", Types.INT)
	 *     .build();
	 * </pre>
	 *
	 * @return a new builder to build a CsvTableSource
	 */
	public static Builder builder() {
		return new Builder();
	}

	@Override
	public DataType getProducedDataType() {
		return TableSchema.builder()
			.fields(config.getSelectedFieldNames(), config.getSelectedFieldDataTypes())
			.build()
			.toRowDataType();
	}

	@SuppressWarnings("unchecked")
	private TypeInformation<Row> getProducedTypeInformation() {
		return (TypeInformation<Row>) fromDataTypeToLegacyInfo(getProducedDataType());
	}

	@Override
	public TableSchema getTableSchema() {
		return TableSchema.builder()
			.fields(config.fieldNames, config.fieldTypes)
			.build();
	}

	@Override
	public CsvTableSource projectFields(int[] fields) {
		if (fields.length == 0) {
			fields = new int[0];
		}
		return new CsvTableSource(config.select(fields));
	}

	@Override
	public boolean isBounded() {
		return true;
	}

	@Override
	public DataStream<Row> getDataStream(StreamExecutionEnvironment execEnv) {
		return execEnv
			.createInput(config.createInputFormat(), getProducedTypeInformation())
			.name(explainSource());
	}

	@Override
	public DataSet<Row> getDataSet(ExecutionEnvironment execEnv) {
		return execEnv
			.createInput(config.createInputFormat(), getProducedTypeInformation())
			.name(explainSource());
	}

	@Override
	public TableFunction<Row> getLookupFunction(String[] lookupKeys) {
		return new CsvLookupFunction(config, lookupKeys);
	}

	@Override
	public AsyncTableFunction<Row> getAsyncLookupFunction(String[] lookupKeys) {
		throw new UnsupportedOperationException("CSV do not support async lookup");
	}

	@Override
	public boolean isAsyncEnabled() {
		return false;
	}

	@Override
	public String explainSource() {
		String[] fields = config.getSelectedFieldNames();
		return "CsvTableSource(read fields: " + String.join(", ", fields) + ")";
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}
		CsvTableSource that = (CsvTableSource) o;
		return Objects.equals(config, that.config);
	}

	@Override
	public int hashCode() {
		return Objects.hash(config);
	}

	/**
	 * A builder for creating CsvTableSource instances.
	 */
	public static class Builder {
		private LinkedHashMap<String, DataType> schema = new LinkedHashMap<>();
		private Character quoteCharacter;
		private String path;
		private String fieldDelim = CsvInputFormat.DEFAULT_FIELD_DELIMITER;
		private String lineDelim = CsvInputFormat.DEFAULT_LINE_DELIMITER;
		private boolean isIgnoreFirstLine = false;
		private String commentPrefix;
		private boolean lenient = false;
		private boolean emptyColumnAsNull = false;

		/**
		 * Sets the path to the CSV file. Required.
		 *
		 * @param path the path to the CSV file
		 */
		public Builder path(String path) {
			this.path = path;
			return this;
		}

		/**
		 * Sets the field delimiter, "," by default.
		 *
		 * @param delim the field delimiter
		 */
		public Builder fieldDelimiter(String delim) {
			this.fieldDelim = delim;
			return this;
		}

		/**
		 * Sets the line delimiter, "\n" by default.
		 *
		 * @param delim the line delimiter
		 */
		public Builder lineDelimiter(String delim) {
			this.lineDelim = delim;
			return this;
		}

		/**
		 * Adds a field with the field name and the data type. Required. This method can be
		 * called multiple times. The call order of this method defines also the order of the fields
		 * in a row.
		 *
		 * @param fieldName the field name
		 * @param fieldType the data type of the field
		 */
		public Builder field(String fieldName, DataType fieldType) {
			if (schema.containsKey(fieldName)) {
				throw new IllegalArgumentException("Duplicate field name " + fieldName);
			}
			// CSV only support java.sql.Timestamp/Date/Time
			DataType type;
			switch (fieldType.getLogicalType().getTypeRoot()) {
				case TIMESTAMP_WITHOUT_TIME_ZONE:
					type = fieldType.bridgedTo(Timestamp.class);
					break;
				case TIME_WITHOUT_TIME_ZONE:
					type = fieldType.bridgedTo(Time.class);
					break;
				case DATE:
					type = fieldType.bridgedTo(Date.class);
					break;
				default:
					type = fieldType;
			}
			schema.put(fieldName, type);
			return this;
		}

		/**
		 * Adds a field with the field name and the type information. Required. This method can be
		 * called multiple times. The call order of this method defines also the order of the fields
		 * in a row.
		 *
		 * @param fieldName the field name
		 * @param fieldType the type information of the field
		 * @deprecated This method will be removed in future versions as it uses the old type system. It
		 * 	           is recommended to use {@link #field(String, DataType)} instead which uses the new type
		 * 	           system based on {@link DataTypes}. Please make sure to use either the old or the new
		 * 	           type system consistently to avoid unintended behavior. See the website documentation
		 * 	           for more information.
		 */
		@Deprecated
		public Builder field(String fieldName, TypeInformation<?> fieldType) {
			return field(fieldName, TypeConversions.fromLegacyInfoToDataType(fieldType));
		}

		/**
		 * Sets a quote character for String values, null by default.
		 *
		 * @param quote the quote character
		 */
		public Builder quoteCharacter(Character quote) {
			this.quoteCharacter = quote;
			return this;
		}

		/**
		 * Sets a prefix to indicate comments, null by default.
		 *
		 * @param prefix the prefix to indicate comments
		 */
		public Builder commentPrefix(String prefix) {
			this.commentPrefix = prefix;
			return this;
		}

		/**
		 * Ignore the first line. Not skip the first line by default.
		 */
		public Builder ignoreFirstLine() {
			this.isIgnoreFirstLine = true;
			return this;
		}

		/**
		 * Skip records with parse error instead to fail. Throw an exception by default.
		 */
		public Builder ignoreParseErrors() {
			this.lenient = true;
			return this;
		}

		/**
		 * Treat empty column as null, false by default.
		 */
		public Builder emptyColumnAsNull() {
			this.emptyColumnAsNull = true;
			return this;
		}

		/**
		 * Apply the current values and constructs a newly-created CsvTableSource.
		 *
		 * @return a newly-created CsvTableSource
		 */
		public CsvTableSource build() {
			if (path == null) {
				throw new IllegalArgumentException("Path must be defined.");
			}
			if (schema.isEmpty()) {
				throw new IllegalArgumentException("Fields can not be empty.");
			}

			return new CsvTableSource(new CsvInputFormatConfig(
					path,
					schema.keySet().toArray(new String[0]),
					schema.values().toArray(new DataType[0]),
					IntStream.range(0, schema.values().size()).toArray(),
					fieldDelim,
					lineDelim,
					quoteCharacter,
					isIgnoreFirstLine,
					commentPrefix,
					lenient,
					emptyColumnAsNull));
		}
	}

	// ------------------------------------------------------------------------------------
	// private utilities
	// ------------------------------------------------------------------------------------

	/**
	 * LookupFunction to support lookup in CsvTableSource.
	 */
	public static class CsvLookupFunction extends TableFunction<Row> {
		private static final long serialVersionUID = 1L;

		private final CsvInputFormatConfig config;

		private final List<Integer> sourceKeys = new ArrayList<>();
		private final List<Integer> targetKeys = new ArrayList<>();
		private final Map<Object, List<Row>> dataMap = new HashMap<>();

		CsvLookupFunction(CsvInputFormatConfig config, String[] lookupKeys) {
			this.config = config;

			List<String> fields = Arrays.asList(config.getSelectedFieldNames());
			for (int i = 0; i < lookupKeys.length; i++) {
				sourceKeys.add(i);
				int targetIdx = fields.indexOf(lookupKeys[i]);
				assert targetIdx != -1;
				targetKeys.add(targetIdx);
			}
		}

		@Override
		public TypeInformation<Row> getResultType() {
			return new RowTypeInfo(config.getSelectedFieldTypes(), config.getSelectedFieldNames());
		}

		@Override
		public void open(FunctionContext context) throws Exception {
			super.open(context);
			TypeInformation<Row> rowType = getResultType();

			RowCsvInputFormat inputFormat = config.createInputFormat();
			FileInputSplit[] inputSplits = inputFormat.createInputSplits(1);
			for (FileInputSplit split : inputSplits) {
				inputFormat.open(split);
				Row row = new Row(rowType.getArity());
				while (true) {
					Row r = inputFormat.nextRecord(row);
					if (r == null) {
						break;
					} else {
						Object key = getTargetKey(r);
						List<Row> rows = dataMap.computeIfAbsent(key, k -> new ArrayList<>());
						rows.add(Row.copy(r));
					}
				}
				inputFormat.close();
			}
		}

		public void eval(Object... values) {
			Object srcKey = getSourceKey(Row.of(values));
			if (dataMap.containsKey(srcKey)) {
				for (Row row1 : dataMap.get(srcKey)) {
					collect(row1);
				}
			}
		}

		private Object getSourceKey(Row source) {
			return getKey(source, sourceKeys);
		}

		private Object getTargetKey(Row target) {
			return getKey(target, targetKeys);
		}

		private Object getKey(Row input, List<Integer> keys) {
			if (keys.size() == 1) {
				int keyIdx = keys.get(0);
				if (input.getField(keyIdx) != null) {
					return input.getField(keyIdx);
				}
				return null;
			} else {
				Row key = new Row(keys.size());
				for (int i = 0; i < keys.size(); i++) {
					int keyIdx = keys.get(i);
					key.setField(i, input.getField(keyIdx));
				}
				return key;
			}
		}

		@Override
		public void close() throws Exception {
			super.close();
		}
	}

	private static class CsvInputFormatConfig implements Serializable {
		private static final long serialVersionUID = 1L;

		private final String path;
		private final String[] fieldNames;
		private final DataType[] fieldTypes;
		private final int[] selectedFields;

		private final String fieldDelim;
		private final String lineDelim;
		private final Character quoteCharacter;
		private final boolean ignoreFirstLine;
		private final String ignoreComments;
		private final boolean lenient;
		private final boolean emptyColumnAsNull;

		CsvInputFormatConfig(
			String path,
			String[] fieldNames,
			DataType[] fieldTypes,
			int[] selectedFields,
			String fieldDelim,
			String lineDelim,
			Character quoteCharacter,
			boolean ignoreFirstLine,
			String ignoreComments,
			boolean lenient,
			boolean emptyColumnAsNull) {

			this.path = path;
			this.fieldNames = fieldNames;
			this.fieldTypes = fieldTypes;
			this.selectedFields = selectedFields;
			this.fieldDelim = fieldDelim;
			this.lineDelim = lineDelim;
			this.quoteCharacter = quoteCharacter;
			this.ignoreFirstLine = ignoreFirstLine;
			this.ignoreComments = ignoreComments;
			this.lenient = lenient;
			this.emptyColumnAsNull = emptyColumnAsNull;
		}

		String[] getSelectedFieldNames() {
			String[] selectedFieldNames = new String[selectedFields.length];
			for (int i = 0; i < selectedFields.length; i++) {
				selectedFieldNames[i] = fieldNames[selectedFields[i]];
			}
			return selectedFieldNames;
		}

		DataType[] getSelectedFieldDataTypes() {
			DataType[] selectedFieldTypes = new DataType[selectedFields.length];
			for (int i = 0; i < selectedFields.length; i++) {
				selectedFieldTypes[i] = fieldTypes[selectedFields[i]];
			}
			return selectedFieldTypes;
		}

		TypeInformation<?>[] getSelectedFieldTypes() {
			return Arrays.stream(getSelectedFieldDataTypes())
				.map(TypeConversions::fromDataTypeToLegacyInfo)
				.toArray(TypeInformation[]::new);
		}

		RowCsvInputFormat createInputFormat() {
			RowCsvInputFormat inputFormat = new RowCsvInputFormat(
				new Path(path),
				getSelectedFieldTypes(),
				lineDelim,
				fieldDelim,
				selectedFields,
				emptyColumnAsNull);
			inputFormat.setSkipFirstLineAsHeader(ignoreFirstLine);
			inputFormat.setCommentPrefix(ignoreComments);
			inputFormat.setLenient(lenient);
			if (quoteCharacter != null) {
				inputFormat.enableQuotedStringParsing(quoteCharacter);
			}
			return inputFormat;
		}

		CsvInputFormatConfig select(int[] fields) {
			return new CsvInputFormatConfig(path, fieldNames, fieldTypes, fields,
				fieldDelim, lineDelim, quoteCharacter, ignoreFirstLine, ignoreComments, lenient, emptyColumnAsNull);
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) {
				return true;
			}
			if (o == null || getClass() != o.getClass()) {
				return false;
			}
			CsvInputFormatConfig that = (CsvInputFormatConfig) o;
			return ignoreFirstLine == that.ignoreFirstLine &&
					lenient == that.lenient &&
					Objects.equals(path, that.path) &&
					Arrays.equals(fieldNames, that.fieldNames) &&
					Arrays.equals(fieldTypes, that.fieldTypes) &&
					Arrays.equals(selectedFields, that.selectedFields) &&
					Objects.equals(fieldDelim, that.fieldDelim) &&
					Objects.equals(lineDelim, that.lineDelim) &&
					Objects.equals(quoteCharacter, that.quoteCharacter) &&
					Objects.equals(ignoreComments, that.ignoreComments) &&
					Objects.equals(emptyColumnAsNull, that.emptyColumnAsNull);
		}

		@Override
		public int hashCode() {
			int result = Objects.hash(path, fieldDelim, lineDelim, quoteCharacter, ignoreFirstLine,
					ignoreComments, lenient, emptyColumnAsNull);
			result = 31 * result + Arrays.hashCode(fieldNames);
			result = 31 * result + Arrays.hashCode(fieldTypes);
			result = 31 * result + Arrays.hashCode(selectedFields);
			return result;
		}
	}
}


text:
package com.karasiq.scalajsbundler

import com.karasiq.scalajsbundler

import java.io.IOException
import java.nio.file.{Path, _}
import java.nio.file.attribute.BasicFileAttributes
import scala.collection.mutable.ListBuffer
import sbt.{Def, _}
import sbt.Keys._
import sbt.plugins.JvmPlugin
import com.karasiq.scalajsbundler.ScalaJSBundler.Bundle
import com.karasiq.scalajsbundler.compilers.AssetCompilers
import com.karasiq.scalajsbundler.dsl.SJSShortcuts

object SJSAssetBundlerPlugin extends AutoPlugin {
  private def clearDirectory(destDir: Path): Unit =
    if (Files.isSymbolicLink(destDir) && Files.isRegularFile(destDir)) {
      Files.delete(destDir)
    } else if (Files.isDirectory(destDir)) {
      Files.walkFileTree(
        destDir,
        new SimpleFileVisitor[Path] {
          override def visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult = {
            Files.delete(file)
            FileVisitResult.CONTINUE
          }

          override def postVisitDirectory(dir: Path, exc: IOException): FileVisitResult = {
            Files.delete(dir)
            FileVisitResult.CONTINUE
          }
        }
      )
    }

  private def fileList(destDir: Path): Seq[File] = {
    val buffer = new ListBuffer[File]()
    Files.walkFileTree(
      destDir,
      new SimpleFileVisitor[Path] {
        override def visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult = {
          buffer += file.toFile
          FileVisitResult.CONTINUE
        }
      }
    )

    buffer.result()
  }

  object autoImport {
    val scalaJsBundlerAssets = taskKey[Seq[Bundle]]("Scala.js bundler resources.")
    val scalaJsBundlerDest   = settingKey[File]("Scala.js bundler output directory.")
    val scalaJsBundlerInline =
      settingKey[Boolean]("Scala.js bundler inline setting. All scripts and styles will be inlined in HTML if enabled.")
    val scalaJsBundlerCompilers = settingKey[AssetCompilers]("Scala.js asset compilers.")
    val scalaJsBundlerCompile   = taskKey[Seq[File]]("Compiles Scala.js bundles.")

    val SJSApps = scalajsbundler.dsl.SJSShortcuts
    val SJSAssetCompilers = AssetCompilers

    lazy val baseSJSAssetBundlerSettings: Seq[Def.Setting[_]] =
      Seq(
        scalaJsBundlerAssets    := Nil,
        scalaJsBundlerDest      := resourceManaged.value / "webapp",
        scalaJsBundlerInline    := false,
        scalaJsBundlerCompilers := AssetCompilers.default,
        scalaJsBundlerCompile := {
          streams.value.log.info("Compiling Scala.js assets")
          clearDirectory(scalaJsBundlerDest.value.toPath)
          val compiler = new ScalaJSBundleCompiler
          scalaJsBundlerAssets.value.foreach { case Bundle(page, contents @ _*) =>
            compiler.createHtml(
              scalaJsBundlerCompilers.value,
              scalaJsBundlerDest.value.toString,
              page,
              contents.flatten,
              scalaJsBundlerInline.value
            )
          }
          fileList(scalaJsBundlerDest.value.toPath)
        },
        managedResources ++= scalaJsBundlerCompile.value
      )
  }

  import autoImport._

  override def requires: Plugins =
    JvmPlugin

  override val projectSettings: Seq[Def.Setting[_]] = inConfig(Compile)(baseSJSAssetBundlerSettings)
}


text:
from django.apps import AppConfig

class DeductionsConfig(AppConfig):
    name = 'clarityv2.deductions'


text:
package dyvilx.tools.compiler;

public final class Main
{
	public static void main(String[] args)
	{
		System.exit(new DyvilCompiler().run(System.in, System.out, System.err, args));
	}
}


text:
var baseURL = "/feedreader/test";
var apiUrlStream = '/api_stream.jsp';
var apiUrlRead = '/api_markread.jsp';
var newsTmpl = {};
var streamId = 0;
var page = 0;
var position = 0;

var topUnread = undefined;

Handlebars.registerHelper("position", function() {
    return ++position;
});

function initNews()
{
    console.log("init news");
    newsTmpl =  Handlebars.compile($("#news_stream_tmpl").html());

    window.onscroll = function(obj)
    {
        if ($("#more").visible()) {
            more();
        }

        if (!topUnread) return;
        var o = topUnread.get(0);

        if (typeof o.getBoundingClientRect === 'function')
        {
            // Use this native browser method, if available.
            var box = o.getBoundingClientRect();
            if (box.top < 30)
            {
                topUnread = topUnread.next("p");
                lastTopY =  box.top;
                markRead(o);
            }
        }
    };
}

function apiMarkRead(entries, callback)
{
    var queryData = {};
    queryData.e = entries;
//    console.log(queryData);

    $.get(baseURL + apiUrlRead, queryData, function(data, status)
    {
        if (callback) callback(data, status);
    });
}

function markAllRead()
{
    var entries = "";
    $(".news").not(".read").each( function(idx, o)
    {
        $(o).addClass("read");
        $("#unread").text(""+ (--count));
        entries += $(o).attr("id") + ",";
    });

    apiMarkRead($(o).attr("id"), function(data, status) {
//            console.log("mark read " + status);
//            console.log(data);
    });
//    console.log(entries.length)
//    if (entries.length > 0) entries = entries.slice(0, -1);
//
//    apiMarkRead(entries, function(data, status) {
//        console.log("mark all read " + status);
//        console.log(data);
//    });

    $("#mark_all_read").hide();
}

function more()
{
    loadStreamEntries(streamId, page++);
}

function renderEntries(data)
{
    console.log("rendering entries " + data.entries.length);

    $("#unread").text(data.unread);

    $("#stream_entries").append(newsTmpl({"entries" : data.entries}));

    if (data.entries.length == 0) {
        $("#more").hide();
        return;
    }

    $("#more").show();
    $("#mark_all_read").show();

    if (topUnread == undefined) {
        topUnread = $(".news").first();
        console.log("top set to ");
        console.log(topUnread);
    }

    console.log("top  id : " + topUnread.get(0).id);
}

function markRead(obj)
{
    if(typeof obj == "number") {
        obj = $("#" + obj).get(0);
    }

//    console.log("marking entry as read " + entryId);
    var count = $("#unread").text();

    $("#unread").text(""+ (--count));
    obj.className = obj.className + " read";

    apiMarkRead(obj.id, function(data, status) {
//        console.log("mark read " + status);
//        console.log(data);
    });
}

function loadStreamEntries(streamId)
{
//    console.log("get entries for feed stream " + streamId + ", page " + page);
    this.streamId = streamId;
    var len = $(".news").not(".read").length;

//    if (len) console.log("skipping " + len);

    var queryData = {};
    queryData.id = streamId;
    queryData.offset = len;

    $.getJSON(baseURL + apiUrlStream, queryData, function(data)
    {
        renderEntries(data);
    });
}


text:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.PDFFindBar = void 0;

var _pdf_find_controller = require("./pdf_find_controller.js");

const MATCHES_COUNT_LIMIT = 1000;

class PDFFindBar {
  constructor(options, eventBus, l10n) {
    this.opened = false;
    this.bar = options.bar;
    this.toggleButton = options.toggleButton;
    this.findField = options.findField;
    this.highlightAll = options.highlightAllCheckbox;
    this.caseSensitive = options.caseSensitiveCheckbox;
    this.entireWord = options.entireWordCheckbox;
    this.findMsg = options.findMsg;
    this.findResultsCount = options.findResultsCount;
    this.findPreviousButton = options.findPreviousButton;
    this.findNextButton = options.findNextButton;
    this.eventBus = eventBus;
    this.l10n = l10n;
    this.toggleButton.addEventListener("click", () => {
      this.toggle();
    });
    this.findField.addEventListener("input", () => {
      this.dispatchEvent("");
    });
    this.bar.addEventListener("keydown", e => {
      switch (e.keyCode) {
        case 13:
          if (e.target === this.findField) {
            this.dispatchEvent("again", e.shiftKey);
          }

          break;

        case 27:
          this.close();
          break;
      }
    });
    this.findPreviousButton.addEventListener("click", () => {
      this.dispatchEvent("again", true);
    });
    this.findNextButton.addEventListener("click", () => {
      this.dispatchEvent("again", false);
    });
    this.highlightAll.addEventListener("click", () => {
      this.dispatchEvent("highlightallchange");
    });
    this.caseSensitive.addEventListener("click", () => {
      this.dispatchEvent("casesensitivitychange");
    });
    this.entireWord.addEventListener("click", () => {
      this.dispatchEvent("entirewordchange");
    });

    this.eventBus._on("resize", this._adjustWidth.bind(this));
  }

  reset() {
    this.updateUIState();
  }

  dispatchEvent(type, findPrev) {
    this.eventBus.dispatch("find", {
      source: this,
      type,
      query: this.findField.value,
      phraseSearch: true,
      caseSensitive: this.caseSensitive.checked,
      entireWord: this.entireWord.checked,
      highlightAll: this.highlightAll.checked,
      findPrevious: findPrev
    });
  }

  updateUIState(state, previous, matchesCount) {
    let findMsg = Promise.resolve("");
    let status = "";

    switch (state) {
      case _pdf_find_controller.FindState.FOUND:
        break;

      case _pdf_find_controller.FindState.PENDING:
        status = "pending";
        break;

      case _pdf_find_controller.FindState.NOT_FOUND:
        findMsg = this.l10n.get("find_not_found");
        status = "notFound";
        break;

      case _pdf_find_controller.FindState.WRAPPED:
        findMsg = this.l10n.get(`find_reached_${previous ? "top" : "bottom"}`);
        break;
    }

    this.findField.setAttribute("data-status", status);
    findMsg.then(msg => {
      this.findMsg.textContent = msg;

      this._adjustWidth();
    });
    this.updateResultsCount(matchesCount);
  }

  updateResultsCount({
    current = 0,
    total = 0
  } = {}) {
    const limit = MATCHES_COUNT_LIMIT;
    let matchCountMsg = Promise.resolve("");

    if (total > 0) {
      if (total > limit) {
        let key = "find_match_count_limit";
        matchCountMsg = this.l10n.get(key, {
          limit
        });
      } else {
        let key = "find_match_count";
        matchCountMsg = this.l10n.get(key, {
          current,
          total
        });
      }
    }

    matchCountMsg.then(msg => {
      this.findResultsCount.textContent = msg;
      this.findResultsCount.classList.toggle("hidden", !total);

      this._adjustWidth();
    });
  }

  open() {
    if (!this.opened) {
      this.opened = true;
      this.toggleButton.classList.add("toggled");
      this.toggleButton.setAttribute("aria-expanded", "true");
      this.bar.classList.remove("hidden");
    }

    this.findField.select();
    this.findField.focus();

    this._adjustWidth();
  }

  close() {
    if (!this.opened) {
      return;
    }

    this.opened = false;
    this.toggleButton.classList.remove("toggled");
    this.toggleButton.setAttribute("aria-expanded", "false");
    this.bar.classList.add("hidden");
    this.eventBus.dispatch("findbarclose", {
      source: this
    });
  }

  toggle() {
    if (this.opened) {
      this.close();
    } else {
      this.open();
    }
  }

  _adjustWidth() {
    if (!this.opened) {
      return;
    }

    this.bar.classList.remove("wrapContainers");
    const findbarHeight = this.bar.clientHeight;
    const inputContainerHeight = this.bar.firstElementChild.clientHeight;

    if (findbarHeight > inputContainerHeight) {
      this.bar.classList.add("wrapContainers");
    }
  }

}

exports.PDFFindBar = PDFFindBar;


text:
<!--
  Copyright 2016 Goldman Sachs.
  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.
  -->

<MithraObject>

    <PackageName>com.gs.fw.common.mithra.test.glew</PackageName>
    <ClassName>LewContract</ClassName>
    <SuperClass name="LewObject" generated="true"/>
    <Import>com.gs.fw.common.mithra.test.glew.LewObject</Import>
    <DefaultTable>LEW_CONTRACT</DefaultTable>

    <Attribute name="instrumentId" javaType="int" columnName="INSTRUMENT_I" primaryKey="true"/>
    <Attribute name="acctId" javaType="int" columnName="ACCT_I"/>
    <Attribute name="crossAcctId" javaType="int" columnName="CROSS_ACCT_I" defaultIfNull="0"/>

    <Attribute name="productSynonym" javaType="String" maxLength="32" columnName="PROD_SYN_N"/>
    <Attribute name="productSynonymType" javaType="String" maxLength="15" columnName="PROD_SYN_TYP_C"/>
    <Attribute name="instrumentType" javaType="String" maxLength="30" columnName="INSTR_TYPE_C"/>
    <Attribute name="instrumentSubtype" javaType="String" maxLength="10" columnName="INSTR_SUBTYPE_C"/>
    <Attribute name="scrpClassId" javaType="int" columnName="CLASS_I"/>
    <Attribute name="debtClass" javaType="String" maxLength="9" columnName="DEBT_CLASS_N"/>

    <!-- Transaction Relationships -->
    <Relationship name="lewTransaction" relatedObject="LewTransaction" cardinality="one-to-one">
        LewTransaction.acctId = this.acctId and
        LewTransaction.instrumentId = this.instrumentId
    </Relationship>

    <Relationship name="scrp" relatedObject="GlewScrp" cardinality="one-to-one">
        GlewScrp.name = this.debtClass
        and GlewScrp.viewId = 1005
    </Relationship>

    <Relationship name="product" relatedObject="LewProduct" cardinality="one-to-one">
        LewProduct.instrumentId = this.instrumentId
    </Relationship>

    <Relationship name="productWithLeftRegion" relatedObject="LewProduct" cardinality="one-to-one">
        LewProduct.instrumentId = this.instrumentId and
        this.region = "NYK"
    </Relationship>

    <Relationship name="productWithLeftAsOfAttribute" relatedObject="LewProduct" cardinality="one-to-one">
        LewProduct.instrumentId = this.instrumentId and
        this.processingDate = {com.gs.fw.common.mithra.util.DefaultInfinityTimestamp.getDefaultInfinity()}
    </Relationship>

    <Relationship name="productWithRightRegion" relatedObject="LewProduct" cardinality="one-to-one">
        LewProduct.instrumentId = this.instrumentId and
        LewProduct.region = "NYK"
    </Relationship>

    <Relationship name="productWithRightAsOfAttribute" relatedObject="LewProduct" cardinality="one-to-one">
        LewProduct.instrumentId = this.instrumentId and
        LewProduct.processingDate = {com.gs.fw.common.mithra.util.DefaultInfinityTimestamp.getDefaultInfinity()}
    </Relationship>

    <Relationship name="scrpSynonymA" relatedObject="GlewScrp" cardinality="one-to-one">
        GlewScrp.name = this.debtClass
        and GlewScrp.viewId = 1005
        and this.productSynonym = "A"
    </Relationship>

    <Relationship name="scrpSynonymB" relatedObject="GlewScrp" cardinality="one-to-one">
        GlewScrp.name = this.debtClass
        and GlewScrp.viewId = 1005
        and this.productSynonym = "B"
    </Relationship>

    <Relationship name="scrpTypeEZ" relatedObject="GlewScrp" cardinality="one-to-one">
        GlewScrp.name = this.debtClass
        and GlewScrp.typeId in (1, 2)
        and this.productSynonym = "B"
    </Relationship>

</MithraObject>


text:
'use strict';

import GL from "gl-react";
import React, { Component }  from "react";

import {
    GPUImageFragShaderPredefineString,
    GPUImageFilter
} from '../GPUImageFilter';

const GPUImageSingleComponentGaussianBlurFragShaderString = GPUImageFragShaderPredefineString + `
uniform float u_gaussian_sigma;
uniform float u_texel_width;
uniform float u_texel_height;

/// Calculate the gaussian blur at given coords
float gaussBlur(vec2 coords) {
    int   windowSize      = 2;
    float gaussFilter[25];
    gaussFilter[0] = 2.0; gaussFilter[1] = 4.0;
    gaussFilter[2] = 5.0, gaussFilter[3] = 4.0;
    gaussFilter[4] = 2.0;
    gaussFilter[5] = 4.0; gaussFilter[6] = 9.0;
    gaussFilter[7] = 12.0, gaussFilter[8] = 9.0;
    gaussFilter[9] = 4.0;
    gaussFilter[10] = 5.0; gaussFilter[11] = 12.0;
    gaussFilter[12] = 15.0, gaussFilter[13] = 12.0;
    gaussFilter[14] = 5.0;
    gaussFilter[15] = 4.0; gaussFilter[16] = 9.0;
    gaussFilter[17] = 12.0, gaussFilter[18] = 9.0;
    gaussFilter[19] = 4.0;
    gaussFilter[20] = 2.0; gaussFilter[21] = 4.0;
    gaussFilter[22] = 5.0, gaussFilter[23] = 4.0;
    gaussFilter[24] = 2.0;

    int   offset = 0;
    float color = 0.0;
    vec4  auxColor = vec4(0.0);
    /// Loop through the window and calculate the convolution
    for (int y = -windowSize; y <= windowSize; y++) {
        for (int x = -windowSize; x <= windowSize; x++) {
            auxColor = texture2D(u_texture_0, coords + vec2(float(x) * u_texel_width, float(y) * u_texel_height));
            color += auxColor.r * gaussFilter[offset];
            offset += 1;
        }
    }

    return color;
}

void main() {
    float mid = gaussBlur(v_texCoord) * u_gaussian_sigma;
    gl_FragColor = vec4(mid, mid, mid, 1.0);
}
`;

export const GPUImageSingleComponentGaussianBlurFilter = GL.createComponent(
    ({children, texelWidth, texelHeight, sigma})=>{
        return (
            <GPUImageFilter
                frag={GPUImageSingleComponentGaussianBlurFragShaderString}
                uniforms={{
                    u_texel_width: texelWidth,
                    u_texel_height: texelHeight,
                    u_gaussian_sigma: sigma,
                }}>
                {children}
            </GPUImageFilter>
        );
    }
);


text:
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.2">
  <compounddef id="d1/d0c/sqlite3gen_8h" kind="file">
    <compoundname>sqlite3gen.h</compoundname>
    <includedby refid="dc/d98/doxygen_8cpp" local="yes">src/doxygen.cpp</includedby>
    <invincdepgraph>
      <node id="4783">
        src/doxygen.cpp
        <link refid="dc/d98/doxygen_8cpp_source"/>
      </node>
      <node id="4782">
        src/sqlite3gen.h
        <link refid="sqlite3gen.h"/>
        <childnode refid="4783" relation="include">
        </childnode>
      </node>
    </invincdepgraph>
      <sectiondef kind="func">
      <memberdef kind="function" id="d1/d0c/sqlite3gen_8h_1ae5b36a2f93dadba9f8c7d762564154e1" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
        <type>void</type>
        <definition>void generateSqlite3</definition>
        <argsstring>()</argsstring>
        <name>generateSqlite3</name>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Users/Mat/Projects/doxygraph/examples/doxygen-1.8.4/src/sqlite3gen.h" line="21" bodyfile="C:/Users/Mat/Projects/doxygraph/examples/doxygen-1.8.4/src/sqlite3gen.cpp" bodystart="1356" bodyend="1359"/>
      </memberdef>
      </sectiondef>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"><highlight class="comment"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="17"><highlight class="normal"></highlight></codeline>
<codeline lineno="18"><highlight class="normal"></highlight><highlight class="preprocessor">#ifndef<sp/>SQLITE3GEN_H</highlight></codeline>
<codeline lineno="19"><highlight class="preprocessor"></highlight><highlight class="preprocessor">#define<sp/>SQLITE3GEN_H</highlight></codeline>
<codeline lineno="20"><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="21"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>generateSqlite3();</highlight></codeline>
<codeline lineno="22"><highlight class="normal"></highlight></codeline>
<codeline lineno="23"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight></codeline>
    </programlisting>
    <location file="C:/Users/Mat/Projects/doxygraph/examples/doxygen-1.8.4/src/sqlite3gen.h"/>
  </compounddef>
</doxygen>


text:
from __future__ import absolute_import

import atexit
import logging
import time

try:
    from queue import Empty, Full, Queue  # pylint: disable=import-error
except ImportError:
    from Queue import Empty, Full, Queue  # pylint: disable=import-error
from collections import defaultdict

from threading import Thread, Event

import six

from kafka.structs import (
    ProduceRequestPayload, ProduceResponsePayload, TopicPartition, RetryOptions)
from kafka.errors import (
    kafka_errors, UnsupportedCodecError, FailedPayloadsError,
    RequestTimedOutError, AsyncProducerQueueFull, UnknownError,
    RETRY_ERROR_TYPES, RETRY_BACKOFF_ERROR_TYPES, RETRY_REFRESH_ERROR_TYPES)
from kafka.protocol import CODEC_NONE, ALL_CODECS, create_message_set

log = logging.getLogger('kafka.producer')

BATCH_SEND_DEFAULT_INTERVAL = 20
BATCH_SEND_MSG_COUNT = 20

# unlimited
ASYNC_QUEUE_MAXSIZE = 0
ASYNC_QUEUE_PUT_TIMEOUT = 0
# unlimited retries by default
ASYNC_RETRY_LIMIT = None
ASYNC_RETRY_BACKOFF_MS = 100
ASYNC_RETRY_ON_TIMEOUTS = True
ASYNC_LOG_MESSAGES_ON_ERROR = True

STOP_ASYNC_PRODUCER = -1
ASYNC_STOP_TIMEOUT_SECS = 30

SYNC_FAIL_ON_ERROR_DEFAULT = True

def _send_upstream(queue, client, codec, batch_time, batch_size,
                   req_acks, ack_timeout, retry_options, stop_event,
                   log_messages_on_error=ASYNC_LOG_MESSAGES_ON_ERROR,
                   stop_timeout=ASYNC_STOP_TIMEOUT_SECS,
                   codec_compresslevel=None):
    """Private method to manage producing messages asynchronously

    Listens on the queue for a specified number of messages or until
    a specified timeout and then sends messages to the brokers in grouped
    requests (one per broker).

    Messages placed on the queue should be tuples that conform to this format:
        ((topic, partition), message, key)

    Currently does not mark messages with task_done. Do not attempt to join()!

    Arguments:
        queue (threading.Queue): the queue from which to get messages
        client (kafka.SimpleClient): instance to use for communicating
            with brokers
        codec (kafka.protocol.ALL_CODECS): compression codec to use
        batch_time (int): interval in seconds to send message batches
        batch_size (int): count of messages that will trigger an immediate send
        req_acks: required acks to use with ProduceRequests. see server protocol
        ack_timeout: timeout to wait for required acks. see server protocol
        retry_options (RetryOptions): settings for retry limits, backoff etc
        stop_event (threading.Event): event to monitor for shutdown signal.
            when this event is 'set', the producer will stop sending messages.
        log_messages_on_error (bool, optional): log stringified message-contents
            on any produce error, otherwise only log a hash() of the contents,
            defaults to True.
        stop_timeout (int or float, optional): number of seconds to continue
            retrying messages after stop_event is set, defaults to 30.
    """
    request_tries = {}

    while not stop_event.is_set():
        try:
            client.reinit()
        except Exception as e:
            log.warn('Async producer failed to connect to brokers; backoff for %s(ms) before retrying', retry_options.backoff_ms)
            time.sleep(float(retry_options.backoff_ms) / 1000)
        else:
            break

    stop_at = None
    while not (stop_event.is_set() and queue.empty() and not request_tries):

        # Handle stop_timeout
        if stop_event.is_set():
            if not stop_at:
                stop_at = stop_timeout + time.time()
            if time.time() > stop_at:
                log.debug('Async producer stopping due to stop_timeout')
                break

        timeout = batch_time
        count = batch_size
        send_at = time.time() + timeout
        msgset = defaultdict(list)

        # Merging messages will require a bit more work to manage correctly
        # for now, dont look for new batches if we have old ones to retry
        if request_tries:
            count = 0
            log.debug('Skipping new batch collection to handle retries')
        else:
            log.debug('Batching size: %s, timeout: %s', count, timeout)

        # Keep fetching till we gather enough messages or a
        # timeout is reached
        while count > 0 and timeout >= 0:
            try:
                topic_partition, msg, key = queue.get(timeout=timeout)
            except Empty:
                break

            # Check if the controller has requested us to stop
            if topic_partition == STOP_ASYNC_PRODUCER:
                stop_event.set()
                break

            # Adjust the timeout to match the remaining period
            count -= 1
            timeout = send_at - time.time()
            msgset[topic_partition].append((msg, key))

        # Send collected requests upstream
        for topic_partition, msg in msgset.items():
            messages = create_message_set(msg, codec, key, codec_compresslevel)
            req = ProduceRequestPayload(
                topic_partition.topic,
                topic_partition.partition,
                tuple(messages))
            request_tries[req] = 0

        if not request_tries:
            continue

        reqs_to_retry, error_cls = [], None
        retry_state = {
            'do_backoff': False,
            'do_refresh': False
        }

        def _handle_error(error_cls, request):
            if issubclass(error_cls, RETRY_ERROR_TYPES) or (retry_options.retry_on_timeouts and issubclass(error_cls, RequestTimedOutError)):
                reqs_to_retry.append(request)
            if issubclass(error_cls, RETRY_BACKOFF_ERROR_TYPES):
                retry_state['do_backoff'] |= True
            if issubclass(error_cls, RETRY_REFRESH_ERROR_TYPES):
                retry_state['do_refresh'] |= True

        requests = list(request_tries.keys())
        log.debug('Sending: %s', requests)
        responses = client.send_produce_request(requests,
                                                acks=req_acks,
                                                timeout=ack_timeout,
                                                fail_on_error=False)

        log.debug('Received: %s', responses)
        for i, response in enumerate(responses):
            error_cls = None
            if isinstance(response, FailedPayloadsError):
                error_cls = response.__class__
                orig_req = response.payload

            elif isinstance(response, ProduceResponsePayload) and response.error:
                error_cls = kafka_errors.get(response.error, UnknownError)
                orig_req = requests[i]

            if error_cls:
                _handle_error(error_cls, orig_req)
                log.error('%s sending ProduceRequestPayload (#%d of %d) '
                          'to %s:%d with msgs %s',
                          error_cls.__name__, (i + 1), len(requests),
                          orig_req.topic, orig_req.partition,
                          orig_req.messages if log_messages_on_error
                                            else hash(orig_req.messages))

        if not reqs_to_retry:
            request_tries = {}
            continue

        # doing backoff before next retry
        if retry_state['do_backoff'] and retry_options.backoff_ms:
            log.warn('Async producer backoff for %s(ms) before retrying', retry_options.backoff_ms)
            time.sleep(float(retry_options.backoff_ms) / 1000)

        # refresh topic metadata before next retry
        if retry_state['do_refresh']:
            log.warn('Async producer forcing metadata refresh metadata before retrying')
            try:
                client.load_metadata_for_topics()
            except Exception:
                log.exception("Async producer couldn't reload topic metadata.")

        # Apply retry limit, dropping messages that are over
        request_tries = dict(
            (key, count + 1)
            for (key, count) in request_tries.items()
                if key in reqs_to_retry
                    and (retry_options.limit is None
                    or (count < retry_options.limit))
        )

        # Log messages we are going to retry
        for orig_req in request_tries.keys():
            log.info('Retrying ProduceRequestPayload to %s:%d with msgs %s',
                     orig_req.topic, orig_req.partition,
                     orig_req.messages if log_messages_on_error
                                       else hash(orig_req.messages))

    if request_tries or not queue.empty():
        log.error('Stopped producer with {0} unsent messages'
                  .format(len(request_tries) + queue.qsize()))

class Producer(object):
    """
    Base class to be used by producers

    Arguments:
        client (kafka.SimpleClient): instance to use for broker
            communications. If async=True, the background thread will use
            client.copy(), which is expected to return a thread-safe object.
        codec (kafka.protocol.ALL_CODECS): compression codec to use.
        req_acks (int, optional): A value indicating the acknowledgements that
            the server must receive before responding to the request,
            defaults to 1 (local ack).
        ack_timeout (int, optional): millisecond timeout to wait for the
            configured req_acks, defaults to 1000.
        sync_fail_on_error (bool, optional): whether sync producer should
            raise exceptions (True), or just return errors (False),
            defaults to True.
        async (bool, optional): send message using a background thread,
            defaults to False.
        batch_send_every_n (int, optional): If async is True, messages are
            sent in batches of this size, defaults to 20.
        batch_send_every_t (int or float, optional): If async is True,
            messages are sent immediately after this timeout in seconds, even
            if there are fewer than batch_send_every_n, defaults to 20.
        async_retry_limit (int, optional): number of retries for failed messages
            or None for unlimited, defaults to None / unlimited.
        async_retry_backoff_ms (int, optional): milliseconds to backoff on
            failed messages, defaults to 100.
        async_retry_on_timeouts (bool, optional): whether to retry on
            RequestTimedOutError, defaults to True.
        async_queue_maxsize (int, optional): limit to the size of the
            internal message queue in number of messages (not size), defaults
            to 0 (no limit).
        async_queue_put_timeout (int or float, optional): timeout seconds
            for queue.put in send_messages for async producers -- will only
            apply if async_queue_maxsize > 0 and the queue is Full,
            defaults to 0 (fail immediately on full queue).
        async_log_messages_on_error (bool, optional): set to False and the
            async producer will only log hash() contents on failed produce
            requests, defaults to True (log full messages). Hash logging
            will not allow you to identify the specific message that failed,
            but it will allow you to match failures with retries.
        async_stop_timeout (int or float, optional): seconds to continue
            attempting to send queued messages after producer.stop(),
            defaults to 30.

    Deprecated Arguments:
        batch_send (bool, optional): If True, messages are sent by a background
            thread in batches, defaults to False. Deprecated, use 'async'
    """
    ACK_NOT_REQUIRED = 0            # No ack is required
    ACK_AFTER_LOCAL_WRITE = 1       # Send response after it is written to log
    ACK_AFTER_CLUSTER_COMMIT = -1   # Send response after data is committed
    DEFAULT_ACK_TIMEOUT = 1000

    def __init__(self, client,
                 req_acks=ACK_AFTER_LOCAL_WRITE,
                 ack_timeout=DEFAULT_ACK_TIMEOUT,
                 codec=None,
                 codec_compresslevel=None,
                 sync_fail_on_error=SYNC_FAIL_ON_ERROR_DEFAULT,
                 async=False,
                 batch_send=False, # deprecated, use async
                 batch_send_every_n=BATCH_SEND_MSG_COUNT,
                 batch_send_every_t=BATCH_SEND_DEFAULT_INTERVAL,
                 async_retry_limit=ASYNC_RETRY_LIMIT,
                 async_retry_backoff_ms=ASYNC_RETRY_BACKOFF_MS,
                 async_retry_on_timeouts=ASYNC_RETRY_ON_TIMEOUTS,
                 async_queue_maxsize=ASYNC_QUEUE_MAXSIZE,
                 async_queue_put_timeout=ASYNC_QUEUE_PUT_TIMEOUT,
                 async_log_messages_on_error=ASYNC_LOG_MESSAGES_ON_ERROR,
                 async_stop_timeout=ASYNC_STOP_TIMEOUT_SECS):

        if async:
            assert batch_send_every_n > 0
            assert batch_send_every_t > 0
            assert async_queue_maxsize >= 0

        self.client = client
        self.async = async
        self.req_acks = req_acks
        self.ack_timeout = ack_timeout
        self.stopped = False

        if codec is None:
            codec = CODEC_NONE
        elif codec not in ALL_CODECS:
            raise UnsupportedCodecError("Codec 0x%02x unsupported" % codec)

        self.codec = codec
        self.codec_compresslevel = codec_compresslevel

        if self.async:
            # Messages are sent through this queue
            self.queue = Queue(async_queue_maxsize)
            self.async_queue_put_timeout = async_queue_put_timeout
            async_retry_options = RetryOptions(
                limit=async_retry_limit,
                backoff_ms=async_retry_backoff_ms,
                retry_on_timeouts=async_retry_on_timeouts)
            self.thread_stop_event = Event()
            self.thread = Thread(
                target=_send_upstream,
                args=(self.queue, self.client.copy(), self.codec,
                      batch_send_every_t, batch_send_every_n,
                      self.req_acks, self.ack_timeout,
                      async_retry_options, self.thread_stop_event),
                kwargs={'log_messages_on_error': async_log_messages_on_error,
                        'stop_timeout': async_stop_timeout,
                        'codec_compresslevel': self.codec_compresslevel}
            )

            # Thread will die if main thread exits
            self.thread.daemon = True
            self.thread.start()

            def cleanup(obj):
                if not obj.stopped:
                    obj.stop()
            self._cleanup_func = cleanup
            atexit.register(cleanup, self)
        else:
            self.sync_fail_on_error = sync_fail_on_error

    def send_messages(self, topic, partition, *msg):
        """Helper method to send produce requests.

        Note that msg type *must* be encoded to bytes by user. Passing unicode
        message will not work, for example you should encode before calling
        send_messages via something like `unicode_message.encode('utf-8')`
        All messages will set the message 'key' to None.

        Arguments:
            topic (str): name of topic for produce request
            partition (int): partition number for produce request
            *msg (bytes): one or more message payloads

        Returns:
            ResponseRequest returned by server

        Raises:
            FailedPayloadsError: low-level connection error, can be caused by
                networking failures, or a malformed request.
            ConnectionError:
            KafkaUnavailableError: all known brokers are down when attempting
                to refresh metadata.
            LeaderNotAvailableError: topic or partition is initializing or
                a broker failed and leadership election is in progress.
            NotLeaderForPartitionError: metadata is out of sync; the broker
                that the request was sent to is not the leader for the topic
                or partition.
            UnknownTopicOrPartitionError: the topic or partition has not
                been created yet and auto-creation is not available.
            AsyncProducerQueueFull: in async mode, if too many messages are
                unsent and remain in the internal queue.
        """
        return self._send_messages(topic, partition, *msg)

    def _send_messages(self, topic, partition, *msg, **kwargs):
        key = kwargs.pop('key', None)

        # Guarantee that msg is actually a list or tuple (should always be true)
        if not isinstance(msg, (list, tuple)):
            raise TypeError("msg is not a list or tuple!")

        for m in msg:
            # The protocol allows to have key & payload with null values both,
            # (https://goo.gl/o694yN) but having (null,null) pair doesn't make sense.
            if m is None:
                if key is None:
                    raise TypeError("key and payload can't be null in one")
            # Raise TypeError if any non-null message is not encoded as bytes
            elif not isinstance(m, six.binary_type):
                raise TypeError("all produce message payloads must be null or type bytes")

        # Raise TypeError if the key is not encoded as bytes
        if key is not None and not isinstance(key, six.binary_type):
            raise TypeError("the key must be type bytes")

        if self.async:
            for idx, m in enumerate(msg):
                try:
                    item = (TopicPartition(topic, partition), m, key)
                    if self.async_queue_put_timeout == 0:
                        self.queue.put_nowait(item)
                    else:
                        self.queue.put(item, True, self.async_queue_put_timeout)
                except Full:
                    raise AsyncProducerQueueFull(
                        msg[idx:],
                        'Producer async queue overfilled. '
                        'Current queue size %d.' % self.queue.qsize())
            resp = []
        else:
            messages = create_message_set([(m, key) for m in msg], self.codec, key, self.codec_compresslevel)
            req = ProduceRequestPayload(topic, partition, messages)
            try:
                resp = self.client.send_produce_request(
                    [req], acks=self.req_acks, timeout=self.ack_timeout,
                    fail_on_error=self.sync_fail_on_error
                )
            except Exception:
                log.exception("Unable to send messages")
                raise
        return resp

    def stop(self, timeout=None):
        """
        Stop the producer (async mode). Blocks until async thread completes.
        """
        if timeout is not None:
            log.warning('timeout argument to stop() is deprecated - '
                        'it will be removed in future release')

        if not self.async:
            log.warning('producer.stop() called, but producer is not async')
            return

        if self.stopped:
            log.warning('producer.stop() called, but producer is already stopped')
            return

        if self.async:
            self.queue.put((STOP_ASYNC_PRODUCER, None, None))
            self.thread_stop_event.set()
            self.thread.join()

        if hasattr(self, '_cleanup_func'):
            # Remove cleanup handler now that we've stopped

            # py3 supports unregistering
            if hasattr(atexit, 'unregister'):
                atexit.unregister(self._cleanup_func) # pylint: disable=no-member

            # py2 requires removing from private attribute...
            else:

                # ValueError on list.remove() if the exithandler no longer exists
                # but that is fine here
                try:
                    atexit._exithandlers.remove(  # pylint: disable=no-member
                        (self._cleanup_func, (self,), {}))
                except ValueError:
                    pass

            del self._cleanup_func

        self.stopped = True

    def __del__(self):
        if self.async and not self.stopped:
            self.stop()