text:
#Dimensions Computation

Big data scenarios often have use-case where huge volumes of data flowing through the big data systems need to be observed for historical trends.
Many applications addressing such scenarios can greatly benefit if they are equipped with the functionality of viewing historical data aggregated across time buckets. The process of receiving individual events, aggregating them over a duration, and using parameters to observe trends is referred to as *Dimensions Computation*.

This document provides an overview of *Dimensions Computation*, as well as instructions for using DataTorrent's operators to easily add dimensions computation to an Apache Apex application.

## Overview

### What is Dimensions Computation?
Dimensions Computation is a powerful mechanism that allows for spotting trends in streaming data in real-time. This tutorial will cover the concepts behind Dimensions Computation and provide details on the process of performing Dimensions Computation. We will also show you how to use Data Torrent's out of the box operators to easily add Dimensions Computation to an application.

*Dimensions Computation* provides a way for businesses to perform aggregations on configured numeric data. The *DimensionsComputation* operator works along with the *DimensionStore* operator, which provides the capability for applications to display historical data and trends.

## Key Concepts

#### Key set
A key set is a set of fields in the incoming tuple that is used to combine data for aggregation.

#### Value set
A value set is the set of fields in the incoming tuple on which *Aggregator*(s)  are applied.

#### Aggregator
An aggregator is a mathematical function that is  applied on value fields in an incoming tuple. Examples of aggregators are SUM, COUNT, MAX, MIN, and AVERAGE.

#### Aggregates
Aggregates are objects containing the aggregated values for a configured value set and key combination.

#### Time buckets
Time buckets indicate the duration for which the floor time is calculated. For example, a for a time bucket of 1 minute, the floor time-value for both * 12:**01:34** PM * and * 12:**01:59** PM * will be * 12:**01:00** PM*. Similarly, for an hourly time bucket, floor time-value for * **15**:02:34 PM* and * **15**:34:00 PM* will be * **15:00:00** PM*.

After calculating the floor value for a duration, the time-value becomes a key. Currently supported time buckets are:  1 second, 1 minute, 1 hour, and 1 day.

#### Combinations
Combinations indicate a group of the keys that are used for aggregate computations.

#### Incremental *Aggregators*
Incremental aggregators are aggregate functions for which computations are possible only by using previous aggregate value and the new value. For example,
```
SUM = {Previous_SUM} + {Current_Value}
COUNT = {Previous_COUNT}  + 1
MIN = ( {Current_Value} < {Previous_MIN} ) ? {Current_Value} : {Previous_MIN}
```

#### On-the-fly *Aggregators* (OTF Aggregators)
On-the-fly aggregators are the aggregate functions that use the result of multiple incremental aggregators, and can be calculated on-the-fly if necessary. For example,
```
AVERAGE = {Current_SUM} / {Current_COUNT}
```

#### DimensionsComputation operator
The DimensionsComputation operator  is an Operator that performs intermediate aggregations using incremental aggregators.

#### DimensionsStore operator
The DimensionsStore operator  is an Operator that performs transient and final aggregations on the data generated by the Dimensions Computations operator. It maintains the historical data for aggregates to ensure a meaningful  historical view.

## Dimensions Computation use cases
Consider the case of a digital advertising publisher who receives thousands of click events every second. The history of individual clicks and impressions doesn't divulge details about users and the advertisements. A technique for deriving meaning out of such data is to observe the total number of clicks and impressions every second, minute, hour, and day. Such a technique might be  helpful for determining global trends in the advertising system, but may not provide enough granularity for localized trends. For example, the total clicks and impressions over a duration might lack in usefulness, however, the total clicks and impressions for a particular advertiser, a particular geographical area, or a combination of the two can provide actionable insight.

## Architecture

