/// <exception cref="System.IO.IOException"/>
 public virtual bool Next(K key, V value)
 {
     lock (this)
     {
         if (!more)
         {
             return(false);
         }
         long pos       = @in.GetPosition();
         bool remaining = (@in.Next(key) != null);
         if (remaining)
         {
             GetCurrentValue(value);
         }
         if (pos >= end && @in.SyncSeen())
         {
             more = false;
         }
         else
         {
             more = remaining;
         }
         return(more);
     }
 }
Ejemplo n.º 2
0
 /// <summary>Read raw bytes from a SequenceFile.</summary>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 public override bool NextKeyValue()
 {
     lock (this)
     {
         if (done)
         {
             return(false);
         }
         long pos = @in.GetPosition();
         bool eof = -1 == @in.NextRawKey(buffer);
         if (!eof)
         {
             if (key == null)
             {
                 key = new BytesWritable();
             }
             if (value == null)
             {
                 value = new BytesWritable();
             }
             key.Set(buffer.GetData(), 0, buffer.GetLength());
             buffer.Reset();
             @in.NextRawValue(vbytes);
             vbytes.WriteUncompressedBytes(buffer);
             value.Set(buffer.GetData(), 0, buffer.GetLength());
             buffer.Reset();
         }
         return(!(done = (eof || (pos >= end && @in.SyncSeen()))));
     }
 }
        /// <exception cref="System.IO.IOException"/>
        public SequenceFileRecordReader(Configuration conf, FileSplit split)
        {
            Path       path = split.GetPath();
            FileSystem fs   = path.GetFileSystem(conf);

            this.@in  = new SequenceFile.Reader(fs, path, conf);
            this.end  = split.GetStart() + split.GetLength();
            this.conf = conf;
            if (split.GetStart() > @in.GetPosition())
            {
                @in.Sync(split.GetStart());
            }
            // sync to start
            this.start = @in.GetPosition();
            more       = start < end;
        }
Ejemplo n.º 4
0
            /// <exception cref="System.IO.IOException"/>
            public SequenceFileAsBinaryRecordReader(Configuration conf, FileSplit split)
            {
                Path       path = split.GetPath();
                FileSystem fs   = path.GetFileSystem(conf);

                this.@in = new SequenceFile.Reader(fs, path, conf);
                this.end = split.GetStart() + split.GetLength();
                if (split.GetStart() > @in.GetPosition())
                {
                    @in.Sync(split.GetStart());
                }
                // sync to start
                this.start = @in.GetPosition();
                vbytes     = @in.CreateValueBytes();
                done       = start >= end;
            }
Ejemplo n.º 5
0
            /// <exception cref="System.IO.IOException"/>
            /// <exception cref="System.Exception"/>
            public override void Initialize(InputSplit split, TaskAttemptContext context)
            {
                Path          path = ((FileSplit)split).GetPath();
                Configuration conf = context.GetConfiguration();
                FileSystem    fs   = path.GetFileSystem(conf);

                this.@in = new SequenceFile.Reader(fs, path, conf);
                this.end = ((FileSplit)split).GetStart() + split.GetLength();
                if (((FileSplit)split).GetStart() > @in.GetPosition())
                {
                    @in.Sync(((FileSplit)split).GetStart());
                }
                // sync to start
                this.start = @in.GetPosition();
                vbytes     = @in.CreateValueBytes();
                done       = start >= end;
            }
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        public override void Initialize(InputSplit split, TaskAttemptContext context)
        {
            FileSplit fileSplit = (FileSplit)split;

            conf = context.GetConfiguration();
            Path       path = fileSplit.GetPath();
            FileSystem fs   = path.GetFileSystem(conf);

            this.@in = new SequenceFile.Reader(fs, path, conf);
            this.end = fileSplit.GetStart() + fileSplit.GetLength();
            if (fileSplit.GetStart() > @in.GetPosition())
            {
                @in.Sync(fileSplit.GetStart());
            }
            // sync to start
            this.start = @in.GetPosition();
            more       = start < end;
        }
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        public override bool NextKeyValue()
        {
            if (!more)
            {
                return(false);
            }
            long pos = @in.GetPosition();

            key = (K)@in.Next(key);
            if (key == null || (pos >= end && @in.SyncSeen()))
            {
                more  = false;
                key   = null;
                value = null;
            }
            else
            {
                value = (V)@in.GetCurrentValue(value);
            }
            return(more);
        }
Ejemplo n.º 8
0
 /// <summary>Read raw bytes from a SequenceFile.</summary>
 /// <exception cref="System.IO.IOException"/>
 public virtual bool Next(BytesWritable key, BytesWritable val)
 {
     lock (this)
     {
         if (done)
         {
             return(false);
         }
         long pos = @in.GetPosition();
         bool eof = -1 == @in.NextRawKey(buffer);
         if (!eof)
         {
             key.Set(buffer.GetData(), 0, buffer.GetLength());
             buffer.Reset();
             @in.NextRawValue(vbytes);
             vbytes.WriteUncompressedBytes(buffer);
             val.Set(buffer.GetData(), 0, buffer.GetLength());
             buffer.Reset();
         }
         return(!(done = (eof || (pos >= end && @in.SyncSeen()))));
     }
 }