text:
"""Tests for CollectiveAllReduceStrategy."""

from absl.testing import parameterized

from tensorflow.python.compat import v2_compat
from tensorflow.python.data.ops import dataset_ops
from tensorflow.python.distribute import combinations as ds_combinations
from tensorflow.python.distribute import multi_process_runner
from tensorflow.python.distribute import strategy_combinations
from tensorflow.python.eager import test
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import test_combinations as combinations
from tensorflow.python.keras import layers
from tensorflow.python.keras.engine import training
from tensorflow.python.keras.optimizer_v2 import gradient_descent as gradient_descent_keras
from tensorflow.python.ops import array_ops

@ds_combinations.generate(
    combinations.combine(
        strategy=[
            strategy_combinations.multi_worker_mirrored_2x1_cpu,
            strategy_combinations.multi_worker_mirrored_2x1_gpu,
        ],
        mode=['eager']))
class MultiWorkerMirroredStrategyTest(test.TestCase, parameterized.TestCase):

  def testFitWithoutStepsPerEpochPartialBatch(self, strategy):

    def _model_fn():
      x = layers.Input(shape=(1,), name='input')
      y = layers.Dense(1, name='dense')(x)
      model = training.Model(x, y)
      return model

    def _get_dataset():
      inputs = array_ops.expand_dims_v2(
          constant_op.constant(range(10)), axis=1)
      targets = array_ops.expand_dims_v2(
          constant_op.constant(range(10)), axis=1)
      # Make global batch size 12 for 2 replicas and a non-repeated dataset
      # with 10 elements so that we have partial batch
      dataset = dataset_ops.Dataset.from_tensor_slices(
          (inputs, targets)).batch(
              12, drop_remainder=False)
      return dataset

    with strategy.scope():
      optimizer_fn = gradient_descent_keras.SGD
      optimizer = optimizer_fn(0.001)
      model = _model_fn()
      loss = 'mse'
      metrics = ['mae']
      model.compile(optimizer, loss, metrics=metrics)
    dataset = _get_dataset()
    kernel_before = model.get_weights()[0][0]
    model.fit(dataset, epochs=10)
    kernel_after = model.get_weights()[0][0]
    self.assertNotEqual(kernel_before, kernel_after)
    self.assertGreater(abs(kernel_before - 1), abs(kernel_after - 1))

if __name__ == '__main__':
  v2_compat.enable_v2_behavior()
  multi_process_runner.test_main()


text:
<?php

namespace rocketfirm\engine\modules\menu\models;

use rocketfirm\engine\LanguageActiveRecord;
use rocketfirm\engine\traits\NestedSetTree;
use rocketfirm\engine\modules\languages\models\Languages;
use creocoder\behaviors\NestedSet;
use creocoder\nestedsets\NestedSetsBehavior;
use Yii;
use yii\base\InvalidConfigException;
use yii\base\InvalidParamException;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\db\Expression;
use yii\helpers\ArrayHelper;
use yii\helpers\Json;
use yii\helpers\StringHelper;
use yii\helpers\Url;

/**
 * This is the model class for table "menu_items".
 *
 * @property integer $id
 * @property integer $menu_id
 * @property integer $lang_id
 * @property string $title
 * @property string $type
 * @property string $link
 * @property string $params
 * @property integer $is_new_window
 * @property integer $is_active
 * @property string $create_date
 * @property string $update_date
 *
 * @property Languages $lang
 * @property Menus $menu
 */
class MenuItems extends LanguageActiveRecord
{
    use NestedSetTree;
    const TYPE_MODULE = 0;
    const TYPE_LINK = 1;

    static $types = [
        self::TYPE_MODULE => 'Внутренняя ссылка',
        self::TYPE_LINK => 'Внешняя ссылка'
    ];

