Read an initial value (int) from our stored counter (file)

        Checks out master branch as a side effect!
188408
def _determine_next_ott_id(self):
        
        if self._doc_counter_lock is None:
            self._doc_counter_lock = Lock()
        with self._doc_counter_lock:
            _LOG.debug('Reading "{}"'.format(self._id_minting_file))
            noi_contents = self._read_master_branch_resource(self._id_minting_file, is_json=True)
            if noi_contents:
                self._next_ott_id = noi_contents['next_ott_id']
            else:
                raise RuntimeError('Stored ottid minting file not found (or invalid)!')
441096
def _readintle(self, length, start):
        """"""
        ui = self._readuintle(length, start)
        if not ui >> (length - 1):
            # Top bit not set, number is positive
            return ui
        # Top bit is set, so number is negative
        tmp = (~(ui - 1)) & ((1 << length) - 1)
        return -tmp
814043
@Override
    public final int read() throws IOException
    {
        assert cursor <= end;
        if (cursor >= end)
        {
            if (includeLevel.in == null)
            {
                return -1;
            }
            int cp = (int)(cursor % size);
            long len = size-(cursor-waterMark);
            int il;
            if (len > size - cp)
            {
                buffer1.position(cp);
                buffer1.limit(size);
                buffer2.position(0);
                buffer2.limit((int)(len-(size-cp)));
                if (!buffer1.hasRemaining() && !buffer2.hasRemaining())
                {
                    throw new UnderflowException("Buffer size="+size+" too small for operation");
                }
                il = fill(includeLevel.in, array2);
            }
            else
            {
                buffer1.position(cp);
                buffer1.limit((int)(cp+len));
                if (!buffer1.hasRemaining())
                {
                    throw new UnderflowException("Buffer size="+size+" too small for operation");
                }
                il = fill(includeLevel.in, array1);
            }
            if (il == -1)
            {
                if (includeStack != null)
                {
                    while (!includeStack.isEmpty() && il == -1)
                    {
                        close(includeLevel.in);
                        includeLevel = includeStack.pop();
                        return read();
                    }
                }
                return -1;
            }
            if (il == 0)
            {
                throw new IOException("No input! Use blocking mode?");
            }
            buffer1.clear();
            buffer2.clear();
            end+=il;
            if (end < 0)
            {
                throw new IOException("end = "+end);
            }
        }
        int rc = get(cursor++);
        if (cursor < 0)
        {
            throw new IOException("cursor = "+cursor);
        }
        includeLevel.forward(rc);
        length++;
        if (length > size)
        {
            throw new IOException("input size "+length+" exceeds buffer size "+size);
        }
        if (checksum != null)
        {
            checksum.update(cursor-1, rc);
        }
        return rc;
    }
521616
@Override
  public synchronized int read(byte[] buf, int off, int len)
      throws IOException {
    checkNotClosed();

    validatePositionedReadArgs(nextReadPos, buf, off, len);
    if (len == 0) {
      return 0;
    }

    if (contentLength == 0 || (nextReadPos >= contentLength)) {
      return -1;
    }

    try {
      lazySeek(nextReadPos, len);
    } catch (EOFException e) {
      // the end of the file has moved
      return -1;
    }

    int bytesRead;
    try {
      bytesRead = wrappedStream.read(buf, off, len);
    } catch (EOFException e) {
      onReadFailure(e, len);
      // the base implementation swallows EOFs.
      return -1;
    } catch (IOException e) {
      onReadFailure(e, len);
      bytesRead = wrappedStream.read(buf, off, len);
    }

    if (bytesRead > 0) {
      pos += bytesRead;
      nextReadPos += bytesRead;
    }
    incrementBytesRead(bytesRead);
    return bytesRead;
  }
