Example #1
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void Close()
 {
     inBuf.Close();
     outBuf.Close();
     deserializer.Close();
     serializer.Close();
 }
Example #2
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void Close()
 {
     keySerializer.Close();
     valueSerializer.Close();
     WritableUtils.WriteVInt(outputStream, IFile.EofMarker);
     WritableUtils.WriteVInt(outputStream, IFile.EofMarker);
     outputStream.Close();
 }
Example #3
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void Close()
 {
     // When IFile writer is created by BackupStore, we do not have
     // Key and Value classes set. So, check before closing the
     // serializers
     if (keyClass != null)
     {
         keySerializer.Close();
         valueSerializer.Close();
     }
     // Write EOF_MARKER for key/value length
     WritableUtils.WriteVInt(@out, EofMarker);
     WritableUtils.WriteVInt(@out, EofMarker);
     decompressedBytesWritten += 2 * WritableUtils.GetVIntSize(EofMarker);
     //Flush the stream
     @out.Flush();
     if (compressOutput)
     {
         // Flush
         compressedOut.Finish();
         compressedOut.ResetState();
     }
     // Close the underlying stream iff we own it...
     if (ownOutputStream)
     {
         @out.Close();
     }
     else
     {
         // Write the checksum
         checksumOut.Finish();
     }
     compressedBytesWritten = rawOut.GetPos() - start;
     if (compressOutput)
     {
         // Return back the compressor
         CodecPool.ReturnCompressor(compressor);
         compressor = null;
     }
     @out = null;
     if (writtenRecordsCounter != null)
     {
         writtenRecordsCounter.Increment(numRecordsWritten);
     }
 }
Example #4
0
            /// <exception cref="System.IO.IOException"/>
            private E MakeCopyForPassByValue <E>(Serialization <E> serialization, E obj)
            {
                Org.Apache.Hadoop.IO.Serializer.Serializer <E> ser = serialization.GetSerializer(GenericsUtil
                                                                                                 .GetClass(obj));
                Deserializer <E> deser = serialization.GetDeserializer(GenericsUtil.GetClass(obj));
                DataOutputBuffer dof   = this._enclosing.threadLocalDataOutputBuffer.Get();

                dof.Reset();
                ser.Open(dof);
                ser.Serialize(obj);
                ser.Close();
                obj = ReflectionUtils.NewInstance(GenericsUtil.GetClass(obj), this._enclosing.GetChainJobConf
                                                      ());
                ByteArrayInputStream bais = new ByteArrayInputStream(dof.GetData(), 0, dof.GetLength
                                                                         ());

                deser.Open(bais);
                deser.Deserialize(obj);
                deser.Close();
                return(obj);
            }
        /// <exception cref="System.Exception"/>
        private K SerDeser <K>(K conf)
        {
            SerializationFactory factory = new SerializationFactory(Conf);

            Org.Apache.Hadoop.IO.Serializer.Serializer <K> serializer = factory.GetSerializer(
                GenericsUtil.GetClass(conf));
            Deserializer <K> deserializer = factory.GetDeserializer(GenericsUtil.GetClass(conf
                                                                                          ));
            DataOutputBuffer @out = new DataOutputBuffer();

            serializer.Open(@out);
            serializer.Serialize(conf);
            serializer.Close();
            DataInputBuffer @in = new DataInputBuffer();

            @in.Reset(@out.GetData(), @out.GetLength());
            deserializer.Open(@in);
            K after = deserializer.Deserialize(null);

            deserializer.Close();
            return(after);
        }