    public static function find()
    {
        $query = new MenuItemsQuery(get_called_class());

        if (Yii::$app->params['yiiEnd'] == 'admin') {
            return $query->setLanguage();
        }

        return $query;
    }

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'menu_items';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['menu_id', 'lang_id', 'title', 'link'], 'required'],
            [['parent_id', 'menu_id', 'lang_id', 'is_new_window', 'is_active'], 'integer'],
            [['title', 'type', 'link', 'params'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('menu', 'ID'),
            'menu_id' => Yii::t('menu', 'Меню'),
            'lang_id' => Yii::t('menu', 'Язык'),
            'parent_id' => Yii::t('menu', 'Родитель'),
            'title' => Yii::t('menu', 'Наименование'),
            'type' => Yii::t('menu', 'Тип'),
            'link' => Yii::t('menu', 'Ссылка'),
            'params' => Yii::t('menu', 'Параметры для внутренней ссылки, формат JSON'),
            'is_new_window' => Yii::t('menu', 'Открывать в новом окне'),
            'is_active' => Yii::t('menu', 'Активность'),
            'create_date' => Yii::t('menu', 'Дата создания'),
            'update_date' => Yii::t('menu', 'Дата изменения'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getLang()
    {
        return $this->hasOne(Languages::className(), ['id' => 'lang_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getMenu()
    {
        return $this->hasOne(Menus::className(), ['id' => 'menu_id']);
    }

    public function getUrl()
    {
        if ($this->type == self::TYPE_MODULE) {
            try {
                $params = Json::decode($this->checkJsonParams($this->params));
            } catch (InvalidParamException $e) {
                $params = null;
            }

            if ($params !== null) {
                $url = ArrayHelper::merge(['/' . $this->link], $params);
            } else {
                $url = ['/' . $this->link];
            }

            return $url;
        }

        return $this->link;
    }

    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ['create_date', 'update_date'],
                    ActiveRecord::EVENT_BEFORE_UPDATE => ['update_date']
                ],
                'value' => new Expression('NOW()'),
            ],
            [
                'class' => NestedSetsBehavior::className(),
                'depthAttribute' => 'level',
                'treeAttribute' => 'root'
            ],
        ];
    }

    public function checkJsonParams()
    {
        return StringHelper::mb_str_replace("'", '"', $this->params);
    }

    public static function getMenuItemTypes()
    {
        if (!empty(Yii::$app->params['menu']['types']) && !is_array(Yii::$app->params['menu']['types'])) {
            throw new InvalidConfigException('В конфигурационном файле нет настроек меню. params.menus.types[]');
        }

        $menuParams = Yii::$app->params['menu']['types'];

        $types = [];
        foreach ($menuParams as $type => $typeParams) {
            $types[$type] = $typeParams['name'];
        }

        return $types;
    }

    public static function getMenuTypeParams($type)
    {
        if (!empty(Yii::$app->params['menu']['types'][$type]) && !is_array(Yii::$app->params['menu']['types'][$type])) {
            throw new InvalidConfigException('В конфигурационном файле нет настроек меню. params.menus.types' . $type . '[]');
        }

        return Yii::$app->params['menu']['types'][$type];
    }

}

redpajama_set_name: RedPajamaGithub


text:
'use strict';

import suman from 'suman';
const {Test} = suman.init(module);

///////////////////////////////////////////////////////////////////////

1..times(function () {

  Test.create(function (assert, describe, before, beforeEach, after, afterEach, it, $core, $deps) {

    describe('test $core', (b, test) => {

      test('test $deps', t => {
        const {child_process, http} = $core;
        const cp = require('child_process');
        const $http = require('http');

        t.assert.equal(child_process, cp);
        t.assert.equal(http, $http);

      });

    });

    describe('test $deps', (b, test) => {

      test('test $deps', t => {
        const {child_process, http} = $deps;
        const cp = require('child_process');
        const $http = require('http');

        t.assert.equal(child_process, cp);
        t.assert.equal(http, $http);

      });

    });

    describe('test lodash to dash', (b, test) => {

      test('test $deps', t => {
        const {tcp_ping} = $deps;  // tcp_ping will load require('tcp-ping')

        t.assert(tcp_ping);

      });

    });

  });

  Test.create(function (assert, describe, before, beforeEach, after, afterEach, it, $core, $deps) {

    describe('test $core', (b, test) => {

      test('test $deps', t => {
        const {child_process, http} = $core;
        const cp = require('child_process');
        const $http = require('http');

        t.assert.equal(child_process, cp);
        t.assert.equal(http, $http);

      });

    });

    describe('test $deps', (b, test) => {

      test('test $deps', t => {
        const {child_process, http} = $deps;
        const cp = require('child_process');
        const $http = require('http');

        t.assert.equal(child_process, cp);
        t.assert.equal(http, $http);

      });

    });

    describe('test lodash to dash', (b, test) => {

      test('test $deps', t => {
        const {tcp_ping} = $deps;  // tcp_ping will load require('tcp-ping')

        t.assert(tcp_ping);

      });

    });

  });

});


text:
namespace XivDB {
    public class Exp {
        public int current { get; set; }
        public int max { get; set; }
        public bool at_cap { get; set; }
        public int total_gained { get; set; }
        public int total_max { get; set; }
        public int total_togo { get; set; }
        public double percent { get; set; }
        public float total_percent { get; set; }
    }
}


text:
<?php

namespace Craffft\ContaoOAuth2Bundle\DependencyInjection;

use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

/**
 * This is the class that loads and manages your bundle configuration
 *
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
 */
class CraffftContaoOAuth2Extension extends Extension
{
    /**
     * {@inheritdoc}
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('services.yml');

        $container->setParameter('craffft_contao_oauth2.extend_member', $config['extend_member']);
        $container->setParameter('craffft_contao_oauth2.member_entity', $config['member_entity']);
        $container->setParameter('craffft_contao_oauth2.member_repository', $config['member_repository']);
    }

    /**
     * Returns the recommended alias to use in XML.
     *
     * This alias is also the mandatory prefix to use when using YAML.
     *
     * @return string The alias
     */
    public function getAlias()
    {
        return 'craffft_contao_oauth2';
    }
}


text:
from __future__ import absolute_import, division, print_function

from itertools import chain

class SymbolTreeNode(object):
  """A simple prefix tree with some custom logic for working with JVM symbols.

  Also used with Python symbols.
  """

  def __init__(self, children=None, values=None):
    self.children = children or {}
    self.values = values or set()

  def _insert(self, symbol_list, value):
    if not symbol_list:
      self.values.add(value)
    else:
      head, rest = symbol_list[0], symbol_list[1:]
      if head not in self.children:
        self.children[head] = SymbolTreeNode()
      child_node = self.children[head]
      child_node._insert(rest, value)

  def insert(self, symbol, value):
    """Insert value into the tree at symbol.

    :param string symbol: This symbol will be split on '.' to create nodes in the prefix tree.
    :param string value: This value (generally a source path) will be inserted into the set of
      values provided at the node produced by `symbol`.
    """
    return self._insert(symbol.split('.'), value)

  def flattened_subtree(self):
    """Returns the set of all values provided by this node and all of its descendents."""
    return set(chain(self.values,
                     *[child.flattened_subtree() for child in self.children.values()]))

  def _get(self, symbol_list, allow_prefix_imports, exact):
    if not symbol_list:
      if not self.values and allow_prefix_imports:
        return self.flattened_subtree()
      else:
        return set(self.values)
    elif symbol_list == ['_']:
      return self.flattened_subtree()
    else:
      head, rest = symbol_list[0], symbol_list[1:]
      if head in self.children:
        return self.children[head]._get(rest, allow_prefix_imports, exact)
      elif exact:
        return set()
      else:
        return set(self.values)

  def get(self, symbol, allow_prefix_imports=False, exact=False):
    """Returns the values at the node inferred from `symbol`.

    :param string symbol: This symbol will be split on '.' to traverse nodes in the prefix tree.
    :param bool allow_prefix_imports: If the symbol refers to a node which does not have any
      values associated with it (it's internal, and therefore has children), instead of returning
      nothing, return all of the values provided by its children (flattened_subtree).
    :param bool exact: Only return the values at a node if it is an exact match for the symbol.
      If a prefix node has values but does not have children to match the rest of the symbol,
      it will return an empty set.  Note that `allow_prefix_imports` and `exact` are mutually
      exclusive, and passing them both will cause an exception to be raised.
    """
    if allow_prefix_imports and exact:
      raise ValueError('Cannot call SymbolTreeNode.get() with both allow_prefix_imports=True and'
                       ' exact=True.  Symbole was: {0}'.format(symbol))
    return self._get(
      symbol.split('.'),
      allow_prefix_imports=allow_prefix_imports,
      exact=exact,
    )

  def render(self, nindent=0, indent='  ', lines=None):
    "Recursively render the tree. Top call returns a string."
    top = lines is None
    lines = lines or []
    for val in self.values:
      lines.append((nindent * indent, val))
    for k, v in self.children.items():
      lines.append((nindent * indent, k))
      v.render(nindent + 1, indent, lines)
    if top:
      return '\n'.join(map(' '.join, lines))


text:
package reseau;

import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

import reseau.serveur.Serveur;

public class InOutReseau extends InOutCodeID {
    private final Socket socket;

    public InOutReseau() throws UnknownHostException, IOException {
	this(InetAddress.getLocalHost());
    }

    public InOutReseau(InetAddress adresse) throws UnknownHostException, IOException {
	this(adresse, Serveur.DEFAULT_PORT);
    }

    public InOutReseau(InetAddress adresse, int port) throws IOException {
	this(new Socket(adresse, port));
    }

    public InOutReseau(Socket socket) throws IOException {
	this.socket = socket;
	setOut(socket.getOutputStream());
	setIn(socket.getInputStream());
    }

    public InetAddress getAdresse() {
	return socket.getInetAddress();
    }

    public Socket getSocket() {
	return socket;
    }

    public int getPort() {
	return socket.getPort();
    }

    @Override
    public boolean fermer() {
	if(super.fermer()) try {
	    socket.close();
	    return true;
	} catch (IOException e) {
	    e.printStackTrace();
	}
	return false;
    }

}


text:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/stand_bg"
    android:orientation="vertical">

    <EditText
        android:id="@+id/edit"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_margin="10dp"
        android:layout_weight="1"
        android:background="@color/transparent"
        android:gravity="start"
        android:minHeight="600dp" />

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

</LinearLayout>


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
in Whalley, Laessøe & Kile, Mycol. Res. 94(2): 239 (1990)

#### Original name
Hypoxylon grenadense J.H. Mill., 1961

### Remarks
null


text:
package com.karasiq.shadowcloud.storage.yandex

import com.karasiq.shadowcloud.config.ConfigProps
import com.karasiq.shadowcloud.providers.StorageProvider

class YandexStorageProvider extends StorageProvider {
  override def storageTypes: Set[String] = Set("yandex")

  override def storages: StoragePF = {
    case props if props.storageType == "yandex" =>
      new YandexStoragePlugin
  }

  override def storageConfigs: StorageConfigPF = {
    case "yandex" => ConfigProps(
      "type" -> "yandex",
      "credentials.login" -> "johndoe123",
      "credentials.password" -> "passw0rd"
    )
  }
}


text:
package com.ajeetkg.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * Created by agupta2 on 3/8/16.
 */

@Configuration
@EnableCaching
@PropertySource("classpath:/redis.properties")
public class RedisConfig extends CachingConfigurerSupport{

    @Value("${redis.hostname}")
    String hostname;

    @Value("${redis.port}")
    int port;

    @Bean
    public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(){
        return new PropertySourcesPlaceholderConfigurer();
    }

    @Bean
    public JedisConnectionFactory jedisConnectionFactory(){
        JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
        jedisConnectionFactory.setHostName(hostname);
        jedisConnectionFactory.setPort(port);
        jedisConnectionFactory.setUsePool(true);
        return jedisConnectionFactory;

    }

    @Bean
    public RedisTemplate<Object, Object> redisTemplate(){
        RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
        redisTemplate.setConnectionFactory(jedisConnectionFactory());
        return redisTemplate;
    }

    @Bean
    public CacheManager cacheManager(){
        RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate());
        cacheManager.setDefaultExpiration(300);
        return cacheManager;
    }

}


text:
import subprocess
from subprocess import Popen, PIPE

#If you just want to run something and do not care about the output, use this
print 'Use check_call if you just want to run something'
print 'Nothing will ever be displayed'
print '-' * 10
subprocess.check_call(["rm", "-rf", "/tmp/out"])

#If you want to do something with the output of a shell command use this
print 'Use check_output to display output'
output= subprocess.check_output(["ls", "-la", "/tmp"])
print output
print '-' * 10

#Pipe output of one command to another
print 'Trying to pipe output of one command to another'
try:
    #Command 1
    ps = subprocess.Popen(('ps', '-A'), stdout=subprocess.PIPE)

    #Pipe to Command 2
    output = subprocess.check_output(('grep', 'init'), stdin=ps.stdout)
    ps.communicate()
    print output
except subprocess.CalledProcessError:
    print 'No such process found'
print '-' * 10

#http://sam.nipl.net/code/python/pipeline.py
print 'Sending a string as input to another process. Result in output file'
input   = "test string"

#Result stored here eventually
outfile = file('outfile.txt','w')

#Last command
p2 = Popen(['sort'],                  stdin=PIPE, stdout=outfile)

#Middle command. Build this first
p1 = Popen(['sed', 's/$/ hi there/'], stdin=PIPE, stdout=p2.stdin)

#This is done to tell the sort command, that it will receive no more input from sed
p2.stdin.close()

#Strings you are passing to the middle command. This is what you'd type first at a shell prompt.
p1.communicate(input)


text:
var assert = require('assert');

var permutations = require('../lib/permutations');

describe("permutations", function () {
    it('should return similar array when 0 or 1 elements', function () {
	assert.deepEqual([ ], permutations([ ]) );
	assert.deepEqual([[1]], permutations([1]) );
    });
    it('should return all permutations of arrays with more than 1 elements', function () {
	assert.deepEqual([[2,1],[1,2]], permutations([1,2]));
	assert.deepEqual([[2,3,1],[3,2,1],[3,1,2],[1,3,2], [2,1,3], [1,2,3]],
			 permutations([1,2,3]));
    });
});


text:
<!DOCTYPE html>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  <meta name="description" content="Javadoc API documentation for Fresco 1.1.0." />

<link rel="shortcut icon" type="image/x-icon" href="../../../../favicon.ico" />
<title>

  StatFsHelper - Fresco 1.1.0 API

| Fresco 1.1.0