Dimensions Computation requires 4 operators working in sync: DimensionsComputation, DimensionsStore, Query, and QueryResult. Given [DAG](#dag) is for a complete Dimensions Computation application.

The operators within Dimensions Computation are described in detail.

#### DimensionsComputation
The DimensionsComputation operator works only with incremental aggregates. The incoming data stream contains tuples that are Plain Old Java Objects (POJO), which contain data required for aggregations.
Depending on the [configuration](#configuration), the DimensionsComputation operator applies incremental aggregators on the value set of the tuple data within a boundary of an application window. At the end of the application window, the aggregate value is reset to calculate the new aggregates. Thus, discrete aggregates are generated by DimensionsComputation operator for every application window. This output is used by the DimensionStore operator (labeled as Store in [DAG](#dag)) for calculating cumulative aggregates.

#### DimensionsStore
The DimensionsStore operator uses the discrete aggregates generated by the DimensionsComputation operator to generate cumulative aggregates in turn. Because the aggregates generated by the DimensionsComputation operator are incremental aggregates, the sum of multiple such aggregates provides cumulative aggregates as follows:

```
SUM1 = SUM(Value11, Value12, ...)
SUM2 = SUM(Value21, Value22, ...)

{Cumulative_SUM} = SUM1 + SUM2
```

The DimensionsStore operator also stores transient aggregates in a persistent proprietary store called HDHT. The DimensionsStore operator uses HDHT to present the requested historical data.

#### Query

The Query operator interfaces with the *pubsub server* of *DataTorrent Gateway*. The browser creates a websocket connection with the  pubsub server hosted by DataTorrent Gateway. The Dashboard UI Widgets send queries to the pubsub server via this connection. The Query operator subscribes to the configured pubsub topic for receiving queries. These queries are parsed by the Query operator and passed onto DimensionsStore to fetch data from HDHT Store.

#### QueryResult

The QueryResult operator gets the result from the DimensionsStore operator for a given query. The results are reconstructed into a format that is understood by a widget. After the results are reconstructed into the required format, they are sent to the *pubsub server* for publishing to UI widgets.

### DAG

![DAG](images/dimensions_computation/image000.png)

## Dimensions Computation Configuration

### Configuration Definitions

The configuration of Dimensions Computation is divided into: Dimensions Computation Schema Configuration and Operator Configurations as follows:

#### Dimensions Computation Schema Configuration

The Dimensions Computation Schema provides the Dimensions Computation operator with information about the aggregations. The schema looks like this:

```json
{"keys":[{"name":"publisher","type":"string","enumValues":["twitter","facebook","yahoo"]},
         {"name":"advertiser","type":"string","enumValues":["starbucks","safeway","mcdonalds"]},
         {"name":"location","type":"string","enumValues":["N","LREC","SKY","AL","AK"]}],
 "timeBuckets":["1m","1h","1d"],
 "values":
  [{"name":"impressions","type":"long","aggregators":["SUM","COUNT","AVG"]},
   {"name":"clicks","type":"long","aggregators":["SUM","COUNT","AVG"]},
   {"name":"cost","type":"double","aggregators":["SUM","COUNT","AVG"]},
   {"name":"revenue","type":"double","aggregators":["SUM","COUNT","AVG"]}],
 "dimensions":
  [{"combination":[]},
   {"combination":["location"]},
   {"combination":["advertiser"], "additionalValues":["impressions:MIN", "clicks:MIN", "cost:MIN", "revenue:MIN", "impressions:MAX", "clicks:MAX", "cost:MAX", "revenue:MAX"]},
   {"combination":["publisher"], "additionalValues":["impressions:MIN", "clicks:MIN", "cost:MIN", "revenue:MIN", "impressions:MAX", "clicks:MAX", "cost:MAX", "revenue:MAX"]},
   {"combination":["advertiser","location"]},
   {"combination":["publisher","location"]},
   {"combination":["publisher","advertiser"]},
   {"combination":["publisher","advertiser","location"]}]
}
```

The schema configuration is a JSON string that contains the following information:

1. **keys:** - This contains the set of keys derived from an input tuple. The *name* field stands for the name of the field from input tuple. The *type* can be defined for individual keys. The probable values for individual keys can be provided using *enumValues*.

2. **values:** - This contains the set of fields from an input tuple on which aggregates are calculated. The *name* field stands for the name of the field from an input tuple. The *type* can be defined for individual keys. The *aggregators* can be defined separately for individual values. Only configured aggregator functions are executed on values.

3. **timeBuckets:** - This can be used to specify the time bucket over which aggregations occur. Possible values for timeBuckets are ***"1m", "1h", "1d"***

4. **dimensions:** - This defines the combinations of keys that are used for grouping data for aggregate calculations. This can be mentioned in *combination* with the JSON key. *additionalValues* can be used for mentioning additional aggregators for any *value*. For example, **impressions:MIN** indicates that for a given combination, calculate "*MIN*" for value "*impression*" as well.
By default, the down time rounded off to the next value as per time bucket is always considered as one of the keys.

#### Operator Configurations

Operator configurations is another set of configuration that can be used to configure individual operators.

##### Properties

1. **dt.operator.QueryResult.topic:** - This is the name of the topic on which UI widgets listen for results.
2. **dt.operator.Query.topic:** - his is the name of the topic on which Query operator listen for queries.
3. **dt.operator.QueryResult.numRetries** - This property indicates the maximum number of times the QueryResult operator should retry sending data. This value is usually high.

##### Attributes

1. **dt.operator.DimensionsComputation.attr.PARTITIONER:** - This attribute determines the number of  partitions for DimensionsComputation. Adding more partitions means data is  processed in parallel. If this attribute is not provided, a single partition is created. Refer to the [Partitioning](#partitioning) section for details on partitioning.
2. **dt.operator.DimensionsComputation.attr.MEMORY_MB:** - This attribute determines the  memory that should be assigned to the DimensionsComputations operator. If this attribute is not provided, the default value of  1 GB is used.
3. **dt.operator.Store.attr.MEMORY_MB:** - This attribute determines the memory that should be assigned to DimensionsStore operator. If this attribute is not provided, the default value of 1 GB is used.
4. **dt.port.*.attr.QUEUE_CAPACITY** - This attribute determines the number of tuples the buffer server can cache without blocking the input stream to the port. For peak activity, we  recommend increasing QUEUE_CAPACITY to a higher value such as 32000. If this attribute is not provided, the default value of 1024 is used.

## Visualizing Dimensions Computation

When Dimension Computation  is launched, the visualization of aggregates over a duration can be seen by adding a widget to a dtDashboard. dtDashboard is the self-service real-time and historical data visualization interface. Rapidly gaining insight and reducing time to action provides the greatest value to an organization. DataTorrent RTS provides self-service data visualization for the business user enabling them to not only see dashboards and reports an order of magnitude faster, but to also create and share customer reports.To derive more value out of dashboards, you can add widgets to the dashboards. Widgets are charts in addition to the default charts that you can see on the dashboard.

And example of a Dashboard UI Widget is as follows:

![Dashboard widgets](images/dimensions_computation/image001.png)

## Creating Dimensions Computation Application

Consider an example of the advertising publisher. Typically, an advertising publisher receives a packet of information for every event related to their  advertisements.

### Sample publisher event

An event might look like this:
```java
public class AdEvent
{
  //The name of the company that is advertising
  public String advertiser;
  //The geographical location of the person initiating the event
  public String location;
  //How much the advertiser was charged for the event
  public double cost;
  //How much revenue was generated for the advertiser
  public double revenue;
  //The number of impressions the advertiser received from this event
  public long impressions;
  //The number of clicks the advertiser received from this event
  public long clicks;
  //The timestamp of the event in milliseconds
  public long time;

  public AdEvent() {}

  public AdEvent(String advertiser, String location, double cost, double revenue,
                 long impressions, long clicks, long time)
  {
    this.advertiser = advertiser;
    this.location = location;
    this.cost = cost;
    this.revenue = revenue;
    this.impressions = impressions;
    this.clicks = clicks;
    this.time = time;
  }

  /* Getters and setters go here */
}
```

### Creating an Application using out-of-the-box operators

Dimensions Computation can be created using out-of-the-box operators from the Megh and Malhar library. A sample is given below:

```java
@ApplicationAnnotation(name="AdEventDemo")
public class AdEventDemo implements StreamingApplication
{
  public static final String EVENT_SCHEMA = "adsGenericEventSchema.json";

  @Override
  public void populateDAG(DAG dag, Configuration conf)
  {
    //This loads the eventSchema.json file which is a jar resource file.
    // eventSchema.json contains the Dimensions Schema using which aggregations is configured.
    String eventSchema = SchemaUtils.jarResourceFileToString("eventSchema.json");

    // Operator that receives Ad Events
    // This can be coming from any source as long as the operator can convert the data into AdEventReceiver object.
    AdEventReceiver receiver = dag.addOperator("Event Receiver", AdEventReceiver.class);

    //Adding Dimensions Computation operator into DAG.
    DimensionsComputationFlexibleSingleSchemaPOJO dimensions = dag.addOperator("DimensionsComputation", DimensionsComputationFlexibleSingleSchemaPOJO.class);

    // This defines the name present in input tuple to the name of the getter method to be used to get the value of the field.
    Map<String, String> keyToExpression = Maps.newHashMap();
    keyToExpression.put("advertiser", "getAdvertiser()");
    keyToExpression.put("location", "getLocation()");
    keyToExpression.put("time", "getTime()");

    // This defines value to expression mapping for value field name to the name of the getter method to get the value of the field.
    Map<String, String> valueToExpression = Maps.newHashMap();
    valueToExpression.put("cost", "getCost()");
    valueToExpression.put("revenue", "getRevenue()");
    valueToExpression.put("impressions", "getImpressions()");
    valueToExpression.put("clicks", "getClicks()");

    dimensions.setKeyToExpression(keyToExpression);
    dimensions.setAggregateToExpression(aggregateToExpression);
    dimensions.setConfigurationSchemaJSON(eventSchema);

    // This configures the unifier. The purpose of this unifier is to combine the partial aggregates from different partitions of DimensionsComputation operator into single stream.
    dimensions.setUnifier(new DimensionsComputationUnifierImpl<InputEvent, Aggregate>());

    // Add Dimension Store operator to DAG.
    AppDataSingleSchemaDimensionStoreHDHT store = dag.addOperator("Store", AppDataSingleSchemaDimensionStoreHDHT.class);

    // This configure the Backend HDHT store of DimensionStore operator. This backend will be used to persist the Historical Aggregates Data.
    TFileImpl hdsFile = new TFileImpl.DTFileImpl();
    hdsFile.setBasePath("dataStorePath");
    store.setFileStore(hdsFile);
    store.setConfigurationSchemaJSON(eventSchema);

    // This configures the Query and QueryResult operators to the gateway address. This is needs for pubsub communication of queries/results between operators and pubsub server.
    String gatewayAddress = dag.getValue(DAG.GATEWAY_CONNECT_ADDRESS);
    URI uri = URI.create("ws://" + gatewayAddress + "/pubsub");
    PubSubWebSocketAppDataQuery wsIn = dag.addOperator("Query", PubSubWebSocketAppDataQuery.class);
    wsIn.setUri(uri);
    PubSubWebSocketAppDataResult wsOut = dag.addOperator("QueryResult", PubSubWebSocketAppDataResult.class);
    wsOut.setUri(uri);

    // Connecting all together.
    dag.addStream("Query", wsIn.outputPort, store.query);
    dag.addStream("QueryResult", store.queryResult, wsOut.input);
    dag.addStream("InputStream", receiver.output, dimensions.input);
    dag.addStream("DimensionalData", dimensions.output, store.input);
  }
}
```

### Configuration for Sample Predefined Use Cases
The following configuration can be used for the predefined use case of the advertiser-publisher.

#### Dimensions Schema Configuration
```json
{"keys":[{"name":"advertiser","type":"string"},
         {"name":"location","type":"string"}],
 "timeBuckets":["1m","1h","1d"],
 "values":
  [{"name":"impressions","type":"long","aggregators":["SUM","MAX","MIN"]},
   {"name":"clicks","type":"long","aggregators":["SUM","MAX","MIN"]},
   {"name":"cost","type":"double","aggregators":["SUM","MAX","MIN"]},
   {"name":"revenue","type":"double","aggregators":["SUM","MAX","MIN"]}],
 "dimensions":
  [{"combination":[]},
   {"combination":["location"]},
   {"combination":["advertiser"]},
   {"combination":["advertiser","location"]}]
}
```

#### Operator Configuration

**Note:** This operator configuration is used for an application where the input data rate is high. To sustain the load, the Dimensions Computation operator is partitioned 8 times, and the queue capacity is increased.

```xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configuration>
  <property>
    <name>dt.operator.DimensionsComputation.attr.PARTITIONER</name>
    <value>com.datatorrent.common.partitioner.StatelessPartitioner:8</value>
  </property>
  <property>
    <name>dt.operator.DimensionsComputation.attr.MEMORY_MB</name>
    <value>16384</value>
  </property>
  <property>
     <name>dt.port.*.attr.QUEUE_CAPACITY</name>
     <value>32000</value>
  </property>
  <property>
    <name>dt.operator.Query.topic</name>
    <value>AdsEventQuery</value>
  </property>
  <property>
    <name>dt.operator.QueryResult.topic</name>
    <value>AdsEventQueryResult</value>
  </property>
</configuration>
```

The above operator configuration is to be used for a highly loaded application where the input rate is quite high. To sustain the load, the Dimensions Computation operator is partitioned 8 times and the queue capacity is also increased.

## Advanced Concepts

### Partitioning

The Dimensions Computation operator can be statically partitioned for higher processing throughput. This can be done by adding the following attributes in the **properties.xml** file, or in the **dt-site.xml** file.

```xml
<property>
  <name>dt.operator.DimensionsComputations.attr.PARTITIONER</name>
  <value>com.datatorrent.common.partitioner.StatelessPartitioner:8</value>
</property>
```
This adds the PARTITIONER attribute. This attribute creates a StatelessPartitioner for the DimensionsComputation operator. The parameter of ***8*** is going to partition the operator 8 times.
The StatelessPartitioner ensures that the operators are clones of each other. The tuples passed to individual clones of operators are decided based on the hashCode of the tuple.

Along with partitioned DimensionsComputation, there also comes a unifier which combines all the intermediate results from individual DimensionsComputation operators into a single stream. This stream is then passed to Dimensions Store.
Following code needs to be added in populateDAG for adding an Unifier:

```java
DimensionsComputationFlexibleSingleSchemaPOJO dimensions = dag.addOperator("DimensionsComputation", DimensionsComputationFlexibleSingleSchemaPOJO.class);
dimensions.setUnifier(new DimensionsComputationUnifierImpl<InputEvent, Aggregate>());
```

Here the unifier used is *DimensionsComputationUnifierImpl* which is an out-of-the-box operator present in the DataTorrent distribution.

## Conclusion

Aggregating huge amounts of data in real time is a major challenge that many enterprises face today. Dimension Computation provides a valuable way in which to think about the problem of aggregating data, and Data Torrent provides an implementation of of Dimension Computation that allows users to integrate data aggregation with their applications with minimal effort.


text:
int dump_hardware_xml(const char *filename)
{
    int err;
    unsigned long flags = 0; // don't show anything special
    hwloc_topology_t topology;

    err = hwloc_topology_init(&topology);
    if(err)
    {
        std::cerr << "hwloc: Failed to initialize" << std::endl;
        return 1;
    }

    err = hwloc_topology_set_flags(topology, flags);
    if(err)
    {
        std::cerr << "hwloc: Failed to set flags" << std::endl;
        return 1;
    }

    err = hwloc_topology_load (topology);
    if(err)
    {
        std::cerr << "hwloc: Failed to load topology" << std::endl;
        return 1;
    }

    err = hwloc_topology_export_xml(topology, "hardware.xml");
    if(err)
    {
        std::cerr << "hwloc: Failed to export xml" << std::endl;
        return 1;
    }

    return 0;
}

redpajama_set_name: RedPajamaGithub


text:
package wall.dao;

import java.util.List;

import wall.entity.java.BaseEntity;

public interface BaseDao<E extends BaseEntity> {
	long getCount();

	List<E> getAll();

	void save(E entity);

	void delete(long id);
}


text:
namespace WebAssembly.Instructions;

/// <summary>
/// Unsigned remainder.
/// </summary>
public class Int64RemainderUnsigned : ValueTwoToOneInstruction
{
    /// <summary>
    /// Always <see cref="OpCode.Int64RemainderUnsigned"/>.
    /// </summary>
    public sealed override OpCode OpCode => OpCode.Int64RemainderUnsigned;

    private protected sealed override WebAssemblyValueType ValueType => WebAssemblyValueType.Int64;

    private protected sealed override System.Reflection.Emit.OpCode EmittedOpCode =>
        System.Reflection.Emit.OpCodes.Rem_Un;

    /// <summary>
    /// Creates a new  <see cref="Int64RemainderUnsigned"/> instance.
    /// </summary>
    public Int64RemainderUnsigned()
    {
    }
}


text:
package com.google.android.gms.drive.internal;

import org.microg.safeparcel.AutoSafeParcelable;

public class DeleteResourceRequest extends AutoSafeParcelable {
    public static Creator<DeleteResourceRequest> CREATOR = new AutoCreator<DeleteResourceRequest>(DeleteResourceRequest.class);
}


text:
package org.apache.eagle.alert.engine.coordinator;

import java.io.IOException;

public class StreamNotDefinedException extends IOException {
    private static final long serialVersionUID = 6027811718016485808L;

    public StreamNotDefinedException() {
    }

    public StreamNotDefinedException(String streamId) {
        super("Stream definition not found: " + streamId);
    }

    public StreamNotDefinedException(String streamName, String specVersion) {
        super(String.format("Stream '%s' not found! Current spec version '%s'. Possibly metadata not loaded or metadata mismatch between upstream and alert bolts yet!", streamName, specVersion));
    }

    public StreamNotDefinedException(String streamName, String streamMetaVersion, String specVersion) {
        super(String.format("Stream '%s' has meta version '%s' which is different from current spec version '%s'.", streamName, streamMetaVersion, specVersion));
    }
}


text:
Lux
===================

Overview
-------------
This version supports BS-seq and oxBS-seq data with fixed experimental parameters. For more details, please see the main README document.

Features
-------------
Please see the main README document.

Installation
-------------
Please see the main README document.

### Generating input files
A python script **parse.py** is supplied for generating input files for the use with **Lux**.
Basically, it transforms the user-supplied data files into the data format read by CmdStan. In addition, it initializes the model parameters with values sampled from the corresponding priors

    usage: parse.py [-h] -d DATA -p PRIOR -b BSEFF [BSEFF ...] -i BSBEFF [BSBEFF ...] -o OXEFF [OXEFF ...] -s SEQERR [SEQERR ...] -pr PREFIX [-v]

    Generates data and init files in the dump format for Lux

    optional arguments:
      -h, --help                                          show this help message and exit
      -d DATA, --data DATA                                 noncontrol cytosine data
      -p PRIOR, --prior PRIOR                              prior of the noncontrol cytosines
      -b BSEFF [BSEFF ...], --bseff BSEFF [BSEFF ...]      bisulfite conversion efficiencies for each replicate
      -i BSBEFF [BSBEFF ...], --bsbeff BSBEFF [BSBEFF ...] inaccurate bisulfite conversion efficiencies for each replicate
      -o OXEFF [OXEFF ...], --oxeff OXEFF [OXEFF ...]      oxidation efficiencies for each replicate
      -s SEQERR [SEQERR ...], --seqerr SEQERR [SEQERR ...] sequencies errors for each replicate
      -pr PREFIX, --prefix PREFIX                          prefix of the output files
      -v, --version                                        show program's version number and exit

For instance, the script **parse.py** is called in the case of one sample as

    ./parse.py --data data.tsv --prior prior.tsv -b 0.99 -i 0.001 -o 0.8 -s 0.001 --prefix sample

This command will generate the two files, **sample_data.R** and **sample_init.R**, which are ready to be used in **Lux**.

As you notice **parse.py** takes two files as input, so next, we will go through their content and format in detail.

#### Noncontrol cytosines
The files **data.tsv** and **prior.tsv** have the count data and prior information on the noncontrol cytosines of interest, respectively.

Each of the cytosines has its own line in the files, and thus the files are required to have the same number of lines, moreover, the order of the cytosines is assumed to be the same in the files.

Each line in the file **data.tsv** is composed of one or more replicate-specific tab-separated blocks of four tab-separated nonnegative integers
>NBSC\tNBS\tNoxBSC\tNoxBS

That is, the number of Cs and the total BS-seq read-outs are listed first, which are followed by the number of Cs and total oxBS-seq read-outs.

Moreover, on each line there should be exactly 4×Nreplicates values separated with the tabs.

The replicate-level in the hierarchical model formulation explicitly assumes that the replicates share the same prior. Thus, the prior of μ is defined by giving the parameter α for all the noncontrol cytosines in terms of three pseudo-counts α1, α2 and α3 corresponding to p(C), p(5mC) and p(5hmC), respectively.

That is, all the lines in the file **prior.tsv** are required to have the following format
>α1\tα2\tα3

In the original publication these were α1=α2=α3=0.8 for all the noncontrol cytosines.

### References
[1] M. J. Betancourt, "Generalizing the No-U-Turn Sampler to Riemannian Manifolds," arXiv, vol. 1304, no. 1920, 2013.

[2] K. D. Hansen, B. Langmead and R. A. Irizarry, "BSmooth: from whole genome bisulfite sequencing reads to differentially methylated regions.," Genome Biol, vol. 13, no. 10, pp. R83, Oct 2012.

[3] M. D. Hoffman and A. Gelman, "The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo," Journal of Machine Learning Research, vol. in press, 2013.

[4] F. Krueger and S. R. Andrews, "Bismark: a flexible aligner and methylation caller for Bisulfite-Seq applications.," Bioinformatics, vol. 27, no. 11, pp. 1571-1572, Jun 2011.

[5] Stan Development Team, "Stan Modeling Language Users Guide and Reference Manual, Version 2.2," 2014.

[6] Stan Development Team, "Stan: A C++ Library for Probability and Sampling, Version 2.2," 2014.

[7] D. Sun, Y. Xi, B. Rodriguez, H. J. Park, P. Tong, M. Meong, M. A. Goodell and W. Li, "MOABS: model based analysis of bisulfite sequencing data.," Genome Biol, vol. 15, no. 2, pp. R38, Feb 2014.


text:
package kubernetes

import (
	"context"
	"testing"

	"github.com/coredns/coredns/plugin/etcd/msg"
	"github.com/coredns/coredns/plugin/kubernetes/object"
	"github.com/coredns/coredns/plugin/test"
	"github.com/coredns/coredns/request"

	"github.com/miekg/dns"
	api "k8s.io/api/core/v1"
	meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var extCases = []struct {
	Qname string
	Qtype uint16
	Msg   []msg.Service
	Rcode int
}{
	{
		Qname: "svc1.testns.example.org.", Rcode: dns.RcodeSuccess,
		Msg: []msg.Service{
			{Host: "1.2.3.4", Port: 80, TTL: 5, Key: "/c/org/example/testns/svc1"},
		},
	},
	{
		Qname: "svc6.testns.example.org.", Rcode: dns.RcodeSuccess,
		Msg: []msg.Service{
			{Host: "1:2::5", Port: 80, TTL: 5, Key: "/c/org/example/testns/svc1"},
		},
	},
	{
		Qname: "*._not-udp-or-tcp.svc1.testns.example.com.", Rcode: dns.RcodeSuccess,
	},
	{
		Qname: "_http._tcp.svc1.testns.example.com.", Rcode: dns.RcodeSuccess,
		Msg: []msg.Service{
			{Host: "1.2.3.4", Port: 80, TTL: 5, Key: "/c/org/example/testns/svc1"},
		},
	},
	{
		Qname: "svc0.testns.example.com.", Rcode: dns.RcodeNameError,
	},
	{
		Qname: "svc0.svc-nons.example.com.", Rcode: dns.RcodeNameError,
	},
}

func TestExternal(t *testing.T) {
	k := New([]string{"cluster.local."})
	k.APIConn = &external{}
	k.Next = test.NextHandler(dns.RcodeSuccess, nil)
	k.Namespaces = map[string]struct{}{"testns": {}}

	for i, tc := range extCases {
		state := testRequest(tc.Qname)

		svc, rcode := k.External(state)

		if x := tc.Rcode; x != rcode {
			t.Errorf("Test %d, expected rcode %d, got %d", i, x, rcode)
		}

		if len(svc) != len(tc.Msg) {
			t.Errorf("Test %d, expected %d for messages, got %d", i, len(tc.Msg), len(svc))
		}

		for j, s := range svc {
			if x := tc.Msg[j].Key; x != s.Key {
				t.Errorf("Test %d, expected key %s, got %s", i, x, s.Key)
			}
			return
		}
	}
}

type external struct{}

func (external) HasSynced() bool                                                   { return true }
func (external) Run()                                                              {}
func (external) Stop() error                                                       { return nil }
func (external) EpIndexReverse(string) []*object.Endpoints                         { return nil }
func (external) SvcIndexReverse(string) []*object.Service                          { return nil }
func (external) Modified() int64                                                   { return 0 }
func (external) EpIndex(s string) []*object.Endpoints                              { return nil }
func (external) EndpointsList() []*object.Endpoints                                { return nil }
func (external) GetNodeByName(ctx context.Context, name string) (*api.Node, error) { return nil, nil }
func (external) SvcIndex(s string) []*object.Service                               { return svcIndexExternal[s] }
func (external) PodIndex(string) []*object.Pod                                     { return nil }

func (external) GetNamespaceByName(name string) (*api.Namespace, error) {
	return &api.Namespace{
		ObjectMeta: meta.ObjectMeta{
			Name: name,
		},
	}, nil
}

var svcIndexExternal = map[string][]*object.Service{
	"svc1.testns": {
		{
			Name:        "svc1",
			Namespace:   "testns",
			Type:        api.ServiceTypeClusterIP,
			ClusterIPs:  []string{"10.0.0.1"},
			ExternalIPs: []string{"1.2.3.4"},
			Ports:       []api.ServicePort{{Name: "http", Protocol: "tcp", Port: 80}},
		},
	},
	"svc6.testns": {
		{
			Name:        "svc6",
			Namespace:   "testns",
			Type:        api.ServiceTypeClusterIP,
			ClusterIPs:  []string{"10.0.0.3"},
			ExternalIPs: []string{"1:2::5"},
			Ports:       []api.ServicePort{{Name: "http", Protocol: "tcp", Port: 80}},
		},
	},
}

func (external) ServiceList() []*object.Service {
	var svcs []*object.Service
	for _, svc := range svcIndexExternal {
		svcs = append(svcs, svc...)
	}
	return svcs
}

func testRequest(name string) request.Request {
	m := new(dns.Msg).SetQuestion(name, dns.TypeA)
	return request.Request{W: &test.ResponseWriter{}, Req: m, Zone: "example.org."}
}


text:
import React, { Component } from 'react';
import ReactDOM from "react-dom";
import { Button, FormGroup, FormControl, ControlLabel } from "react-bootstrap";
import axios from 'axios';
require('promise.prototype.finally').shim();

import './SearchBar.css';

class SearchBar extends Component {
  constructor(props) {
    super(props);
    this.state = {
      isLoading: false,
      value: ""
    };
  }

  render () {
    let isLoading = this.state.isLoading;
    return (
      <div className="spacing">
        <FormGroup>
          <ControlLabel>Type in a valid github username!</ControlLabel>
          <FormControl type="text" placeholder="Search"
            onChange={this.handleChange}
            ref={(input) => this.input = input}
          />
        </FormGroup>
        <Button
          bsStyle="primary"
          disabled={isLoading}
          onClick={!isLoading ? this.handleClick : null}>
          {isLoading ? 'Loading...' : 'Search'}
          </Button>
      </div>
    );
  }

  handleClick = (event) => {
    event.preventDefault();
    if(this.state.value.length === 0) return; // TODO: create error component.
    //start loader
    this.setState({isLoading: true});

    //make ajax request.
    axios.get(`https://api.github.com/search/users?q="${this.state.value}"`)
      .then((response) => {
        var data = response.data;
        var bestFit = data.items[0];
        if(data.total_count > 0){
          this.props.addData({
            name: bestFit.login,
            type: bestFit.type,
            url: bestFit.html_url,
            score: bestFit.score,
            site_admin: bestFit.site_admin,
            img: bestFit.avatar_url,
            id: bestFit.id
          });
        }
        else{
          this.props.addError(true, this.state.value);
        }

      })
      .catch(function (error) {
        //log message if failed
        console.log("error on get users", error);
      })
      .finally(() => {
        this.setState({isLoading: false});
      });

  }

  handleChange = (a) => {
    //TODO find a better way to bypass uncontrolled input from bootstrap-react
    this.setState({value: ReactDOM.findDOMNode(this.input).value});
  }
}

export default SearchBar;