void IDriver.Run() { var inputArray = new[] { "Hello, Andy", "Hello, andy", "Hello, why doesn't this work!", "Hello, Andy", "Hello, chickenface", "Hello, Andy" }; var output = StreamingUnit.Execute <WCMapper, WCReducer>(inputArray); Console.WriteLine("Mapper Result"); foreach (var mapperResult in output.MapperResult) { Console.WriteLine(mapperResult); } Console.WriteLine("************************"); Console.WriteLine("Reducer Result"); foreach (var reducerResult in output.ReducerResult) { Console.WriteLine(reducerResult); } Console.WriteLine("************************"); Console.ReadLine(); }
static void Main(string[] args) { var inputArray = new[] { "Hello, Andy", "Hello, andy", "Hello, why doesn't this work!", "Hello, Andy", "Hello, chickenface", "Hello, Andy" }; var output = StreamingUnit.Execute <HelloWorldMapper, HelloWorldReducer>(inputArray); Console.WriteLine("Map"); foreach (var mapperResult in output.MapperResult) { Console.WriteLine(mapperResult); } Console.WriteLine("Reduce"); foreach (var reducerResult in output.ReducerResult) { Console.WriteLine(reducerResult); } Console.ReadLine(); }
public void AggregatePurchaseMapper_ViewProduct_NoDataEmitted() { //arrange const string inputLine = "04/03/2013 14:21:27 199472 New USA Adword View Product"; //act var actualOutput = StreamingUnit.Execute <AggregatePurchaseMapper>(new string[] { inputLine }); //assert Assert.IsTrue(actualOutput.MapperResult.Count == 0); }
public void AggregatePurchaseMapper_BadDataWithTimestampMissing_NoDataEmitted() { //arrange const string inputLine = "199472 New USA Adword View Product"; //act var actualOutput = StreamingUnit.Execute <AggregatePurchaseMapper>(new string[] { inputLine }); //assert Assert.IsTrue(actualOutput.MapperResult.Count == 0); }
public static void _Mapper() { const string inputline = "ID::585304696325328896 Text::The Easter rush has passed and I can function like a normal human being again. #ILoveBeingALineCook #Kinda Time::2015-04-06 9:54:48 PM Lattitude::32.745723 Longitude::-80.045119"; var actualOutput = StreamingUnit.Execute <Mapper>(new[] { inputline }); //assert //var mapperResult = actualOutput.MapperResult; Console.WriteLine("Map"); foreach (var mapperResult in actualOutput.MapperResult) { Console.WriteLine(mapperResult); } }
public void ContinentMapper_PurchaseOnGermanSite_ResultForGermany() { //arrange const string inputLine = "USA 10 50"; //act var actualOutput = StreamingUnit.Execute <NewUserPurchasesByContinentMapper>(new string[] { inputLine }); //assert var mapperResult = actualOutput.MapperResult.Single().Split('\t'); Assert.AreEqual("North America", mapperResult[0]); // The Streaming unit emits the key as the first tab separated value in the MapperResult Assert.AreEqual("5", mapperResult[1]); }
public void ContinentMapper_ViewProduct_NoDataEmitted() { //arrange const string inputLine = "France 5 20"; //act var actualOutput = StreamingUnit.Execute <NewUserPurchasesByContinentMapper>(new string[] { inputLine }); //assert var mapperResult = actualOutput.MapperResult.Single().Split('\t'); Assert.AreEqual("Europe", mapperResult[0]); Assert.AreEqual("1", mapperResult[1]); }
public static void _Reducer() { const string neutralInputLine = "ID::585304696325328896 Text::The Easter rush has passed and I can function like a normal human being again. #ILoveBeingALineCook #Kinda Time::2015-04-06 9:54:48 PM Lattitude::32.745723 Longitude::-80.045119"; const string positiveInputLine1 = "ID::585305245741293568 Text::Nasty Easter joke...LMFAO!!! Brilliant... Time::2015-04-06 9:56:59 PM Lattitude::34.10362 Longitude::-118.326781"; const string positiveInputLine2 = "ID::585305558930104320 Text::I am happy I was in the camp with JPM chief economist on this no cut call and playing GBPAUD short was the Easter bonus. Time::2015-04-06 9:58:14 PM Lattitude::51.525835 Longitude::-0.569526"; var actualOutput = StreamingUnit.Execute <Mapper, Reducer>( new[] { neutralInputLine, positiveInputLine1, positiveInputLine2 }); Console.WriteLine("Reduce"); foreach (var reducerResult in actualOutput.ReducerResult) { Console.WriteLine(reducerResult); } }
public void AggregatePurchaseMapper_ViewProduct_NoDataEmitted() { //arrange const string inputLine = "62 328 3 879371909"; //act var actualOutput = StreamingUnit.Execute <MovieLensMapper>(new string[] { inputLine }); //assert var result = actualOutput.MapperResult.Single().Split('\t'); Assert.AreEqual("328", result[0]); Assert.AreEqual("879371909", result[1]); Assert.AreEqual("3", result[2]); }
private static void RunUsingStreamingUnit() { using (var reader = new StreamReader(@"../../../clickStream.log")) { string sample = reader.ReadToEnd(); StreamingUnitOutput output = StreamingUnit.Execute <AggregatePurchaseMapper, AggregatePurchaseReducer>(sample.Split(new[] { '\r', '\n' })); foreach (string result in output.ReducerResult) { Console.WriteLine(result); } Console.ReadLine(); } }
private static void RunUsingStreamingUnit() { using (var reader = new StreamReader(@"../../ua.base")) { string sample = reader.ReadToEnd(); StreamingUnitOutput output = StreamingUnit.Execute <MovieLensMapper>(sample.Split(new[] { '\r', '\n' })); const string path = "C:\\Data\\MovieLensData.log"; File.WriteAllLines(path, Enumerable.ToArray(output.MapperResult)); Console.WriteLine("Written to {0}", path); Console.ReadLine(); } }
public void AggregatePurchaseMapper_PurchaseOnUSASite_ResultForUSA() { //arrange // Define a tab separated row of data for a purchase in Germany by a new user const string inputLine = "01/03/2013 11:30:08 155990 New USA Adword Purchase"; //act var actualOutput = StreamingUnit.Execute <AggregatePurchaseMapper>(new[] { inputLine }); //assert var mapperResult = actualOutput.MapperResult.Single().Split('\t'); // NB: The Streaming unit emits the key as the first tab separated value in the MapperResult Assert.AreEqual("USA", mapperResult[0]); Assert.AreEqual("New", mapperResult[1]); }
public void AggregatePurchaseMapper_PurchaseOnGermanSite_ResultForGermany() { //arrange // Define a tab separated row of data for a purchase in Germany by a new user const string inputLine = "04/03/2013 12:17:36 193902 New Germany No Referrer Purchase"; //act var actualOutput = StreamingUnit.Execute <AggregatePurchaseMapper>(new[] { inputLine }); //assert var mapperResult = actualOutput.MapperResult.Single().Split('\t'); // NB: The Streaming unit emits the key as the first tab separated value in the MapperResult Assert.AreEqual("Germany", mapperResult[0]); Assert.AreEqual("New", mapperResult[1]); }
public void AggregatePurchaseReducer_TwoPurchasesUSAOneNewUser_50percentFigureEmitted() { // arrange const string newUserinputLine = "01/04/2013 14:21:27 199572 New USA Adword Purchase"; const string regularUserinputLine = "01/04/2013 14:26:27 399572 Regular USA Organic Search Purchase"; const string infrequentInputLine = "01/04/2013 15:21:27 369572 Infrequent France Adword Purchase"; //act var actualOutput = StreamingUnit.Execute <AggregatePurchaseMapper, AggregatePurchaseReducer>( new [] { newUserinputLine, regularUserinputLine, infrequentInputLine }); //assert var reducerResult = actualOutput.ReducerResult.Single(v => v.Split('\t')[0] == "USA").Split('\t'); Assert.AreEqual("2", reducerResult[1]); // Checking that the number of purchases for USA was 2 Assert.AreEqual("50", reducerResult[2]); // Checking that 50% of purchases for USA were from new visitors }
private StreamingUnitOutput run(string[] data) { return(StreamingUnit.Execute <LoveCleanStreetsMapper, LoveCleanStreetsReducer>(data)); }