</title>
<link href="../../../../../assets/doclava-developer-docs.css" rel="stylesheet" type="text/css" />
<link href="../../../../../assets/customizations.css" rel="stylesheet" type="text/css" />

      Fresco 1.1.0

          <form accept-charset="utf-8" class="gsc-search-box"
                onsubmit="return submit_search()">

                    <input id="search_autocomplete" class="gsc-input" type="text" size="33" autocomplete="off"
                      title="search developer docs" name="q"
                      value="search developer docs"
                      onFocus="search_focus_changed(this, true)"
                      onBlur="search_focus_changed(this, false)"
                      onkeydown="return search_changed(event, true, '../../../../')"
                      onkeyup="return search_changed(event, false, '../../../../')" />

          </form>

                Packages |
                Classes

  com.facebook.animated.gif

  com.facebook.animated.webp

  com.facebook.binaryresource

  com.facebook.cache.common

  com.facebook.cache.disk

  com.facebook.common.activitylistener

  com.facebook.common.disk

  com.facebook.common.executors

  com.facebook.common.file

  com.facebook.common.internal

  com.facebook.common.lifecycle

  com.facebook.common.logging

  com.facebook.common.media

  com.facebook.common.memory

  com.facebook.common.references

  com.facebook.common.soloader

  com.facebook.common.statfs

  com.facebook.common.streams

  com.facebook.common.time

  com.facebook.common.util

  com.facebook.common.webp

  com.facebook.datasource

  com.facebook.drawable.base

  com.facebook.drawee.backends.pipeline

  com.facebook.drawee.backends.volley

  com.facebook.drawee.components

  com.facebook.drawee.controller

  com.facebook.drawee.debug

  com.facebook.drawee.drawable

  com.facebook.drawee.generic

  com.facebook.drawee.gestures

  com.facebook.drawee.interfaces

  com.facebook.drawee.span

  com.facebook.drawee.view

  com.facebook.fresco.animation.backend

  com.facebook.fresco.animation.bitmap

  com.facebook.fresco.animation.bitmap.cache

  com.facebook.fresco.animation.bitmap.wrapper

  com.facebook.fresco.animation.drawable

  com.facebook.fresco.animation.drawable.animator

  com.facebook.fresco.animation.factory

  com.facebook.fresco.animation.frame

  com.facebook.fresco.animation.wrapper

  com.facebook.imageformat

  com.facebook.imagepipeline.animated.base

  com.facebook.imagepipeline.animated.factory

  com.facebook.imagepipeline.animated.impl

  com.facebook.imagepipeline.animated.util

  com.facebook.imagepipeline.backends.okhttp3

  com.facebook.imagepipeline.backends.volley

  com.facebook.imagepipeline.bitmaps

  com.facebook.imagepipeline.cache

  com.facebook.imagepipeline.common

  com.facebook.imagepipeline.core

  com.facebook.imagepipeline.datasource

  com.facebook.imagepipeline.decoder

  com.facebook.imagepipeline.image

  com.facebook.imagepipeline.listener

  com.facebook.imagepipeline.memory

  com.facebook.imagepipeline.nativecode

  com.facebook.imagepipeline.platform

  com.facebook.imagepipeline.postprocessors

  com.facebook.imagepipeline.producers

  com.facebook.imagepipeline.request

  com.facebook.imageutils

  com.facebook.webpsupport

  com.facebook.widget.text.span

Classes

StatFsHelper

Enums

StatFsHelper.StorageType

            Packages |
            Classes

Summary:

  Nested Classes

  | Protected Ctors

  | Methods

  | Protected Methods

  | Inherited Methods

| [Expand All]

    public

    class

StatFsHelper

    extends Object

        java.lang.Object

               ↳

        com.facebook.common.statfs.StatFsHelper

Class Overview

Helper class that periodically checks the amount of free space available.

To keep the overhead low, it caches the free space information, and
 only updates that info after two minutes.

It is a singleton, and is thread-safe.

Initialization is delayed until first use, so the first call to any method may incur some
 additional cost.

Summary

Nested Classes

        enum
      StatFsHelper.StorageType

Protected Constructors

        StatFsHelper()

Constructor.

Public Methods

            long

        getAvailableStorageSpace(StatFsHelper.StorageType storageType)

Gets the information about the available storage space
 either internal or external depends on the give input

            long

        getFreeStorageSpace(StatFsHelper.StorageType storageType)

Gets the information about the free storage space, including reserved blocks,
 either internal or external depends on the given input

            synchronized

            static

            StatFsHelper

        getInstance()

            long

        getTotalStorageSpace(StatFsHelper.StorageType storageType)

Gets the information about the total storage space,
 either internal or external depends on the given input

            void

        resetStats()

Thread-safe call to reset the disk stats.

            boolean

        testLowDiskSpace(StatFsHelper.StorageType storageType, long freeSpaceThreshold)

Check if available space in the filesystem is greater than the given threshold.

Protected Methods

            static

            StatFs

        createStatFs(String path)

  [Expand]

Inherited Methods

From class

  java.lang.Object

            Object

        clone()

            boolean

        equals(Object arg0)

            void

        finalize()

            final

            Class<?>

        getClass()

            int

        hashCode()

            final

            void

        notify()

            final

            void

        notifyAll()

            String

        toString()

            final

            void

        wait(long arg0, int arg1)

            final

            void

        wait(long arg0)

            final

            void

        wait()

Protected Constructors

        protected

      StatFsHelper
      ()

Constructor.

Initialization is delayed until first use, so we must call #ensureInitialized()
 when implementing member methods.

Public Methods

        public

        long

      getAvailableStorageSpace
      (StatFsHelper.StorageType storageType)

Gets the information about the available storage space
 either internal or external depends on the give input

Parameters

          storageType
          Internal or external storage type

Returns

available space in bytes, 0 if no information is available

        public

        long

      getFreeStorageSpace
      (StatFsHelper.StorageType storageType)

Gets the information about the free storage space, including reserved blocks,
 either internal or external depends on the given input

Parameters

          storageType
          Internal or external storage type

Returns

available space in bytes, -1 if no information is available

        public
        static

        synchronized
        StatFsHelper

      getInstance
      ()

        public

        long

      getTotalStorageSpace
      (StatFsHelper.StorageType storageType)

Gets the information about the total storage space,
 either internal or external depends on the given input

Parameters

          storageType
          Internal or external storage type

Returns

available space in bytes, -1 if no information is available

        public

        void

      resetStats
      ()

Thread-safe call to reset the disk stats.
 If we know that the free space has changed recently (for example, if we have
 deleted files), use this method to reset the internal state and
 start tracking disk stats afresh, resetting the internal timer for updating stats.

        public

        boolean

      testLowDiskSpace
      (StatFsHelper.StorageType storageType, long freeSpaceThreshold)

Check if available space in the filesystem is greater than the given threshold.
 Note that the free space stats are cached and updated in intervals of RESTAT_INTERVAL_MS.
 If the amount of free space has crossed over the threshold since the last update, it will
 return incorrect results till the space stats are updated again.

Parameters

          storageType
          StorageType (internal or external) to test

          freeSpaceThreshold
          compare the available free space to this size

Returns

whether free space is lower than the input freeSpaceThreshold,
 returns true if disk information is not available

Protected Methods

        protected
        static

        StatFs

      createStatFs
      (String path)

 +Generated by Doclava.
 +


text:
    Add New Flow

Search

List

<app-flow-search  *ngIf="openedTab == 'search'"></app-flow-search>

            <app-flow-list *ngIf="openedTab == 'list' && loadFlows"  [srcSwitch]="src" [dstSwitch]="dst" ></app-flow-list>


text:
package org.andengine.util.call;

/**
 * (c) 2010 Nicolas Gramlich
 * (c) 2011 Zynga Inc.
 *
 * @author Nicolas Gramlich
 * @since 20:52:44 - 03.01.2010
 */
public interface Callable<T> {
	// ===========================================================
	// Constants
	// ===========================================================

	// ===========================================================
	// Methods
	// ===========================================================

	/**
	 * Computes a result, or throws an exception if unable to do so.
	 *
	 * @return the computed result.
	 * @throws Exception if unable to compute a result.
	 */
	public T call() throws Exception;
}


text:
package org.apache.tez.mapreduce.examples;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;

import org.apache.commons.cli.ParseException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.FileAlreadyExistsException;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.mapreduce.security.TokenCache;
import org.apache.hadoop.security.Credentials;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.GenericOptionsParser;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
import org.apache.hadoop.yarn.api.records.LocalResource;
import org.apache.tez.client.TezClientUtils;
import org.apache.tez.client.TezClient;
import org.apache.tez.common.TezUtils;
import org.apache.tez.common.security.DAGAccessControls;
import org.apache.tez.dag.api.DAG;
import org.apache.tez.dag.api.DataSourceDescriptor;
import org.apache.tez.dag.api.Edge;
import org.apache.tez.dag.api.PreWarmVertex;
import org.apache.tez.dag.api.ProcessorDescriptor;
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.TezException;
import org.apache.tez.dag.api.UserPayload;
import org.apache.tez.dag.api.Vertex;
import org.apache.tez.dag.api.client.DAGClient;
import org.apache.tez.dag.api.client.DAGStatus;
import org.apache.tez.dag.api.client.StatusGetOpts;
import org.apache.tez.mapreduce.examples.helpers.SplitsInClientOptionParser;
import org.apache.tez.mapreduce.hadoop.MRHelpers;
import org.apache.tez.mapreduce.hadoop.MRInputHelpers;
import org.apache.tez.mapreduce.hadoop.MRJobConfig;
import org.apache.tez.mapreduce.input.MRInputLegacy;
import org.apache.tez.mapreduce.output.MROutputLegacy;
import org.apache.tez.mapreduce.processor.map.MapProcessor;
import org.apache.tez.mapreduce.processor.reduce.ReduceProcessor;
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
import org.apache.tez.runtime.library.conf.OrderedPartitionedKVEdgeConfig;
import org.apache.tez.runtime.library.partitioner.HashPartitioner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Maps;

