/// <summary>write the boolean value</summary>
        /// <exception cref="System.IO.IOException"/>
        internal static void WriteBoolean(bool value, DataOutputStream @out)
        {
            BooleanWritable uBoolean = TlData.Get().UBoolean;

            uBoolean.Set(value);
            uBoolean.Write(@out);
        }
        /// <summary>read the boolean value</summary>
        /// <exception cref="System.IO.IOException"/>
        internal static bool ReadBoolean(DataInput @in)
        {
            BooleanWritable uBoolean = TlData.Get().UBoolean;

            uBoolean.ReadFields(@in);
            return(uBoolean.Get());
        }
Exemple #3
0
        public virtual void TestPipesReduser()
        {
            FilePath[] psw  = CleanTokenPasswordFile();
            JobConf    conf = new JobConf();

            try
            {
                Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier> token = new Org.Apache.Hadoop.Security.Token.Token
                                                                                     <AMRMTokenIdentifier>(Sharpen.Runtime.GetBytesForString("user"), Sharpen.Runtime.GetBytesForString
                                                                                                               ("password"), new Text("kind"), new Text("service"));
                TokenCache.SetJobToken(token, conf.GetCredentials());
                FilePath fCommand = GetFileCommand("org.apache.hadoop.mapred.pipes.PipeReducerStub"
                                                   );
                conf.Set(MRJobConfig.CacheLocalfiles, fCommand.GetAbsolutePath());
                PipesReducer <BooleanWritable, Text, IntWritable, Text> reducer = new PipesReducer
                                                                                  <BooleanWritable, Text, IntWritable, Text>();
                reducer.Configure(conf);
                BooleanWritable bw = new BooleanWritable(true);
                conf.Set(MRJobConfig.TaskAttemptId, taskName);
                InitStdOut(conf);
                conf.SetBoolean(MRJobConfig.SkipRecords, true);
                TestPipeApplication.CombineOutputCollector <IntWritable, Text> output = new TestPipeApplication.CombineOutputCollector
                                                                                        <IntWritable, Text>(this, new Counters.Counter(), new TestPipeApplication.Progress
                                                                                                                (this));
                Reporter     reporter = new TestPipeApplication.TestTaskReporter(this);
                IList <Text> texts    = new AList <Text>();
                texts.AddItem(new Text("first"));
                texts.AddItem(new Text("second"));
                texts.AddItem(new Text("third"));
                reducer.Reduce(bw, texts.GetEnumerator(), output, reporter);
                reducer.Close();
                string stdOut = ReadStdOut(conf);
                // test data: key
                NUnit.Framework.Assert.IsTrue(stdOut.Contains("reducer key :true"));
                // and values
                NUnit.Framework.Assert.IsTrue(stdOut.Contains("reduce value  :first"));
                NUnit.Framework.Assert.IsTrue(stdOut.Contains("reduce value  :second"));
                NUnit.Framework.Assert.IsTrue(stdOut.Contains("reduce value  :third"));
            }
            finally
            {
                if (psw != null)
                {
                    // remove password files
                    foreach (FilePath file in psw)
                    {
                        file.DeleteOnExit();
                    }
                }
            }
        }
 /// <summary>Accumulate number of points inside/outside results from the mappers.</summary>
 /// <param name="isInside">Is the points inside?</param>
 /// <param name="values">An iterator to a list of point counts</param>
 /// <param name="context">dummy, not used here.</param>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 protected override void Reduce(BooleanWritable isInside, IEnumerable <LongWritable
                                                                       > values, Reducer.Context context)
 {
     if (isInside.Get())
     {
         foreach (LongWritable val in values)
         {
             numInside += val.Get();
         }
     }
     else
     {
         foreach (LongWritable val in values)
         {
             numOutside += val.Get();
         }
     }
 }
 public virtual void BinaryProtocolStub()
 {
     try
     {
         InitSoket();
         //should be 5
         //RUN_REDUCE boolean
         WritableUtils.ReadVInt(dataInput);
         WritableUtils.ReadVInt(dataInput);
         int intValue = WritableUtils.ReadVInt(dataInput);
         System.Console.Out.WriteLine("getIsJavaRecordWriter:" + intValue);
         // reduce key
         WritableUtils.ReadVInt(dataInput);
         // value of reduce key
         BooleanWritable value = new BooleanWritable();
         ReadObject(value, dataInput);
         System.Console.Out.WriteLine("reducer key :" + value);
         // reduce value code:
         // reduce values
         while ((intValue = WritableUtils.ReadVInt(dataInput)) == 7)
         {
             Text txt = new Text();
             // value
             ReadObject(txt, dataInput);
             System.Console.Out.WriteLine("reduce value  :" + txt);
         }
         // done
         WritableUtils.WriteVInt(dataOut, 54);
         dataOut.Flush();
         dataOut.Close();
     }
     catch (Exception x)
     {
         Sharpen.Runtime.PrintStackTrace(x);
     }
     finally
     {
         CloseSoket();
     }
 }
 private bool CheckHashCode(BooleanWritable f, BooleanWritable s)
 {
     return(f.GetHashCode() == s.GetHashCode());
 }