1032551
private void readValues()
            throws IOException
    {
        lastReadInputCheckpoint = input.getCheckpoint();

        // read the first 2 bits and determine the encoding type
        int firstByte = input.read();
        if (firstByte < 0) {
            throw new OrcCorruptionException(input.getOrcDataSourceId(), "Read past end of RLE integer");
        }

        int enc = (firstByte >>> 6) & 0x03;
        if (EncodingType.SHORT_REPEAT.ordinal() == enc) {
            readShortRepeatValues(firstByte);
        }
        else if (EncodingType.DIRECT.ordinal() == enc) {
            readDirectValues(firstByte);
        }
        else if (EncodingType.PATCHED_BASE.ordinal() == enc) {
            readPatchedBaseValues(firstByte);
        }
        else {
            readDeltaValues(firstByte);
        }
    }
1286239
private static int readLEInt(InputStream in) throws IOException {
		int i = in.read() & 0xFF;
		i |= (in.read() & 0xFF) << 8;
		i |= (in.read() & 0xFF) << 16;
		i |= (in.read() & 0xFF) << 24;
		return i;
	}
275886
public int read() throws IOException {
        logger.debug("read()");
        logger.debug("count={} pos={}", count, pos);
        return (pos < count) ? (buf[pos++] & 0xff) : (-1);
    }
548882
private void readIFDs() {
    int offset0 = 0;
    try {
      // The pointer to the first IFD is located in bytes 4-7
      offset0 = data.readLong(4).toInt();
      tiffModel.setFirstIFDOffset(offset0);
      if (offset0 == 0)
        validation.addErrorLoc("There is no first IFD", "Header");
      else if (offset0 > data.size())
        validation.addErrorLoc("Incorrect offset", "Header");
    } catch (Exception ex) {
      validation.addErrorLoc("IO exception", "Header");
    }
      
    if (validation.isCorrect()) {
      int nifd = 1;
      try {
        IfdReader ifd0 = readIFD(offset0, true, 0);
        HashSet<Integer> usedOffsets = new HashSet<Integer>();
        usedOffsets.add(offset0);
        if (ifd0.getIfd() == null) {
          validation.addErrorLoc("Parsing error in first IFD", "IFD" + 0);
        } else {
          IFD iifd = ifd0.getIfd();
          iifd.setNextOffset(ifd0.getNextIfdOffset());
          tiffModel.addIfd0(iifd);

          IfdReader current_ifd = ifd0;

          // Read next IFDs
          boolean stop = false;
          while (current_ifd.getNextIfdOffset() > 0 && !stop) {
            if (usedOffsets.contains(current_ifd.getNextIfdOffset())) {
              // Circular reference
              validation.addErrorLoc("IFD offset already used", "IFD" + nifd);
              stop = true;
            } else if (current_ifd.getNextIfdOffset() > data.size()) {
              validation.addErrorLoc("Incorrect offset", "IFD" + nifd);
              stop = true;
            } else {
              usedOffsets.add(current_ifd.getNextIfdOffset());
              IfdReader next_ifd = readIFD(current_ifd.getNextIfdOffset(), true, nifd);
              if (next_ifd == null) {
                validation.addErrorLoc("Parsing error in IFD " + nifd, "IFD" + nifd);
                stop = true;
              } else {
                iifd = next_ifd.getIfd();
                iifd.setNextOffset(next_ifd.getNextIfdOffset());
                current_ifd.getIfd().setNextIFD(iifd);
                current_ifd = next_ifd;
              }
              nifd++;
            }
          }
        }
      } catch (Exception ex) {
        validation.addErrorLoc("IFD parsing error", "IFD" + nifd);
      }

      try {
        tiffModel.createMetadataDictionary();
      } catch (Exception ex) {
      }
    }
  }
1024772
public int readVarInt() throws IOException {
    boolean more;
    int result = 0;
    do {
      int b = in.readUnsignedByte();
      more = (b & 0x80) == 0x80;
      result = 128 * result + (b & 0x7F);

      // TODO Check for int overflow
    } while (more);

    return result;
  }
771682
@Override
    public int read( char[] cbuf, int off, int len ) throws IOException {
        assert len >= 0;
        assert off >= 0;

        int amountRead = 0;
        final int endIndex = off + len;
        for ( int index = off; index < endIndex; index++ ) {
            int readChar = read();
            if ( readChar == -1 ) {
                break;
            }

            cbuf[ index ] = ( char ) readChar;
            amountRead++;
        }

        return amountRead == 0 ? -1 : amountRead;
    }