/**
 * An MRR job built on top of word count to return words sorted by
 * their frequency of occurrence.
 *
 * Use -DUSE_TEZ_SESSION=true to run jobs in a session mode.
 * If multiple input/outputs are provided, this job will process each pair
 * as a separate DAG in a sequential manner.
 * Use -DINTER_JOB_SLEEP_INTERVAL=<N> where N is the sleep interval in seconds
 * between the sequential DAGs.
 */
public class TestOrderedWordCount extends Configured implements Tool {

  private static Logger LOG = LoggerFactory.getLogger(TestOrderedWordCount.class);

  private static final String DAG_VIEW_ACLS = "tez.testorderedwordcount.view-acls";
  private static final String DAG_MODIFY_ACLS = "tez.testorderedwordcount.modify-acls";

  public static class TokenizerMapper
       extends Mapper<Object, Text, Text, IntWritable>{

    private final static IntWritable one = new IntWritable(1);
    private Text word = new Text();

    public void map(Object key, Text value, Context context
                    ) throws IOException, InterruptedException {
      StringTokenizer itr = new StringTokenizer(value.toString());
      while (itr.hasMoreTokens()) {
        word.set(itr.nextToken());
        context.write(word, one);
      }
    }
  }

  public static class IntSumReducer
       extends Reducer<Text,IntWritable,IntWritable, Text> {
    private IntWritable result = new IntWritable();

    public void reduce(Text key, Iterable<IntWritable> values,
                       Context context
                       ) throws IOException, InterruptedException {
      int sum = 0;
      for (IntWritable val : values) {
        sum += val.get();
      }
      result.set(sum);
      context.write(result, key);
    }
  }

  /**
   * Shuffle ensures ordering based on count of employees per department
   * hence the final reducer is a no-op and just emits the department name
   * with the employee count per department.
   */
  public static class MyOrderByNoOpReducer
      extends Reducer<IntWritable, Text, Text, IntWritable> {

    public void reduce(IntWritable key, Iterable<Text> values,
        Context context
        ) throws IOException, InterruptedException {
      for (Text word : values) {
        context.write(word, key);
      }
    }
  }

  private Credentials credentials = new Credentials();

  @VisibleForTesting
  public DAG createDAG(FileSystem fs, Configuration conf,
      Map<String, LocalResource> commonLocalResources, Path stagingDir,
      int dagIndex, String inputPath, String outputPath,
      boolean generateSplitsInClient,
      boolean useMRSettings,
      int intermediateNumReduceTasks) throws Exception {

    Configuration mapStageConf = new JobConf(conf);
    mapStageConf.set(MRJobConfig.MAP_CLASS_ATTR,
        TokenizerMapper.class.getName());
    MRHelpers.translateMRConfToTez(mapStageConf, !useMRSettings);

    Configuration iReduceStageConf = new JobConf(conf);
    // TODO replace with auto-reduce parallelism
    iReduceStageConf.setInt(MRJobConfig.NUM_REDUCES, 2);
    iReduceStageConf.set(MRJobConfig.REDUCE_CLASS_ATTR,
        IntSumReducer.class.getName());
    iReduceStageConf.set(TezRuntimeConfiguration.TEZ_RUNTIME_KEY_CLASS, Text.class.getName());
    iReduceStageConf.set(TezRuntimeConfiguration.TEZ_RUNTIME_VALUE_CLASS,
        IntWritable.class.getName());
    iReduceStageConf.setBoolean("mapred.mapper.new-api", true);
    MRHelpers.translateMRConfToTez(iReduceStageConf, !useMRSettings);

    Configuration finalReduceConf = new JobConf(conf);
    finalReduceConf.setInt(MRJobConfig.NUM_REDUCES, 1);
    finalReduceConf.set(MRJobConfig.REDUCE_CLASS_ATTR,
        MyOrderByNoOpReducer.class.getName());
    finalReduceConf.set(TezRuntimeConfiguration.TEZ_RUNTIME_KEY_CLASS, IntWritable.class.getName());
    finalReduceConf.set(TezRuntimeConfiguration.TEZ_RUNTIME_VALUE_CLASS, Text.class.getName());
    MRHelpers.translateMRConfToTez(finalReduceConf, !useMRSettings);

    MRHelpers.configureMRApiUsage(mapStageConf);
    MRHelpers.configureMRApiUsage(iReduceStageConf);
    MRHelpers.configureMRApiUsage(finalReduceConf);

    List<Vertex> vertices = new ArrayList<Vertex>();

    String mapStageHistoryText = TezUtils.convertToHistoryText("Initial Tokenizer Vertex",
        mapStageConf);
    DataSourceDescriptor dsd;
    if (generateSplitsInClient) {
      mapStageConf.set(MRJobConfig.INPUT_FORMAT_CLASS_ATTR,
          TextInputFormat.class.getName());
      mapStageConf.set(FileInputFormat.INPUT_DIR, inputPath);
      mapStageConf.setBoolean("mapred.mapper.new-api", true);
      dsd = MRInputHelpers.configureMRInputWithLegacySplitGeneration(mapStageConf, stagingDir,
          true);
    } else {
      dsd = MRInputLegacy.createConfigBuilder(mapStageConf, TextInputFormat.class,
          inputPath).build();
    }
    dsd.getInputDescriptor().setHistoryText(TezUtils.convertToHistoryText(
        "HDFS Input " + inputPath, mapStageConf));

    Map<String, String> mapEnv = Maps.newHashMap();
    MRHelpers.updateEnvBasedOnMRTaskEnv(mapStageConf, mapEnv, true);
    Map<String, String> reduceEnv = Maps.newHashMap();
    MRHelpers.updateEnvBasedOnMRTaskEnv(mapStageConf, reduceEnv, false);

    Vertex mapVertex;
    ProcessorDescriptor mapProcessorDescriptor =
        ProcessorDescriptor.create(MapProcessor.class.getName())
            .setUserPayload(
                TezUtils.createUserPayloadFromConf(mapStageConf))
            .setHistoryText(mapStageHistoryText);
    if (!useMRSettings) {
      mapVertex = Vertex.create("initialmap", mapProcessorDescriptor);
    } else {
      mapVertex = Vertex.create("initialmap", mapProcessorDescriptor, -1,
          MRHelpers.getResourceForMRMapper(mapStageConf));
      mapVertex.setTaskLaunchCmdOpts(MRHelpers.getJavaOptsForMRMapper(mapStageConf));
      mapVertex.setTaskEnvironment(mapEnv);
    }
    mapVertex.addTaskLocalFiles(commonLocalResources)
        .addDataSource("MRInput", dsd);
    vertices.add(mapVertex);

    String iReduceStageHistoryText = TezUtils.convertToHistoryText("Intermediate Summation Vertex",
        iReduceStageConf);
    ProcessorDescriptor iReduceProcessorDescriptor = ProcessorDescriptor.create(
        ReduceProcessor.class.getName())
        .setUserPayload(TezUtils.createUserPayloadFromConf(iReduceStageConf))
        .setHistoryText(iReduceStageHistoryText);

    Vertex intermediateVertex;
    if (!useMRSettings) {
      intermediateVertex = Vertex.create("intermediate_reducer", iReduceProcessorDescriptor,
          intermediateNumReduceTasks);
    } else {
      intermediateVertex = Vertex.create("intermediate_reducer", iReduceProcessorDescriptor,
          intermediateNumReduceTasks, MRHelpers.getResourceForMRReducer(iReduceStageConf));
      intermediateVertex.setTaskLaunchCmdOpts(MRHelpers.getJavaOptsForMRReducer(iReduceStageConf));
      intermediateVertex.setTaskEnvironment(reduceEnv);
    }
    intermediateVertex.addTaskLocalFiles(commonLocalResources);
    vertices.add(intermediateVertex);

    String finalReduceStageHistoryText = TezUtils.convertToHistoryText("Final Sorter Vertex",
        finalReduceConf);
    UserPayload finalReducePayload = TezUtils.createUserPayloadFromConf(finalReduceConf);
    Vertex finalReduceVertex;

    ProcessorDescriptor finalReduceProcessorDescriptor =
        ProcessorDescriptor.create(
            ReduceProcessor.class.getName())
            .setUserPayload(finalReducePayload)
            .setHistoryText(finalReduceStageHistoryText);
    if (!useMRSettings) {
      finalReduceVertex = Vertex.create("finalreduce", finalReduceProcessorDescriptor, 1);
    } else {
      finalReduceVertex = Vertex.create("finalreduce", finalReduceProcessorDescriptor, 1,
          MRHelpers.getResourceForMRReducer(finalReduceConf));
      finalReduceVertex.setTaskLaunchCmdOpts(MRHelpers.getJavaOptsForMRReducer(finalReduceConf));
      finalReduceVertex.setTaskEnvironment(reduceEnv);
    }
    finalReduceVertex.addTaskLocalFiles(commonLocalResources);
    finalReduceVertex.addDataSink("MROutput",
        MROutputLegacy.createConfigBuilder(finalReduceConf, TextOutputFormat.class, outputPath)
            .build());
    finalReduceVertex.getDataSinks().get(0).getOutputDescriptor().setHistoryText(
        TezUtils.convertToHistoryText("HDFS Output " + outputPath, finalReduceConf));
    vertices.add(finalReduceVertex);

    DAG dag = DAG.create("OrderedWordCount" + dagIndex);
    dag.setDAGInfo("{ \"context\": \"Tez\", \"description\": \"TestOrderedWordCount Job\" }");
    for (int i = 0; i < vertices.size(); ++i) {
      dag.addVertex(vertices.get(i));
    }

    OrderedPartitionedKVEdgeConfig edgeConf1 = OrderedPartitionedKVEdgeConfig
        .newBuilder(Text.class.getName(), IntWritable.class.getName(),
            HashPartitioner.class.getName()).setFromConfiguration(iReduceStageConf)
	    .configureInput().useLegacyInput().done().build();
    dag.addEdge(
        Edge.create(dag.getVertex("initialmap"), dag.getVertex("intermediate_reducer"),
            edgeConf1.createDefaultEdgeProperty()));

    OrderedPartitionedKVEdgeConfig edgeConf2 = OrderedPartitionedKVEdgeConfig
        .newBuilder(IntWritable.class.getName(), Text.class.getName(),
            HashPartitioner.class.getName()).setFromConfiguration(finalReduceConf)
            .configureInput().useLegacyInput().done().build();
    dag.addEdge(
        Edge.create(dag.getVertex("intermediate_reducer"), dag.getVertex("finalreduce"),
            edgeConf2.createDefaultEdgeProperty()));

    updateDAGACls(conf, dag, dagIndex);

    return dag;
  }

