Reads the blob from the journal into the working cursor.
974497
@Override
  void readJournal(PageServiceImpl pageActor,
                   ReadStream is, 
                   byte[] buffer, int offset, RowCursor cursor)
    throws IOException
  {
    int len = BitsUtil.readInt16(is);

    if (len == 0) {
      BitsUtil.writeInt(buffer, offset + offset(), 0);
      return;
    }
    
    if ((len & LARGE_BLOB_MASK) != 0) {
      len = len & ~LARGE_BLOB_MASK;
      
      if (len != 4) {
        throw new IllegalStateException();
      }
      
      int id = BitsUtil.readInt(is);
      
      PageBlob pageBlob = pageActor.getBlobPage(id);

      if (pageBlob != null) {
        BlobOutputStream blob = new BlobOutputStream(cursor, this, id);
      
        cursor.setBlob(index(), blob);
      }

      return;
    }
    
    TempBuffer tBuf = TempBuffer.create();
    byte []tempBuffer = tBuf.buffer();

    is.readAll(tempBuffer, 0, len);
      
    BlobOutputStream blob = new BlobOutputStream(cursor,
                                                 this,
                                                 tBuf,
                                                 len);
    
    cursor.setBlob(index(), blob);
  }
42199
@Override
  void writeJournal(OutputStream os, 
                    byte[] buffer, int offset,
                    BlobOutputStream blob)
    throws IOException
  {
    if (blob == null) {
      BitsUtil.writeInt16(os, 0);
      return;
    }

    if (blob.isLargeBlob()) {
      blob.flushBlob();
      
      BitsUtil.writeInt16(os, LARGE_BLOB_MASK | 4);
      BitsUtil.writeInt(os, blob.getBlobId());
      return;
    }
    
    int len = blob.getSize();
    
    if (len >= 32 * 1024) {
      throw new IllegalStateException("TOO_BIG: " + len);
    }
    
    BitsUtil.writeInt16(os, len);
    
    blob.writeToStream(os);
  }
1034794
@Override
    public synchronized ConsumerJournalEntry readJournalEntry()
            throws JournalException, XMLStreamException {
        if (!open) {
            return null;
        }

        if (!advancedPastHeader) {
            advanceIntoFile();
            advancedPastHeader = true;
        }

        XMLEvent next = reader.peek();

        // advance past any whitespace events.
        while (next.isCharacters() && next.asCharacters().isWhiteSpace()) {
            reader.nextEvent();
            next = reader.peek();
        }
        if (isStartTagEvent(next, QNAME_TAG_JOURNAL_ENTRY)) {
            String identifier = peekAtJournalEntryIdentifier();
            ConsumerJournalEntry journalEntry = super.readJournalEntry(reader);
            journalEntry.setIdentifier(identifier);
            return journalEntry;
        } else if (isEndTagEvent(next, QNAME_TAG_JOURNAL)) {
            return null;
        } else {
            throw getNotNextMemberOrEndOfGroupException(QNAME_TAG_JOURNAL,
                                                        QNAME_TAG_JOURNAL_ENTRY,
                                                        next);
        }
    }
908872
def read_bytes(fo, writer_schema=None, reader_schema=None):
    """"""
    size = read_long(fo)
    return fo.read(size)
28463
public CBlob toCBlob()
    {
        CBlob cBlob = new CBlob( getPath(), length, contentType );
        cBlob.setModificationDate( updated );
        
        return cBlob;
    }
603935
public static String blobToStr(Blob blob, Charset charset) {
		InputStream in = null;
		try {
			in = blob.getBinaryStream();
			return IoUtil.read(in, charset);
		} catch (SQLException e) {
			throw new DbRuntimeException(e);
		} finally {
			IoUtil.close(in);
		}
	}
869392
public static byte[] getBlob(Cursor cursor, String columnName) {
        if (cursor == null) {
            return null;
        }

        return cursor.getBlob(cursor.getColumnIndex(columnName));
    }
