// Gets the total number of purchases made by new users in North America & in Europe.
        // The input is the output from the AggregatePurchaseMapper job
        // In format: 'Country \t Number of Purchases \t % of the purchases made by New users' E.g. 'France	5	15.64'
        public override void Map(string inputLine, MapperContext context)
        {
            var dataRow = inputLine.Split('\t');
            if (dataRow.Count() == 3)
            {
                var country = dataRow[0];
                int numPurchases;
                double percentNew;
                if (int.TryParse(dataRow[1], out numPurchases) && double.TryParse(dataRow[2], out percentNew))
                {
                    var continent = string.Empty;
                    if (_europeanCountries.Contains(country))
                    {
                        continent = "Europe";
                        context.IncrementCounter("HitMissProgress", "EuropeanCountryFound", 1);
                    }
                    else if (_northAmericanCountries.Contains(country))
                    {
                        continent = "North America";
                        context.IncrementCounter("HitMissProgress", "NorthAmericanCountryFound", 1);
                    }

                    if (!string.IsNullOrEmpty(continent))
                    {
                        var numNewUserPurchases = Math.Round(numPurchases * percentNew / 100, 2);
                        context.EmitKeyValue(continent, numNewUserPurchases.ToString(CultureInfo.InvariantCulture));
                    }
                }
            }
        }
Exemplo n.º 2
0
        // Gets the total number of purchases made by new users in North America & in Europe.
        // The input is the output from the AggregatePurchaseMapper job
        // In format: 'Country \t Number of Purchases \t % of the purchases made by New users' E.g. 'France	5	15.64'
        public override void Map(string inputLine, MapperContext context)
        {
            var dataRow = inputLine.Split('\t');

            if (dataRow.Count() == 3)
            {
                var    country = dataRow[0];
                int    numPurchases;
                double percentNew;
                if (int.TryParse(dataRow[1], out numPurchases) && double.TryParse(dataRow[2], out percentNew))
                {
                    var continent = string.Empty;
                    if (_europeanCountries.Contains(country))
                    {
                        continent = "Europe";
                        context.IncrementCounter("HitMissProgress", "EuropeanCountryFound", 1);
                    }
                    else if (_northAmericanCountries.Contains(country))
                    {
                        continent = "North America";
                        context.IncrementCounter("HitMissProgress", "NorthAmericanCountryFound", 1);
                    }

                    if (!string.IsNullOrEmpty(continent))
                    {
                        var numNewUserPurchases = Math.Round(numPurchases * percentNew / 100, 2);
                        context.EmitKeyValue(continent, numNewUserPurchases.ToString(CultureInfo.InvariantCulture));
                    }
                }
            }
        }
        // Gets the total number of purchases in each country across the 4 days & the % of these purchases made by new users.
        // Each data row in 'clickstearm' data file is in the format...
        // 'DateTime of Hit \t ProductId \t VisitorType \t Country of Request \t Referrer \t Action'
        // E.g. 01/03/2013 18:51:31	159822	Regular	USA	Adword	Purchase
        public override void Map(string inputLine, MapperContext context)
        {
            var dataRow = inputLine.Split('\t');
            if (dataRow.Count() == 6)
            {
                var visitorType = dataRow[2];
                var country = dataRow[3];
                var action = dataRow[5];

                if (action == "Purchase")
                {
                    context.IncrementCounter("HitMissProgress", "PurchaseFound", 1);
                    context.EmitKeyValue(country, visitorType);
                }
                context.IncrementCounter("HitMissProgress", "PurchaseNotFound", 1);
            }
        }
Exemplo n.º 4
0
            };                                                                                    //ascii 58--64 + misc.

            public override void Map(string inputLine, MapperContext context)
            {
                foreach (string word in inputLine.Trim().Split(this._punctuationChars))
                {
                    context.IncrementCounter("mapInputs");
                    context.Log(string.Format("Map::  {0},{1}", word, "1"));
                    context.EmitKeyValue(word, "1");
                }
            }
Exemplo n.º 5
0
        // Gets the total number of purchases in each country across the 4 days & the % of these purchases made by new users.
        // Each data row in 'clickstearm' data file is in the format...
        // 'DateTime of Hit \t ProductId \t VisitorType \t Country of Request \t Referrer \t Action'
        // E.g. 01/03/2013 18:51:31	159822	Regular	USA	Adword	Purchase
        public override void Map(string inputLine, MapperContext context)
        {
            var dataRow = inputLine.Split('\t');

            if (dataRow.Count() == 6)
            {
                var visitorType = dataRow[2];
                var country     = dataRow[3];
                var action      = dataRow[5];

                if (action == "Purchase")
                {
                    context.IncrementCounter("HitMissProgress", "PurchaseFound", 1);
                    context.EmitKeyValue(country, visitorType);
                }
                context.IncrementCounter("HitMissProgress", "PurchaseNotFound", 1);
            }
        }
        public override void Map(string inputLine, MapperContext context)
        {
            //example input: Hello, Andy
            if (!inputLine.StartsWith("Hello, "))
            {
                context.Log(string.Format("The inputLine {0} is not in the correct format", inputLine));
                context.IncrementCounter("RecoverableError", "InputFormatIncorrect", 1);
                return;
            }

            var key = inputLine.Substring(7);
            if (key.EndsWith(".")) key = key.Trim('.');

            context.EmitKeyValue(key, "1");//we are going to count instances, the value is irrelevant
        }
        public override void Map(string inputLine, MapperContext context)
        {
            //example input: Hello, Andy
            if (!inputLine.StartsWith("Hello, "))
            {
                context.Log(string.Format("The inputLine {0} is not in the correct format", inputLine));
                context.IncrementCounter("RecoverableError", "InputFormatIncorrect", 1);
                return;
            }

            var key = inputLine.Substring(7);

            if (key.EndsWith("."))
            {
                key = key.Trim('.');
            }

            context.EmitKeyValue(key, "1");//we are going to count instances, the value is irrelevant
        }