  private void updateDAGACls(Configuration conf, DAG dag, int dagIndex) {
    LOG.info("Checking DAG specific ACLS");
    DAGAccessControls accessControls = null;
    String suffix = "." + dagIndex;
    if (conf.get(DAG_VIEW_ACLS + suffix) != null
        || conf.get(DAG_MODIFY_ACLS + suffix) != null) {
      accessControls = new DAGAccessControls(
          conf.get(DAG_VIEW_ACLS + suffix), conf.get(DAG_MODIFY_ACLS + suffix));

    } else if (conf.get(DAG_VIEW_ACLS) != null
      || conf.get(DAG_MODIFY_ACLS) != null) {
      accessControls = new DAGAccessControls(
          conf.get(DAG_VIEW_ACLS), conf.get(DAG_MODIFY_ACLS));
    }
    if (accessControls != null) {
      LOG.info("Setting DAG specific ACLS");
      dag.setAccessControls(accessControls);
    }
  }

  private static void printUsage() {
    String options = " [-generateSplitsInClient true/<false>]";
    System.err.println("Usage: testorderedwordcount <in> <out>" + options);
    System.err.println("Usage (In Session Mode):"
        + " testorderedwordcount <in1> <out1> ... <inN> <outN>" + options);
    ToolRunner.printGenericCommandUsage(System.err);
  }

  @Override
  public int run(String[] args) throws Exception {
    Configuration conf = getConf();
    String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();

    boolean generateSplitsInClient;

    SplitsInClientOptionParser splitCmdLineParser = new SplitsInClientOptionParser();
    try {
      generateSplitsInClient = splitCmdLineParser.parse(otherArgs, false);
      otherArgs = splitCmdLineParser.getRemainingArgs();
    } catch (ParseException e1) {
      System.err.println("Invalid options");
      printUsage();
      return 2;
    }

    boolean useTezSession = conf.getBoolean("USE_TEZ_SESSION", true);
    long interJobSleepTimeout = conf.getInt("INTER_JOB_SLEEP_INTERVAL", 0)
        * 1000;

    boolean retainStagingDir = conf.getBoolean("RETAIN_STAGING_DIR", false);
    boolean useMRSettings = conf.getBoolean("USE_MR_CONFIGS", true);
    // TODO needs to use auto reduce parallelism
    int intermediateNumReduceTasks = conf.getInt("IREDUCE_NUM_TASKS", 2);

    if (((otherArgs.length%2) != 0)
        || (!useTezSession && otherArgs.length != 2)) {
      printUsage();
      return 2;
    }

    List<String> inputPaths = new ArrayList<String>();
    List<String> outputPaths = new ArrayList<String>();

    for (int i = 0; i < otherArgs.length; i+=2) {
      inputPaths.add(otherArgs[i]);
      outputPaths.add(otherArgs[i+1]);
    }

    UserGroupInformation.setConfiguration(conf);

    TezConfiguration tezConf = new TezConfiguration(conf);
    TestOrderedWordCount instance = new TestOrderedWordCount();

    FileSystem fs = FileSystem.get(conf);

    String stagingDirStr =  conf.get(TezConfiguration.TEZ_AM_STAGING_DIR,
            TezConfiguration.TEZ_AM_STAGING_DIR_DEFAULT) + Path.SEPARATOR +
            Long.toString(System.currentTimeMillis());
    Path stagingDir = new Path(stagingDirStr);
    FileSystem pathFs = stagingDir.getFileSystem(tezConf);
    pathFs.mkdirs(new Path(stagingDirStr));

    tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, stagingDirStr);
    stagingDir = pathFs.makeQualified(new Path(stagingDirStr));

    TokenCache.obtainTokensForNamenodes(instance.credentials, new Path[] {stagingDir}, conf);
    TezClientUtils.ensureStagingDirExists(tezConf, stagingDir);

    // No need to add jar containing this class as assumed to be part of
    // the tez jars.

    // TEZ-674 Obtain tokens based on the Input / Output paths. For now assuming staging dir
    // is the same filesystem as the one used for Input/Output.

    if (useTezSession) {
      LOG.info("Creating Tez Session");
      tezConf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, true);
    } else {
      tezConf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, false);
    }
    TezClient tezSession = TezClient.create("OrderedWordCountSession", tezConf,
        null, instance.credentials);
    tezSession.start();

    DAGStatus dagStatus = null;
    DAGClient dagClient = null;
    String[] vNames = { "initialmap", "intermediate_reducer",
      "finalreduce" };

    Set<StatusGetOpts> statusGetOpts = EnumSet.of(StatusGetOpts.GET_COUNTERS);
    try {
      for (int dagIndex = 1; dagIndex <= inputPaths.size(); ++dagIndex) {
        if (dagIndex != 1
            && interJobSleepTimeout > 0) {
          try {
            LOG.info("Sleeping between jobs, sleepInterval="
                + (interJobSleepTimeout/1000));
            Thread.sleep(interJobSleepTimeout);
          } catch (InterruptedException e) {
            LOG.info("Main thread interrupted. Breaking out of job loop");
            break;
          }
        }

        String inputPath = inputPaths.get(dagIndex-1);
        String outputPath = outputPaths.get(dagIndex-1);

        if (fs.exists(new Path(outputPath))) {
          throw new FileAlreadyExistsException("Output directory "
              + outputPath + " already exists");
        }
        LOG.info("Running OrderedWordCount DAG"
            + ", dagIndex=" + dagIndex
            + ", inputPath=" + inputPath
            + ", outputPath=" + outputPath);

        Map<String, LocalResource> localResources =
          new TreeMap<String, LocalResource>();

        DAG dag = instance.createDAG(fs, tezConf, localResources,
            stagingDir, dagIndex, inputPath, outputPath,
            generateSplitsInClient, useMRSettings, intermediateNumReduceTasks);

        boolean doPreWarm = dagIndex == 1 && useTezSession
            && conf.getBoolean("PRE_WARM_SESSION", true);
        int preWarmNumContainers = 0;
        if (doPreWarm) {
          preWarmNumContainers = conf.getInt("PRE_WARM_NUM_CONTAINERS", 0);
          if (preWarmNumContainers <= 0) {
            doPreWarm = false;
          }
        }
        if (doPreWarm) {
          LOG.info("Pre-warming Session");
          PreWarmVertex preWarmVertex = PreWarmVertex.create("PreWarm", preWarmNumContainers, dag
              .getVertex("initialmap").getTaskResource());
          preWarmVertex.addTaskLocalFiles(dag.getVertex("initialmap").getTaskLocalFiles());
          preWarmVertex.setTaskEnvironment(dag.getVertex("initialmap").getTaskEnvironment());
          preWarmVertex.setTaskLaunchCmdOpts(dag.getVertex("initialmap").getTaskLaunchCmdOpts());

          tezSession.preWarm(preWarmVertex);
        }

        if (useTezSession) {
          LOG.info("Waiting for TezSession to get into ready state");
          waitForTezSessionReady(tezSession);
          LOG.info("Submitting DAG to Tez Session, dagIndex=" + dagIndex);
          dagClient = tezSession.submitDAG(dag);
          LOG.info("Submitted DAG to Tez Session, dagIndex=" + dagIndex);
        } else {
          LOG.info("Submitting DAG as a new Tez Application");
          dagClient = tezSession.submitDAG(dag);
        }

        while (true) {
          dagStatus = dagClient.getDAGStatus(statusGetOpts);
          if (dagStatus.getState() == DAGStatus.State.RUNNING ||
              dagStatus.getState() == DAGStatus.State.SUCCEEDED ||
              dagStatus.getState() == DAGStatus.State.FAILED ||
              dagStatus.getState() == DAGStatus.State.KILLED ||
              dagStatus.getState() == DAGStatus.State.ERROR) {
            break;
          }
          try {
            Thread.sleep(500);
          } catch (InterruptedException e) {
            // continue;
          }
        }

        while (dagStatus.getState() != DAGStatus.State.SUCCEEDED &&
            dagStatus.getState() != DAGStatus.State.FAILED &&
            dagStatus.getState() != DAGStatus.State.KILLED &&
            dagStatus.getState() != DAGStatus.State.ERROR) {
          if (dagStatus.getState() == DAGStatus.State.RUNNING) {
            ExampleDriver.printDAGStatus(dagClient, vNames);
          }
          try {
            try {
              Thread.sleep(1000);
            } catch (InterruptedException e) {
              // continue;
            }
            dagStatus = dagClient.getDAGStatus(statusGetOpts);
          } catch (TezException e) {
            LOG.error("Failed to get application progress. Exiting");
            return -1;
          }
        }
        ExampleDriver.printDAGStatus(dagClient, vNames,
            true, true);
        LOG.info("DAG " + dagIndex + " completed. "
            + "FinalState=" + dagStatus.getState());
        if (dagStatus.getState() != DAGStatus.State.SUCCEEDED) {
          LOG.info("DAG " + dagIndex + " diagnostics: "
            + dagStatus.getDiagnostics());
        }
      }
    } catch (Exception e) {
      LOG.error("Error occurred when submitting/running DAGs", e);
      throw e;
    } finally {
      if (!retainStagingDir) {
        pathFs.delete(stagingDir, true);
      }
      LOG.info("Shutting down session");
      tezSession.stop();
    }

    if (!useTezSession) {
      ExampleDriver.printDAGStatus(dagClient, vNames);
      LOG.info("Application completed. " + "FinalState=" + dagStatus.getState());
    }
    return dagStatus.getState() == DAGStatus.State.SUCCEEDED ? 0 : 1;
  }

  private static void waitForTezSessionReady(TezClient tezSession)
    throws IOException, TezException, InterruptedException {
    tezSession.waitTillReady();
  }

  public static void main(String[] args) throws Exception {
    int res = ToolRunner.run(new TezConfiguration(), new TestOrderedWordCount(), args);
    System.exit(res);
  }
}


