Reads a stream blob from a stream from the serialized row.
181263
@Override
  void readStreamBlob(InputStream is, 
                      byte[] buffer, int offset, RowCursor cursor)
    throws IOException
  {
    int len = BitsUtil.readInt(is);

    if (len == 0) {
      BitsUtil.writeInt(buffer, offset + offset(), 0);
      return;
    }
    
    try (BlobOutputStream blob = openOutputStream(cursor)) {
      while (len > 0) {
        boolean isNext = (len & BLOB_CONT_MASK) != 0;
        len &= ~BLOB_CONT_MASK;
        
        blob.writeFromStream(is, len);
        
        if (isNext) {
          len = BitsUtil.readInt(is);
        }
        else {
          len = 0;
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
      
      throw e;
    }
    
    if (len < 0) {
      throw new IOException(L.l("Unexpected end of file while reading {0}", this));
    }

    //cursor.setBlob(getIndex(), blob);
  }
430126
public int read(byte []buffer, int offset, int length)
    throws IOException
  {
    return _stream.read(buffer, offset, length);
  }
1191535
protected void doReadObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
        final GetField readFields = stream.readFields();

        for (final String fieldName : getFieldNamesInAdditionToId()) {
            final Object value = readFields.get(fieldName, null);
            setField(fieldName, value);
        }

        // fix issue of deserializing _rowNumber in it's previous int form
        final long rowNumber;
        final ObjectStreamField legacyRowNumberField =
                readFields.getObjectStreamClass().getField(getFieldNameForOldId());
        if (legacyRowNumberField != null) {
            rowNumber = readFields.get(getFieldNameForOldId(), -1);
        } else {
            rowNumber = readFields.get(getFieldNameForNewId(), -1L);
        }

        setField(getFieldNameForNewId(), rowNumber);
    }
451178
def extract_chunks(blob):
    """"""
    chunks = []
    stream = BytesIO(blob.bytes)
    current_pos = stream.tell()
    stream.seek(0, 2)
    length = stream.tell()
    stream.seek(current_pos, 0)
    while stream.tell() < length:
        chunks.append(read_chunk(stream))

    return chunks
259481
def _read_bytes(self, b):
        
        _LOGGER.debug("%d bytes requested from stream with content type: %s", b, self.content_type)
        if 0 <= b <= len(self.output_buffer) or self.__message_complete:
            _LOGGER.debug("No need to read from source stream or source stream closed")
            return

        if self.content_type == ContentType.FRAMED_DATA:
            _LOGGER.debug("Reading to framed body")
            self.output_buffer += self._read_bytes_to_framed_body(b)
        elif self.content_type == ContentType.NO_FRAMING:
            _LOGGER.debug("Reading to non-framed body")
            self.output_buffer += self._read_bytes_to_non_framed_body(b)
        else:
            raise NotSupportedError("Unsupported content type")

        # To maintain backwards compatibility, only enforce this if a CMM is provided by the caller.
        if self.config.key_provider is None and self.config.source_length is not None:
            # Enforce that if the caller provided a source length value, the total bytes encrypted
            # must not exceed that value.
            if self._bytes_encrypted > self.config.source_length:
                raise CustomMaximumValueExceeded(
                    "Bytes encrypted has exceeded stated source length estimate:\n{actual:d} > {estimated:d}".format(
                        actual=self._bytes_encrypted, estimated=self.config.source_length
                    )
                )
1076151
public Object fromStream(final byte[] iStream) throws IOException {
		if (iStream == null || iStream.length == 0)
			// NULL VALUE
			return null;

		final ByteArrayInputStream is = new ByteArrayInputStream(iStream);
		final ObjectInputStream in = new ObjectInputStream(is);
		try {
			return in.readObject();
		} catch (ClassNotFoundException e) {
			throw new OSerializationException("Cannot unmarshall Java serialized object", e);
		} finally {
			in.close();
			is.close();
		}
	}
1250572
def FromStream(cls, stream, auto_transfer=True, total_size=None, **kwds):
        """"""
        return cls(stream, auto_transfer=auto_transfer, total_size=total_size,
                   **kwds)
323652
protected long readFromByteArray(OutputStream stream, long length, long position) throws IOException
   {
      byte[] data = getAsByteArray();
      length = validateAndAdjustLenght(length, position, data.length);

      stream.write(data, (int)position, (int)length);

      return length;
   }
779732
def _deserialize(self, stream):
        """"""
        readline = stream.readline
        self.tree = Tree(self.repo, hex_to_bin(readline().split()[1]), Tree.tree_id << 12, '')

        self.parents = []
        next_line = None
        while True:
            parent_line = readline()
            if not parent_line.startswith(b'parent'):
                next_line = parent_line
                break
            # END abort reading parents
            self.parents.append(type(self)(self.repo, hex_to_bin(parent_line.split()[-1].decode('ascii'))))
        # END for each parent line
        self.parents = tuple(self.parents)

        # we don't know actual author encoding before we have parsed it, so keep the lines around
        author_line = next_line
        committer_line = readline()

        # we might run into one or more mergetag blocks, skip those for now
        next_line = readline()
        while next_line.startswith(b'mergetag '):
            next_line = readline()
            while next_line.startswith(b' '):
                next_line = readline()
        # end skip mergetags

        # now we can have the encoding line, or an empty line followed by the optional
        # message.
        self.encoding = self.default_encoding
        self.gpgsig = None

        # read headers
        enc = next_line
        buf = enc.strip()
        while buf:
            if buf[0:10] == b"encoding ":
                self.encoding = buf[buf.find(' ') + 1:].decode('ascii')
            elif buf[0:7] == b"gpgsig ":
                sig = buf[buf.find(b' ') + 1:] + b"\n"
                is_next_header = False
                while True:
                    sigbuf = readline()
                    if not sigbuf:
                        break
                    if sigbuf[0:1] != b" ":
                        buf = sigbuf.strip()
                        is_next_header = True
                        break
                    sig += sigbuf[1:]
                # end read all signature
                self.gpgsig = sig.rstrip(b"\n").decode('ascii')
                if is_next_header:
                    continue
            buf = readline().strip()
        # decode the authors name

        try:
            self.author, self.authored_date, self.author_tz_offset = \
                parse_actor_and_date(author_line.decode(self.encoding, 'replace'))
        except UnicodeDecodeError:
            log.error("Failed to decode author line '%s' using encoding %s", author_line, self.encoding,
                      exc_info=True)

        try:
            self.committer, self.committed_date, self.committer_tz_offset = \
                parse_actor_and_date(committer_line.decode(self.encoding, 'replace'))
        except UnicodeDecodeError:
            log.error("Failed to decode committer line '%s' using encoding %s", committer_line, self.encoding,
                      exc_info=True)
        # END handle author's encoding

        # a stream from our data simply gives us the plain message
        # The end of our message stream is marked with a newline that we strip
        self.message = stream.read()
        try:
            self.message = self.message.decode(self.encoding, 'replace')
        except UnicodeDecodeError:
            log.error("Failed to decode message '%s' using encoding %s", self.message, self.encoding, exc_info=True)
        # END exception handling

        return self
1113630
public static byte[] loadBytesFromStream(InputStream stream) {
		try {
			BufferedInputStream bis = new BufferedInputStream(stream);
			byte[] theData = new byte[10000000];
			int dataReadSoFar = 0;
			byte[] buffer = new byte[1024];
			int read = 0;
			while ((read = bis.read(buffer)) != -1) {
				System.arraycopy(buffer, 0, theData, dataReadSoFar, read);
				dataReadSoFar += read;
			}
			bis.close();
			// Resize to actual data read
			byte[] returnData = new byte[dataReadSoFar];
			System.arraycopy(theData, 0, returnData, 0, dataReadSoFar);
			return returnData;
		}
		catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
203690
public static Object convertBlob(Object blob, InputStream input) throws SQLException {
        return convertBlob(blob, toByteArray(input));
    }
652595
def read(self, url):
        """"""
        params = self._split_url(url)
        output_stream = io.BytesIO()
        block_blob_service = self._block_blob_service(
            account_name=params["account"], sas_token=params["sas_token"]
        )

        block_blob_service.get_blob_to_stream(
            container_name=params["container"], blob_name=params["blob"], stream=output_stream
        )

        output_stream.seek(0)
        return [line.decode("utf-8") for line in output_stream]
1011752
function readIntoBuf(stream) {
  return new Promise((resolve, reject) => {
    const chunks = []

    stream.on('data', chunk => {
      chunks.push(chunk)
    })

    stream.on('error', err => {
      reject(err)
    })

    stream.on('end', () => {
      resolve(Buffer.concat(chunks))
    })
  })
}
1036213
@Override
    public INDArray load(Blob blob) throws SQLException {
        if (blob == null)
            return null;
        try(InputStream is = blob.getBinaryStream()) {
            ByteBuffer direct = ByteBuffer.allocateDirect((int) blob.length());
            ReadableByteChannel readableByteChannel = Channels.newChannel(is);
            readableByteChannel.read(direct);
            Buffer byteBuffer = (Buffer) direct;
            byteBuffer.rewind();
            return BinarySerde.toArray(direct);
        } catch (Exception e) {
           throw new RuntimeException(e);
        }


    }
345007
public void readFrom(InputStream is) throws IOException {
        while(true) {
            if(count==buf.length) {
                // reallocate
                byte[] data = new byte[buf.length*2];
                System.arraycopy(buf,0,data,0,buf.length);
                buf = data;
            }

            int sz = is.read(buf,count,buf.length-count);
            if(sz<0)     return;
            count += sz;
        }
    }
1290705
private static Object readDynamic(StreamingInput input)
		throws IOException
	{
		switch(input.peek())
		{
			case VALUE:
				input.next();
				return input.getValue();
			case NULL:
				input.next();
				return input.getValue();
			case LIST_START:
				return readList(input);
			case OBJECT_START:
				return readMap(input);
		}

		throw new SerializationException("Unable to read file, unknown start of value: " + input.peek());
	}
863839
private int readBytes(byte[] b, int offs, int len)
		throws BitstreamException
	{
		int totalBytesRead = 0;
		try
		{
			while (len > 0)
			{
				int bytesread = source.read(b, offs, len);
				if (bytesread == -1)
				{
					break;
				}
				totalBytesRead += bytesread;
				offs += bytesread;
				len -= bytesread;
			}
		}
		catch (IOException ex)
		{
			throw newBitstreamException(STREAM_ERROR, ex);
		}
		return totalBytesRead;
	}