597792
public int readReverse() throws IOException {
		int b;
		do {
			canRead.block(0);
			synchronized (this) {
				if (error != null) throw error;
				if (io == null) throw new IOException("IO closed");
				// check if we reached the beginning of the file
				if (bufferPosInFile == 0 && posInBuffer == minInBuffer) return -1;
				if (posInBuffer == minInBuffer) {
					// we are reading faster than buffering
					if (currentRead != null)
						canRead.restart();
					else
						readBufferBack();
					b = -1;
				} else {
					b = buffer[--posInBuffer] & 0xFF;
					if (currentRead == null && posInBuffer < buffer.length / 2 && bufferPosInFile > 0)
						readBufferBack();
				}
			}
		} while (b == -1);
		return b;
	}
1257882
private void init()
	{

		sum = BigInteger.ZERO;
		sumByMillisec = BigInteger.ZERO;
		currentVal = -1;
		count =0;
		avg = -1;
		max = -1;
		min = -1;
	}
1321038
@Override
  public int read(byte []buf, int offset, int length) throws IOException
  {
    try {
      if (_is == null) {
        if (_s == null) {
          return -1;
        }
        
        _is = _s.getInputStream();
      }

      int readLength = _is.read(buf, offset, length);

      if (readLength >= 0) {
        _totalReadBytes += readLength;
      }

      return readLength;
    } catch (InterruptedIOException e) {
      e.printStackTrace();
      if (_throwReadInterrupts)
        throw e;
      
      log.log(Level.FINEST, e.toString(), e);
    } catch (IOException e) {
      e.printStackTrace();
      if (_throwReadInterrupts) {
        throw e;
      }

      if (log.isLoggable(Level.FINEST)) {
        log.log(Level.FINEST, e.toString(), e);
      }
      else {
        log.finer(e.toString());
      }
      // server/0611
      /*
      try {
        close();
      } catch (IOException e1) {
      }
      */
    }

    return -1;
  }
477034
private int read1(byte b[], int off, int len)
  throws IOException {
    int avail = count-pos;
    if( avail <= 0 ) {
      if(len>=buf.length) {
        // read a chunk to user buffer directly; avoid one copy
        int nread = readChecksumChunk(b, off, len);
        return nread;
      } else {
        // read a chunk into the local buffer
        fill();
        if( count <= 0 ) {
          return -1;
        } else {
          avail = count;
        }
      }
    }
    
    // copy content of the local buffer to the user buffer
    int cnt = (avail < len) ? avail : len;
    System.arraycopy(buf, pos, b, off, cnt);
    pos += cnt;
    return cnt;    
  }
222908
@Override
	public int read() throws IOException {
		byte[] b = new byte[1];
		int num = read(b);
		if(num == 0) {
			throw new IllegalStateException("read returned 0");
		}
		return num > 0 ? b[0] : -1;
	}
880187
@Override
  public int read(CharBuffer target) throws IOException {
    try {
      beforeRead(target != null ? target.length() : 0);
      int n = in.read(target);
      afterRead(n);
      return n;
    } catch (IOException e) {
      handleIOException(e);
      return -1;
    }
  }
425585
protected BranchCounts readBranchCounts(final BitInputStream in,
    final Bits code, final long size) throws IOException {
    final BranchCounts branchCounts = new BranchCounts(code, size);
    final CodeType currentCodeType = this.getType(code);
    long maximum = size;

    // Get terminals
    if (currentCodeType == CodeType.Unknown) {
      branchCounts.terminals = this.readTerminalCount(in, maximum);
    }
    else if (currentCodeType == CodeType.Terminal) {
      branchCounts.terminals = size;
    }
    else {
      branchCounts.terminals = 0;
    }
    maximum -= branchCounts.terminals;

    // Get zero-suffixed primary
    if (maximum > 0) {
      assert Thread.currentThread().getStackTrace().length < 100;
      branchCounts.zeroCount = this.readZeroBranchSize(in, maximum, code);
    }
    maximum -= branchCounts.zeroCount;
    branchCounts.oneCount = maximum;
    return branchCounts;
  }