text:
package nsqadmin

import (
	"log"
	"os"
	"time"
)

type nsqadminOptions struct {
	HTTPAddress string `flag:"http-address"`

	GraphiteURL   string `flag:"graphite-url"`
	ProxyGraphite bool   `flag:"proxy-graphite"`

	UseStatsdPrefixes bool          `flag:"use-statsd-prefixes"`
	StatsdPrefix      string        `flag:"statsd-prefix"`
	StatsdInterval    time.Duration `flag:"statsd-interval"`

	NSQLookupdHTTPAddresses []string `flag:"lookupd-http-address" cfg:"nsqlookupd_http_addresses"`
	NSQDHTTPAddresses       []string `flag:"nsqd-http-address" cfg:"nsqd_http_addresses"`

	NotificationHTTPEndpoint string `flag:"notification-http-endpoint"`

	Logger logger
}

func NewNSQAdminOptions() *nsqadminOptions {
	return &nsqadminOptions{
		HTTPAddress:       "0.0.0.0:4171",
		UseStatsdPrefixes: true,
		StatsdPrefix:      "nsq.%s",
		StatsdInterval:    60 * time.Second,
		Logger:            log.New(os.Stderr, "[nsqadmin] ", log.Ldate|log.Ltime|log.Lmicroseconds),
	}
}


text:
L.ImageOverlay = L.Class.extend({
	includes: L.Mixin.Events,

	options: {
		opacity: 1
	},

	initialize: function (url, bounds, options) { // (String, LatLngBounds, Object)
		this._url = url;
		this._bounds = L.latLngBounds(bounds);

		L.setOptions(this, options);
	},

	onAdd: function (map) {
		this._map = map;

		if (!this._image) {
			this._initImage();
		}

		map._panes.overlayPane.appendChild(this._image);

		map.on('viewreset', this._reset, this);

		if (map.options.zoomAnimation && L.Browser.any3d) {
			map.on('zoomanim', this._animateZoom, this);
		}

		this._reset();
	},

	onRemove: function (map) {
		map.getPanes().overlayPane.removeChild(this._image);

		map.off('viewreset', this._reset, this);

		if (map.options.zoomAnimation) {
			map.off('zoomanim', this._animateZoom, this);
		}
	},

	addTo: function (map) {
		map.addLayer(this);
		return this;
	},

	setOpacity: function (opacity) {
		this.options.opacity = opacity;
		this._updateOpacity();
		return this;
	},

	// TODO remove bringToFront/bringToBack duplication from TileLayer/Path
	bringToFront: function () {
		if (this._image) {
			this._map._panes.overlayPane.appendChild(this._image);
		}
		return this;
	},

	bringToBack: function () {
		var pane = this._map._panes.overlayPane;
		if (this._image) {
			pane.insertBefore(this._image, pane.firstChild);
		}
		return this;
	},

	_initImage: function () {
		this._image = L.DomUtil.create('img', 'leaflet-image-layer');

		if (this._map.options.zoomAnimation && L.Browser.any3d) {
			L.DomUtil.addClass(this._image, 'leaflet-zoom-animated');
		} else {
			L.DomUtil.addClass(this._image, 'leaflet-zoom-hide');
		}

		this._updateOpacity();

		//TODO createImage util method to remove duplication
		L.extend(this._image, {
			galleryimg: 'no',
			onselectstart: L.Util.falseFn,
			onmousemove: L.Util.falseFn,
			onload: L.bind(this._onImageLoad, this),
			src: this._url
		});
	},

	_animateZoom: function (e) {
		var map = this._map,
		    image = this._image,
		    scale = map.getZoomScale(e.zoom),
		    nw = this._bounds.getNorthWest(),
		    se = this._bounds.getSouthEast(),

		    topLeft = map._latLngToNewLayerPoint(nw, e.zoom, e.center),
		    size = map._latLngToNewLayerPoint(se, e.zoom, e.center)._subtract(topLeft),
		    currentSize = map.latLngToLayerPoint(se)._subtract(map.latLngToLayerPoint(nw)),
		    origin = topLeft._add(size._subtract(currentSize)._divideBy(2));

		image.style[L.DomUtil.TRANSFORM] =
		        L.DomUtil.getTranslateString(origin) + ' scale(' + scale + ') ';
	},

	_reset: function () {
		var image   = this._image,
		    topLeft = this._map.latLngToLayerPoint(this._bounds.getNorthWest()),
		    size    = this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(topLeft);

		L.DomUtil.setPosition(image, topLeft);

		image.style.width  = size.x + 'px';
		image.style.height = size.y + 'px';
	},

	_onImageLoad: function () {
		this.fire('load');
	},

	_updateOpacity: function () {
		L.DomUtil.setOpacity(this._image, this.options.opacity);
	}
});

L.imageOverlay = function (url, bounds, options) {
	return new L.ImageOverlay(url, bounds, options);
};


text:
import { Router, ActivatedRoute } from '@angular/router';
 import {Component, AfterViewInit, OnInit} from '@angular/core';
import {BlogTagModel, BlogModel, BlogCategoryResponse} from "./blog.model";
import {BlogService} from "./blog.service";
import {Config} from "../../../shared/configs/general.config";
import {ImageCanvasSizeEnum} from "../../../shared/configs/enum.config";
import {ImageUploader} from "../../../shared/components/image-uploader.component";
import {FormGroup, FormControl, Validators, FormBuilder} from "@angular/forms";
import Swal from 'sweetalert2';

@Component({
  selector: 'blog-editor',
  templateUrl: './blog-editor.html'
})
export class BlogEditorComponent implements AfterViewInit,OnInit {
  objBlog:BlogModel = new BlogModel();
  objCatList:BlogCategoryResponse = new BlogCategoryResponse();
  blogId:string;
  blogForm:FormGroup;
  editorFormControl:FormControl = new FormControl('', Validators.required);
  isSubmitted:boolean = false;
  autoCompleteData:string[];
  /* Image Upload Handle*/
  imageDeleted:boolean = false;
  file:File;
  fileName:string = "";
  drawImagePath:string = Config.DefaultWideImage;
  imageFormControl:FormControl = new FormControl('');
  canvasSize:number = ImageCanvasSizeEnum.wide;
  /* End Image Upload handle */

  constructor(private router: Router, private activatedRoute: ActivatedRoute, private _objService:BlogService, private _formBuilder:FormBuilder) {
    activatedRoute.params.subscribe(param => this.blogId = param['id']);
  }

  ngAfterViewInit() {
    if (!this.blogId)
      this.drawImageToCanvas(this.drawImagePath);
  }