255825
private Journal.JournalEntry readInternal() throws IOException {
    if (mInputStream == null) {
      return null;
    }
    JournalEntry entry = mInputStream.mReader.readEntry();
    if (entry != null) {
      return entry;
    }
    if (mInputStream.mFile.isIncompleteLog()) {
      // Incomplete logs may end early.
      return null;
    } else {
      Preconditions.checkState(mInputStream.mFile.isCompletedLog(),
          "Expected log to be either checkpoint, incomplete, or complete");
      ProcessUtils.fatalError(LOG, "Journal entry %s was truncated", mNextSequenceNumber);
      return null;
    }
  }
1314931
def readinto(self, b):
        
        if not self._readable:
            raise UnsupportedOperation('read')

        with self._seek_lock:
            # Gets seek
            seek = self._seek

            # Initializes queue
            queue = self._read_queue
            if seek == 0:
                # Starts initial preloading on first call
                self._preload_range()

            # Initializes read data buffer
            size = len(b)
            if size:
                # Preallocated buffer:
                # Use memory view to avoid copies
                b_view = memoryview(b)
                size_left = size
            else:
                # Dynamic buffer:
                # Can't avoid copy, read until EOF
                b_view = b
                size_left = -1
            b_end = 0

            # Starts reading
            buffer_size = self._buffer_size
            while size_left > 0 or size_left == -1:

                # Finds buffer position in queue and buffer seek
                start = seek % buffer_size
                queue_index = seek - start

                # Gets preloaded buffer
                try:
                    buffer = queue[queue_index]
                except KeyError:
                    # EOF
                    break

                # Get buffer from future
                with handle_os_exceptions():
                    try:
                        queue[queue_index] = buffer = buffer.result()

                    # Already evaluated
                    except AttributeError:
                        pass
                buffer_view = memoryview(buffer)
                data_size = len(buffer)

                # Checks if end of file reached
                if not data_size:
                    break

                # Gets theoretical range to copy
                if size_left != -1:
                    end = start + size_left
                else:
                    end = data_size - start

                # Checks for end of buffer
                if end >= data_size:
                    # Adjusts range to copy
                    end = data_size

                    # Removes consumed buffer from queue
                    del queue[queue_index]

                    # Append another buffer preload at end of queue
                    index = queue_index + buffer_size * self._max_buffers
                    if index < self._size:
                        queue[index] = self._workers.submit(
                            self._read_range, index, index + buffer_size)

                # Gets read size, updates seek and updates size left
                read_size = end - start
                if size_left != -1:
                    size_left -= read_size
                seek += read_size

                # Defines read buffer range
                b_start = b_end
                b_end = b_start + read_size

                # Copy data from preload buffer to read buffer
                b_view[b_start:b_end] = buffer_view[start:end]

            # Updates seek and sync raw
            self._seek = seek
            self._raw.seek(seek)

        # Returns read size
        return b_end
1133158
def WriteBlobs(self, blob_id_data_map, cursor=None):
    """"""
    chunks = []
    for blob_id, blob in iteritems(blob_id_data_map):
      chunks.extend(_BlobToChunks(blob_id.AsBytes(), blob))
    for values in _PartitionChunks(chunks):
      _Insert(cursor, "blobs", values)
1194268
function BlobReader(blob, opts) {
  stream.Readable.call(this);
  opts = opts || {};

  this._batchSize = opts.batchSize || 65536;
  this._blob = blob;
  this._pos = 0;
}
444183
def _create_blob(self):
        """"""
        blob = None
        for line in self.blob_file:
            line = try_decode_string(line)
            line = line.strip()
            if line == '':
                self.log.info("Ignoring empty line...")
                continue
            if line.startswith('end_event:') and blob:
                blob['raw_header'] = self.raw_header
                return blob
            try:
                tag, values = line.split(':')
            except ValueError:
                self.log.warning("Ignoring corrupt line: {}".format(line))
                continue
            try:
                values = tuple(split(values.strip(), callback=float))
            except ValueError:
                self.log.info("Empty value: {}".format(values))
            if line.startswith('start_event:'):
                blob = Blob()
                blob[tag] = tuple(int(v) for v in values)
                continue
            if tag not in blob:
                blob[tag] = []
            blob[tag].append(values)
