Пример #1
0
            /// <summary>
            /// Combine InputSplits from child InputFormats into a
            /// <see cref="CompositeInputSplit"/>
            /// .
            /// </summary>
            /// <exception cref="System.IO.IOException"/>
            public override InputSplit[] GetSplits(JobConf job, int numSplits)
            {
                InputSplit[][] splits = new InputSplit[kids.Count][];
                for (int i = 0; i < kids.Count; ++i)
                {
                    InputSplit[] tmp = kids[i].GetSplits(job, numSplits);
                    if (null == tmp)
                    {
                        throw new IOException("Error gathering splits from child RReader");
                    }
                    if (i > 0 && splits[i - 1].Length != tmp.Length)
                    {
                        throw new IOException("Inconsistent split cardinality from child " + i + " (" + splits
                                              [i - 1].Length + "/" + tmp.Length + ")");
                    }
                    splits[i] = tmp;
                }
                int size = splits[0].Length;

                CompositeInputSplit[] ret = new CompositeInputSplit[size];
                for (int i_1 = 0; i_1 < size; ++i_1)
                {
                    ret[i_1] = new CompositeInputSplit(splits.Length);
                    for (int j = 0; j < splits.Length; ++j)
                    {
                        ret[i_1].Add(splits[j][i_1]);
                    }
                }
                return(ret);
            }
Пример #2
0
            /// <exception cref="System.IO.IOException"/>
            public override ComposableRecordReader GetRecordReader(InputSplit split, JobConf
                                                                   job, Reporter reporter)
            {
                // child types unknowable
                if (!(split is CompositeInputSplit))
                {
                    throw new IOException("Invalid split type:" + split.GetType().FullName);
                }
                CompositeInputSplit spl   = (CompositeInputSplit)split;
                int capacity              = kids.Count;
                CompositeRecordReader ret = null;

                try
                {
                    if (!rrCstrMap.Contains(ident))
                    {
                        throw new IOException("No RecordReader for " + ident);
                    }
                    ret = (CompositeRecordReader)rrCstrMap[ident].NewInstance(id, job, capacity, cmpcl
                                                                              );
                }
                catch (MemberAccessException e)
                {
                    throw (IOException)Sharpen.Extensions.InitCause(new IOException(), e);
                }
                catch (InstantiationException e)
                {
                    throw (IOException)Sharpen.Extensions.InitCause(new IOException(), e);
                }
                catch (TargetInvocationException e)
                {
                    throw (IOException)Sharpen.Extensions.InitCause(new IOException(), e);
                }
                for (int i = 0; i < capacity; ++i)
                {
                    ret.Add(kids[i].GetRecordReader(spl.Get(i), job, reporter));
                }
                return((ComposableRecordReader)ret);
            }