  createForm() {
    this.blogForm = this._formBuilder.group({
      "blogTitle": ['', Validators.required],
      "blogSummary": ['', Validators.required],
      "blogAuthor": ['', Validators.required],
      "editorFormControl": this.editorFormControl,
      "blogCategory": ['', Validators.required],
      "tags": ['', Validators.required],
      "bannerImageTitle": [''],
      "bannerImageAltText": [''],
      "imageFormControl": this.imageFormControl,
      "status": [''],
      "active": ['']
    });
  }

  ngOnInit() {
    this.createForm();
    this.getCategoryList();
    /*active*/
    if (this.blogId)
      this.getBlogDetail();
    this.getBlogTagList();
  }

  getBlogTagList():void {
    this._objService.getBlogTagList()
      .subscribe(res =>this.bindTagForAutoComplete(res),
        error => this.errorMessage(error));
  }

  bindTagForAutoComplete(res:BlogTagModel[]) {
    let data:string[] = res.map(function (row) {
      return row.tag;
    });
    this.autoCompleteData = data;
  }

  getCategoryList() {
    this._objService.getBlogCategoryList(100, 1, true)
      .subscribe(res=>this.objCatList = res,
        error=>this.errorMessage(error)
      )
  }

  getBlogDetail() {
    this._objService.getBlogDetail(this.blogId)
      .subscribe(res =>this.bindDetail(res),
        error => this.errorMessage(error));
  }

  bindDetail(objRes:BlogModel) {
    let tags = objRes.tags.map(function (res: any) {
      return res.tag;
    });
    objRes.tags = tags;
    this.objBlog = objRes;
    this.editorFormControl.patchValue(objRes.blogDescription);
    let path:string = "";
    if (this.objBlog.bannerImage) {
      var cl = Config.Cloudinary;
      path = cl.url(this.objBlog.bannerImage);
    }
    else
      path = Config.DefaultWideImage;
    this.drawImageToCanvas(path);
  }

  saveBlog() {
    this.isSubmitted = true;
    this.editorFormControl.patchValue(this.objBlog.blogDescription);
    if (this.blogForm.valid) {
      if (!this.blogId) {
        this._objService.saveBlog(this.objBlog, this.file)
          .subscribe(res => this.resStatusMessage(res),
            error => this.errorMessage(error));
      }
      else {
        this._objService.updateBlog(this.objBlog, this.file, this.imageDeleted)
          .subscribe(res => this.resStatusMessage(res),
            error => this.errorMessage(error));
      }
    }
  }

  resStatusMessage(objSave:any) {
    this.triggerCancelForm();
    Swal("Success !", objSave.message, "success");
  }

  editorValueChange(args: any) {
    this.objBlog.blogDescription = args;
    //  (<FormControl>this.newsForm.controls["editorFormControl"]).updateValue(args);
  }

  triggerCancelForm() {
    this.router.navigate(['/blog']);
  }

  errorMessage(objResponse:any) {
    Swal("Alert !", objResponse, "info");
  }

  /*Image Handler */
  changeFile(args: any) {
    this.file = args;
    this.fileName = this.file.name;
  }

  drawImageToCanvas(path:string) {
    this.drawImagePath = path;
  }

  deleteImage(imageId: string) {
  Swal({
        title: "Are you sure?",
        text: "You will not be able to recover this Image !",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "Yes, delete it!"
      })
      .then((result)=> {
        if(result.value){
        this._objService.deleteImage(this.objBlog.bannerImage, this.objBlog.imageProperties.imageExtension, this.objBlog.imageProperties.imagePath)
          .subscribe(res=> {
              this.imageDeleted = true;
              this.objBlog.bannerImage = "";
              this.fileName = "";
              this.drawImageToCanvas(Config.DefaultWideImage);
              Swal("Deleted!", res.message, "success");
            },
            error=> {
              Swal("Alert!", error, "info");
            });
          }
      });
  }
  /* End Image Handler */
}


text:
/* white-spaces before closing bracket */
nav.right-side span.item span {
  width: 100px;
  margin: auto;
  }


text:
package nodes

import (
	"github.com/pkg/errors"

	"k8s.io/kubeadm/kinder/pkg/cluster/status"
	"k8s.io/kubeadm/kinder/pkg/constants"
	"k8s.io/kubeadm/kinder/pkg/cri/nodes/common"
	"k8s.io/kubeadm/kinder/pkg/cri/nodes/containerd"
	"k8s.io/kubeadm/kinder/pkg/cri/nodes/docker"
	"k8s.io/kubeadm/kinder/pkg/exec"
)

// CreateHelper provides CRI specific methods for node create
type CreateHelper struct {
	cri status.ContainerRuntime
}

// NewCreateHelper returns a new CreateHelper
func NewCreateHelper(cri status.ContainerRuntime) (*CreateHelper, error) {
	return &CreateHelper{
		cri: cri,
	}, nil
}

// CreateNode creates a container that internally hosts the selected cri runtime
func (h *CreateHelper) CreateNode(cluster, name, image, role string, volumes []string) error {
	switch h.cri {
	case status.ContainerdRuntime:
		return containerd.CreateNode(cluster, name, image, role, volumes)
	case status.DockerRuntime:
		return docker.CreateNode(cluster, name, image, role, volumes)
	}
	return errors.Errorf("unknown cri: %s", h.cri)
}

// CreateExternalEtcd creates a container hosting a single node, insecure, external etcd cluster
func (h *CreateHelper) CreateExternalEtcd(cluster, name, image string) error {
	args, err := common.BaseRunArgs(cluster, name, constants.ExternalEtcdNodeRoleValue)
	if err != nil {
		return err
	}

	// Add etcd run args
	args = common.RunArgsForExternalEtcd(args)

	// Specify the image to run
	args = append(args, image)

	// Add container args for starting a single node, insecure etcd
	args = common.ContainerArgsForExternalEtcd(cluster, args)

	// creates the container
	return exec.NewHostCmd("docker", args...).Run()
}

// CreateExternalLoadBalancer creates a container hosting an external load balancer
func (h *CreateHelper) CreateExternalLoadBalancer(cluster, name string) error {
	args, err := common.BaseRunArgs(cluster, name, constants.ExternalLoadBalancerNodeRoleValue)
	if err != nil {
		return err
	}

	// Add load balancer run args
	args, err = common.RunArgsForExternalLoadBalancer(args)
	if err != nil {
		return err
	}

	// Specify the image to run
	args = append(args, constants.LoadBalancerImage)

	// creates the container
	return exec.NewHostCmd("docker", args...).Run()
}


text:
package com.naokia.groonga4s.response

import org.specs2.mutable.Specification

class ErrorResponseParserSpec extends Specification{
  "ErrorResponseParser" >> {
    "parse error json" >> {
      val jsonStr = "[[-22,1433725216.53196,0.000396728515625,\"invalid table name: <>\",[[\"grn_select\",\"proc.c\",1153]]]]"
      val response = new ErrorResponseParser().parse(jsonStr, "http://localhost:10041/d/select?table=Site&someQuery")
      response.returnCode must equalTo(-22)
      response.message must equalTo("invalid table name: <>")
    }
  }
}


text:
package com.camnter.load.plugin.resources.plugin;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * @author CaMnter
 */

@SuppressWarnings("DanglingJavadoc")
public class PluginActivity extends AppCompatActivity {

    private Resources resources;