1119369
@Override
  int insertBlob(byte[] srcBuffer, int srcRowOffset,
                 byte[] dstBuffer, int dstRowOffset, int dstBlobTail)
  {
    int srcColumnOffset = srcRowOffset + offset();
    int dstColumnOffset = dstRowOffset + offset();
    
    int blobLen = BitsUtil.readInt16(srcBuffer, srcColumnOffset + 2);

    if (blobLen == 0) {
      return dstBlobTail;
    }
    
    blobLen &= ~LARGE_BLOB_MASK;

    if (dstRowOffset < dstBlobTail + blobLen) {
      return -1;
    }

    int blobOffset = BitsUtil.readInt16(srcBuffer, srcColumnOffset);

    try {
      System.arraycopy(srcBuffer, blobOffset, dstBuffer, dstBlobTail,
                       blobLen);
    } catch (ArrayIndexOutOfBoundsException e) {
      throw new ArrayIndexOutOfBoundsException("srcOff: " + blobOffset
                                               + " dstOff: " + dstBlobTail
                                               + " len: " + blobLen
                                               + " " + this);
    }

    BitsUtil.writeInt16(dstBuffer, dstColumnOffset, dstBlobTail);
    
    /*
    System.out.println("SET: " + Hex.toHex(dstBuffer, dstRowOffset, 5) 
                       + " " + Hex.toHex(dstBuffer, dstBlobTail, 4));
                       */
    
    return dstBlobTail + blobLen;
  }
476369
function readFromSnapshotSub (entityContent, dock, buffer, offset, length, position, cb) {
    var p;
    if ((position !== null) && (position !== undefined)) {
      p = position;
    } else {
      p = dock.position;
    }
    if (cb) {
      payloadCopyUni(entityContent, buffer, offset, p, p + length, function (error, bytesRead, buffer2) {
        if (error) return cb(error);
        dock.position = p + bytesRead;
        cb(null, bytesRead, buffer2);
      });
    } else {
      var bytesRead = payloadCopyUni(entityContent, buffer, offset, p, p + length);
      dock.position = p + bytesRead;
      return bytesRead;
    }
  }
1281301
def ReadBlobs(self, blob_ids, cursor=None):
    """"""
    if not blob_ids:
      return {}

    query = ("SELECT blob_id, blob_chunk "
             "FROM blobs "
             "FORCE INDEX (PRIMARY) "
             "WHERE blob_id IN {} "
             "ORDER BY blob_id, chunk_index ASC").format(
                 mysql_utils.Placeholders(len(blob_ids)))
    cursor.execute(query, [blob_id.AsBytes() for blob_id in blob_ids])
    results = {blob_id: None for blob_id in blob_ids}
    for blob_id_bytes, blob in cursor.fetchall():
      blob_id = rdf_objects.BlobID.FromBytes(blob_id_bytes)
      if results[blob_id] is None:
        results[blob_id] = blob
      else:
        results[blob_id] += blob
    return results
809380
def blob(self, nodeid, tag, start=0, end=0xFFFFFFFF):
        
        startkey = self.makekey(nodeid, tag, start)
        endkey = self.makekey(nodeid, tag, end)
        cur = self.btree.find('ge', startkey)
        data = b''
        while cur.getkey() <= endkey:
            data += cur.getval()
            cur.next()
        return data
259532
def open(cls, filename):
        """"""
        file_info = cls.parse_remote(filename)
        blob_service = cls.connect(filename)
        return BlobHandle(blob_service=blob_service,
                          container=file_info.container,
                          blob=file_info.blob,
                          chunk_size=cls._BLOB_CHUNK_DATA_SIZE)