C# and F# language binding and extensions to Apache Spark
Перейти к файлу
Tao Qin a4a3486f01 Merge pull request #359 from qintao1976/dev
In MultiThreadWorker mode, does not let the whole worker process exit when some TaskRunner fails
2016-03-25 09:43:36 +08:00
build Implement a Daemon process to take charge of launching Worker processes 2016-03-24 16:24:02 +08:00
csharp Minor change to improve log info in worker 2016-03-24 16:19:31 +08:00
dev/scripts change nuget package version number for pre release build 2016-03-03 14:25:47 +08:00
docs replacing references to SparkCLR after repo rename 2016-03-07 11:42:07 -08:00
examples Address review comments 2016-03-03 14:20:50 -08:00
logo Rename clear to white and white to clear for 100px logos 2016-01-11 17:38:33 -08:00
notes replacing references to SparkCLR after repo rename 2016-03-07 11:42:07 -08:00
scala Make the name of 'referesh-offsets' thread unique for different DynamicPartitionKafkaInputDStream instances 2016-03-22 21:10:33 +08:00
scripts updating sparkclr jar version 2016-03-18 22:26:53 -07:00
.gitattributes Add standard .gitattributes file, to avoid line ending problems. 2015-11-05 11:06:08 -08:00
.gitignore Fix .gitignore to match new directory structure 2016-01-15 20:58:21 -08:00
.travis.yml move run-samples.sh to "localmode" 2016-01-14 13:06:13 -08:00
LICENSE initial commit 2015-10-29 15:27:15 -07:00
README.md fixing Twitter link 2016-03-21 23:06:52 -07:00
appveyor.yml upgrade to Spark 1.6.1 2016-03-18 21:55:02 -07:00

README.md

Mobius: C# API for Spark

Mobius adds C# language binding to Apache Spark, enabling the implementation of Spark driver code and data processing operations in C#.

For example, the word count sample in Apache Spark can be implemented in C# as follows :

var lines = sparkContext.TextFile(@"hdfs://path/to/input.txt");  
var words = lines.FlatMap(s => s.Split(' '));
var wordCounts = words.Map(w => new KeyValuePair<string, int>(w.Trim(), 1))  
                      .ReduceByKey((x, y) => x + y);  
var wordCountCollection = wordCounts.Collect();  
wordCounts.SaveAsTextFile(@"hdfs://path/to/wordcount.txt");  

A simple DataFrame application using TempTable may look like the following:

var reqDataFrame = sqlContext.TextFile(@"hdfs://path/to/requests.csv");
var metricDataFrame = sqlContext.TextFile(@"hdfs://path/to/metrics.csv");
reqDataFrame.RegisterTempTable("requests");
metricDataFrame.RegisterTempTable("metrics");
// C0 - guid in requests DataFrame, C3 - guid in metrics DataFrame  
var joinDataFrame = GetSqlContext().Sql(  
    "SELECT joinedtable.datacenter" +
         ", MAX(joinedtable.latency) maxlatency" +
         ", AVG(joinedtable.latency) avglatency " + 
    "FROM (" +
       "SELECT a.C1 as datacenter, b.C6 as latency " +  
       "FROM requests a JOIN metrics b ON a.C0  = b.C3) joinedtable " +   
    "GROUP BY datacenter");
joinDataFrame.ShowSchema();
joinDataFrame.Show();

A simple DataFrame application using DataFrame DSL may look like the following:

// C0 - guid, C1 - datacenter
var reqDataFrame = sqlContext.TextFile(@"hdfs://path/to/requests.csv")  
                             .Select("C0", "C1");    
// C3 - guid, C6 - latency   
var metricDataFrame = sqlContext.TextFile(@"hdfs://path/to/metrics.csv", ",", false, true)
                                .Select("C3", "C6"); //override delimiter, hasHeader & inferSchema
var joinDataFrame = reqDataFrame.Join(metricDataFrame, reqDataFrame["C0"] == metricDataFrame["C3"])
                                .GroupBy("C1");
var maxLatencyByDcDataFrame = joinDataFrame.Agg(new Dictionary<string, string> { { "C6", "max" } });
maxLatencyByDcDataFrame.ShowSchema();
maxLatencyByDcDataFrame.Show();

Refer to Mobius\csharp\Samples directory and sample usage for complete samples.

API Documentation

Refer to Mobius C# API documentation for the list of Spark's data processing operations supported in Mobius.

API Usage

Mobius API usage samples are available at:

  • Samples project which uses a comprehensive set of Mobius APIs to implement samples that are also used for functional validation of APIs

  • Examples folder which contains standalone C# projects that can be used as templates to start developing Mobius applications

  • Performance test scenarios implemented in C# and Scala for side by side comparison of Spark driver code

Documents

Refer to the docs folder for design overview and other info on Mobius

Build Status

Ubuntu 14.04.3 LTS Windows Unit test coverage
Build status Build status codecov.io

Getting Started

Windows Linux
Build & run unit tests windows-instructions.md linux-instructions.md
Run samples (functional tests) in local mode windows-instructions.md linux-instructions.md
Run examples in local mode running-mobius-app.md running-mobius-app.md
Run Mobius app in standalone cluster running-mobius-app.md running-mobius-app.md
Run Mobius app in YARN cluster running-mobius-app.md running-mobius-app.md

Note: Refer to linux-compatibility.md for using Mobius with Spark on Linux

Supported Spark Versions

Mobius is built and tested with Spark 1.4.1, Spark 1.5.2 and Spark 1.6.0.

Releases

https://github.com/Microsoft/Mobius/releases

Nuget

License

License

Mobius is licensed under the MIT license. See LICENSE file for full license information.

Community

Issue Stats Issue Stats Join the chat at https://gitter.im/Microsoft/Mobius [Twitter](https://twitter.com/intent/tweet?text=@MobiusForSpark [your tweet] via @GitHub)