    /**
     * ---------------------------------------------------------------------------------------------
     *
     * 有两种选择:
     *
     * - 拿 Plugin Resource 直接加载资源,但是无法加载 layout
     * - Hook ContextImpl 中的 mResource. 然后下面可以加载 layout
     *
     * ---------------------------------------------------------------------------------------------
     *
     * 自定义 View 或者 Fragment:
     *
     * 需要 持有一个 Inflate
     *
     * final View selfView = LayoutInflater.from(this).inflate(R.layout.activity_main, null);
     * this.setContentView(selfView);
     *
     * ---------------------------------------------------------------------------------------------
     *
     * @param savedInstanceState Bundle
     */
    @SuppressLint("SetTextI18n")
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_main);
    }

    @Override
    protected void attachBaseContext(Context newBase) {
        try {
            final Field field = newBase.getClass().getDeclaredField("mResources");
            field.setAccessible(true);
            if (this.resources == null) {
                this.resources = this.getPluginResources(newBase);
            }
            field.set(newBase, this.resources);
        } catch (Exception e) {
            e.printStackTrace();
        }
        super.attachBaseContext(newBase);
    }

    /**
     * 获取 插件 Resources
     *
     * @param newBase Context
     * @return Resources
     */
    private Resources getPluginResources(final Context newBase) {
        try {
            String dir = null;
            final File cacheDir = newBase.getExternalCacheDir();
            final File filesDir = newBase.getExternalFilesDir("");
            if (cacheDir != null) {
                dir = cacheDir.getAbsolutePath();
            } else {
                if (filesDir != null) {
                    dir = filesDir.getAbsolutePath();
                }
            }
            if (TextUtils.isEmpty(dir)) return null;

            // assets 的 load-plugin-resource-plugin.apk 拷贝到 /storage/sdcard0/Android/data/[package name]/cache
            // 或者  /storage/sdcard0/Android/data/[package name]/files
            final File dexPath = new File(dir + File.separator + "load-plugin-resource-plugin.apk");

            if (!dexPath.exists()) {
                AssetsUtils.copyAssets(newBase, "load-plugin-resource-plugin.apk",
                    dexPath.getAbsolutePath());
            }

            final AssetManager assetManager = AssetManager.class.newInstance();
            final Method addAssetPath = assetManager.getClass()
                .getMethod("addAssetPath", String.class);
            addAssetPath.invoke(assetManager, dexPath.getAbsolutePath());

            /**
             * 如果要 独立使用 Resources,而不 Hook mResources :
             *
             * final Resources originResources = super.getResources();
             * final Resources pluginResources = new Resources(assetManager, originResources.getDisplayMetrics(),
             * originResources.getConfiguration());
             */
            return new Resources(
                assetManager,
                newBase.getResources().getDisplayMetrics(),
                newBase.getResources().getConfiguration()
            );
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

}


text:
namespace sax {

	Texture::Texture():
		width(0),
		height(0),
		realWidth(0),
		realHeight(0),
		crop(nullptr),
		sdlTexture(nullptr),
		path("")
	{}

	Texture::~Texture() {
		clear();
	}

	void Texture::clear() {
		if ( sdlTexture != nullptr ) {
			SDL_DestroyTexture( sdlTexture );
		}
	}

	void Texture::fromImage( std::string path ) {
		clear();
		TextureInfo* info = Resources::get_texture_info( path );
		this->path = path;
		realWidth = info->width;
		realHeight = info->height;
		width = info->width;
		height = info->height;
	}

	void Texture::fromSurface( SDL_Renderer* renderer, SDL_Surface* surface ) {
		clear();
		sdlTexture = SDL_CreateTextureFromSurface( renderer, surface );
		realWidth = surface->w;
		realHeight = surface->h;
		width = surface->w;
		height = surface->h;
	}

	void Texture::draw( SDL_Renderer* renderer, SDL_Rect* destRect, double rotation, Point* anchor) {

		if ( sdlTexture == nullptr && ! path.empty() ) {
			sdlTexture = Resources::get_texture( renderer, path );
		}

		if ( sdlTexture != nullptr ) {
			SDL_Point _anchor = { (int)anchor->x, (int)anchor->y };
			SDL_RenderCopyEx( renderer, sdlTexture, crop, destRect, rotation, &_anchor, SDL_FLIP_NONE );
			//SDL_RenderCopy(renderer, sdlTexture, crop, destRect);
		}
	}

	int Texture::get_width() {
		return width;
	}

	int Texture::get_height() {
		return height;
	}

}


text:
package com.snail.hostseditor.event;

import com.snail.hostseditor.model.Host;

import java.util.List;

/**
 * Sent to the bus when hosts need to be refreshed.
 */
public class RefreshHostsEvent {

    public final List<Host> hosts;

    public RefreshHostsEvent(List<Host> refreshedHosts) {
        hosts = refreshedHosts;
    }
}


text:
package db

import (
	"time"
)

type TaskStatus string

const (
	TaskRunningStatus  TaskStatus = "running"
	TaskWaitingStatus  TaskStatus = "waiting"
	TaskStoppingStatus TaskStatus = "stopping"
	TaskStoppedStatus  TaskStatus = "stopped"
	TaskSuccessStatus  TaskStatus = "success"
	TaskFailStatus     TaskStatus = "error"
)

//Task is a model of a task which will be executed by the runner
type Task struct {
	ID         int `db:"id" json:"id"`
	TemplateID int `db:"template_id" json:"template_id" binding:"required"`
	ProjectID  int `db:"project_id" json:"project_id"`

	Status TaskStatus `db:"status" json:"status"`
	Debug  bool       `db:"debug" json:"debug"`

	DryRun bool `db:"dry_run" json:"dry_run"`
	Diff   bool `db:"diff" json:"diff"`

	// override variables
	Playbook    string `db:"playbook" json:"playbook"`
	Environment string `db:"environment" json:"environment"`
	Limit       string `db:"hosts_limit" json:"limit"`

	UserID *int `db:"user_id" json:"user_id"`

	Created time.Time  `db:"created" json:"created"`
	Start   *time.Time `db:"start" json:"start"`
	End     *time.Time `db:"end" json:"end"`

	Message string `db:"message" json:"message"`

	// CommitMessage is a git commit hash of playbook repository which
	// was active when task was created.
	CommitHash *string `db:"commit_hash" json:"commit_hash"`
	// CommitMessage contains message retrieved from git repository after checkout to CommitHash.
	// It is readonly by API.
	CommitMessage string `db:"commit_message" json:"commit_message"`

	BuildTaskID *int `db:"build_task_id" json:"build_task_id"`

	// Version is a build version.
	// This field available only for Build tasks.
	Version *string `db:"version" json:"version"`

	Arguments *string `db:"arguments" json:"arguments"`
}

func (task *Task) GetIncomingVersion(d Store) *string {
	if task.BuildTaskID == nil {
		return nil
	}

	buildTask, err := d.GetTask(task.ProjectID, *task.BuildTaskID)

	if err != nil {
		return nil
	}

	tpl, err := d.GetTemplate(task.ProjectID, buildTask.TemplateID)
	if err != nil {
		return nil
	}

	if tpl.Type == TemplateBuild {
		return buildTask.Version
	}

	return buildTask.GetIncomingVersion(d)
}

func (task *Task) ValidateNewTask(template Template) error {
	switch template.Type {
	case TemplateBuild:
	case TemplateDeploy:
	case TemplateTask:
	}
	return nil
}

func (task *TaskWithTpl) Fill(d Store) error {
	if task.BuildTaskID != nil {
		build, err := d.GetTask(task.ProjectID, *task.BuildTaskID)
		if err == ErrNotFound {
			return nil
		}
		if err != nil {
			return err
		}
		task.BuildTask = &build
	}
	return nil
}

// TaskWithTpl is the task data with additional fields
type TaskWithTpl struct {
	Task
	TemplatePlaybook string       `db:"tpl_playbook" json:"tpl_playbook"`
	TemplateAlias    string       `db:"tpl_alias" json:"tpl_alias"`
	TemplateType     TemplateType `db:"tpl_type" json:"tpl_type"`
	UserName         *string      `db:"user_name" json:"user_name"`
	BuildTask        *Task        `db:"-" json:"build_task"`
}

// TaskOutput is the ansible log output from the task
type TaskOutput struct {
	TaskID int       `db:"task_id" json:"task_id"`
	Task   string    `db:"task" json:"task"`
	Time   time.Time `db:"time" json:"time"`
	Output string    `db:"output" json:"output"`
}


text:
class CreateSections < ActiveRecord::Migration[5.1]
  def self.up
    create_table :sections do |t|
      t.integer     :user_id
      t.integer     :investigation_id
      t.column      :uuid, :string, :limit => 36

      t.string      :name
      t.text        :description
      t.integer     :position

      t.timestamps
    end
    add_index :sections, :position
  end

  def self.down
    remove_index :sections, :position
    drop_table :sections
  end
end


text:
// Copyright 2004-present Facebook. All Rights Reserved.

package com.facebook.buck.jvm.kotlin;

import static com.google.common.collect.Iterables.transform;

import com.facebook.buck.io.ProjectFilesystem;
import com.facebook.buck.rules.SourcePathResolver;
import com.facebook.buck.rules.Tool;
import com.facebook.buck.shell.ShellStep;
import com.facebook.buck.step.ExecutionContext;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSortedSet;

import java.io.File;
import java.nio.file.Path;

public class KotlincStep extends ShellStep {

  private static final String CLASSPATH_FLAG = "-cp";
  private static final String DESTINATION_FLAG = "-d";
  private static final String INCLUDE_RUNTIME_FLAG = "-include-runtime";

  private final Tool kotlinc;
  private final SourcePathResolver resolver;
  private final ImmutableSortedSet<Path> declaredClassPathEntries;
  private final Path outputDirectory;
  private final ImmutableList<String> extraArguments;
  private final ImmutableSortedSet<Path> sourceFilePaths;

  KotlincStep(
      Tool kotlinc,
      ImmutableList<String> extraArguments,
      SourcePathResolver resolver,
      Path outputDirectory,
      ImmutableSortedSet<Path> sourceFilePaths,
      ImmutableSortedSet<Path> declaredClassPathEntries,
      ProjectFilesystem filesystem) {
    super(filesystem.getRootPath());
    this.kotlinc = kotlinc;
    this.resolver = resolver;
    this.declaredClassPathEntries = declaredClassPathEntries;
    this.outputDirectory = outputDirectory;
    this.extraArguments = extraArguments;
    this.sourceFilePaths = sourceFilePaths;
  }

  @Override
  public String getShortName() {
    return Joiner.on(" ").join(kotlinc.getCommandPrefix(resolver));
  }

  @Override
  protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
    final ImmutableList.Builder<String> command = ImmutableList.<String>builder()
        .addAll(kotlinc.getCommandPrefix(resolver));

    String classpath =
        Joiner.on(File.pathSeparator).join(transform(declaredClassPathEntries, Object::toString));
    command
        .add(INCLUDE_RUNTIME_FLAG)
        .add(CLASSPATH_FLAG)
        .add(classpath.isEmpty() ? "''" : classpath)
        .add(DESTINATION_FLAG)
        .add(outputDirectory.toString());

    command
        .addAll(extraArguments)
        .addAll(transform(sourceFilePaths, Object::toString));
    return command.build();
  }
}


text:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
         http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">

    <include file="db/changelog/db.changelog-1.xml"/>
</databaseChangeLog>


text: require 'middleman-vendor_bower'