This function depends on that the underlying dataSegmentIn.available() only
returns 0 when EOF.  Otherwise it will break because it jumps over the dataSegmentIn
that has available() == 0.
502878
@Override
  public int available() throws IOException {
    if (dataSegmentIn == null) {
      if (!moveToNextDataSegment()) {
        return 0;
      }
    }
    do {
      int result = dataSegmentIn.available();
      if (result != 0) {
        return result;
      }
      if (!moveToNextDataSegment()) {
        return 0;
      }
    } while (true);
  }
879205
private boolean loadMore(int available)
        throws IOException
    {
        mByteCount += (mByteBufferEnd - available);

        // Bytes that need to be moved to the beginning of buffer?
        if (available > 0) {
	    /* 11-Nov-2008, TSa: can only move if we own the buffer; otherwise
	     *   we are stuck with the data.
	     */
            if (mBytePtr > 0 && canModifyBuffer()) {
                for (int i = 0; i < available; ++i) {
                    mByteBuffer[i] = mByteBuffer[mBytePtr+i];
                }
                mBytePtr = 0;
		mByteBufferEnd = available;
            }
        } else {
            /* Ok; here we can actually reasonably expect an EOF,
             * so let's do a separate read right away:
             */
            int count = readBytes();
            if (count < 1) {
                if (count < 0) { // -1
                    freeBuffers(); // to help GC?
                    return false;
                }
                // 0 count is no good; let's err out
                reportStrangeStream();
            }
        }

        /* Need at least 4 bytes; if we don't get that many, it's an
         * error.
         */
        while (mByteBufferEnd < 4) {
            int count = readBytesAt(mByteBufferEnd);
            if (count < 1) {
                if (count < 0) { // -1, EOF... no good!
                    freeBuffers(); // to help GC?
                    reportUnexpectedEOF(mByteBufferEnd, 4);
                }
                // 0 count is no good; let's err out
                reportStrangeStream();
            }
        }
        return true;
    }
1177104
@Override
    public boolean isReavailable()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.entry(tc, "isReavailable");
            SibTr.exit(tc, "isReavailable", Boolean.valueOf(reavailable));
        }
        return reavailable;
    }
806899
@Override
	public int available() throws IOException {
		synchronized(file) {
			long len=file.getLength();
			return len>Integer.MAX_VALUE?Integer.MAX_VALUE:(int)len;
		}
	}
203219
private Servlet makeUnavailable(UnavailableException e) 
      throws UnavailableException 
    {
        _unavailableEx=e;
        _unavailable=-1;
        if (e.isPermanent())   
            _unavailable=-1;
        else
	{
            if (_unavailableEx.getUnavailableSeconds()>0)
                _unavailable=System.currentTimeMillis()+1000*_unavailableEx.getUnavailableSeconds();
            else
                _unavailable=System.currentTimeMillis()+5000; // TODO configure
	}
   
        throw _unavailableEx;
    }
14946
@Override
  public long skip(long n)
    throws IOException
  {
    if (n <= 0) {
      return n;
    }
    
    long skipLen = 0;
    
    while (n > 0) {
      long sublen = Math.min(n, _readLength - _readOffset);

      if (sublen > 0) {
        _readOffset += sublen;

        skipLen += sublen;
        n -= sublen;
      }
      else {
        if (_source.hasSkip()) {
          _readOffset = _readLength = 0;
          
          long sourceSkipped = _source.skip(n);

          if (sourceSkipped <= 0) {
            return skipLen;
          }
          else {
            _position += sourceSkipped;
            skipLen += sourceSkipped;
            
            n -= sourceSkipped;
          }
        }
        else if (! readBuffer()) {
          return skipLen;
        }
      }
    }
    
    return skipLen;
  }
900941
def is_eof(self):
        
        pos = self._stream.tell()
        byte = self._stream.read(1)
        self._stream.seek(pos, 0)

        return utils.binary(byte) == utils.binary("")
161325
public boolean read(DataInputStream daIn, boolean bFixedLength) // Fixed length = false
    {
        try   {
            float fData = daIn.readFloat();
            Float flData = null;
            if (!Float.isNaN(fData))
                flData = new Float(fData);
            int errorCode = this.setData(flData, DBConstants.DONT_DISPLAY, DBConstants.READ_MOVE);
            return (errorCode == DBConstants.NORMAL_RETURN);    // Success
        } catch (IOException ex)    {
            ex.printStackTrace();
            return false;
        }
    }
347579
boolean hasNext() throws DataSourceReadException {
        if (!hasNextComputed) {
            boolean stayInLoop;
            do {
                stayInLoop = false;
                /*
                 * Prior to reading the first iterator, we loop through all of
                 * the iterators to determine the minimum keyId. The minimum
                 * keyId, stored in currentMin, is used for data retrieval. The
                 * value of currentMin will be null if there is no data to
                 * retrieve.
                 */
                if (i == 0) {
                    this.currentMin = null;
                    for (DataStreamingEvent<E> elt : this.currentElt) {
                        currentMin = min(elt);
                    }
                }
                /*
                 * If there is no data to retrieve, we'll return false. If there
                 * is data to retrieve, we'll loop through the iterators and
                 * pull data for the current keyId, which is the keyId field of
                 * currentMin. If there's no data for the current keyId, this
                 * should loop through all of the iterators until their ends,
                 * and set hasNext to false.
                 */
                if (currentMin == null) {
                    this.hasNext = false;
                } else {
                    int n = this.currentElt.size();
                    for (; i < n; i++) {
                        DataStreamingEvent<E> elt = this.currentElt.get(i);
                        if (elt != null && elt.getKeyId().equals(
                                this.currentMin != null 
                                ? this.currentMin.getKeyId() : null)) {
                            this.result = elt;
                            this.nextKeyId = elt.getKeyId();
                            advance(i);
                            i++;
                            break;
                        }
                    }
                    if (this.i == n && this.result == null) {
                        this.i = 0;
                        stayInLoop = true;
                    }
                }
            } while (this.hasNext && stayInLoop);
            this.hasNextComputed = true;
        }
        return hasNext;
    }
704536
private int skip(byte[] data, int pos, int count) {
        int remaining = data.length - pos;
        if (remaining >= count) {
            this.parseInt = 0;
            return (pos + count);
        }
        // didn't have the entire amount, store the remaining length to skip later
        this.parseInt = (count - remaining);
        return data.length;
    }
1317205
@SuppressWarnings("fallthrough")
  String getRemainingJSDocLine() {
    int c;
    for (;;) {
      c = getChar();
      switch (c) {
        case '*':
          if (peekChar() != '/') {
            addToString(c);
            break;
          }
          // fall through
        case EOF_CHAR:
        case '\n':
          ungetChar(c);
          this.string = getStringFromBuffer();
          stringBufferTop = 0;
          return this.string;

        default:
          addToString(c);
          break;
      }
    }
  }
1106437
private boolean checkAvailable(){
        int i = 0;
        try{
            i = this.in.available();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Current amount immediately available in buffers : " + i);
            }
        } catch (Exception e){
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "There was an IOException during the checkAvailable method : " + e);
            }
        }
        return ((i > 0) ? true : false);
    }
633047
private boolean seekOrSkip(long bytes, boolean toNewSource) throws IOException {
    if (seekableIn != null) {
      // Use Seekable interface to speed up skip.
      int available = in.available();
      try {
        if (toNewSource) {
          return seekableIn.seekToNewSource(seekableIn.getPos() + bytes);
        } else {
          seekableIn.seek(seekableIn.getPos() + bytes);
          return true;
        }
      } catch (IOException e) {
        if (bytes > available && "Cannot seek after EOF".equals(e.getMessage())) {
          eofReached = true;
          throw new EOFException(e.getMessage());
        }
      }
    } else {
      // Do raw skip.
      long toSkip = bytes;
      while (toSkip > 0) {
        long skipped = in.skip(toSkip);
        if (skipped <= 0) {
          throw new EOFException("skip returned " + skipped);
        }
        toSkip -= skipped;
      };
    }
    return true;
  }
801040
@SuppressWarnings("unchecked")
  private void readNext() {
    // Compute the index of the next entry in the segment.
    final long index = getNextIndex();

    // Mark the buffer so it can be reset if necessary.
    buffer.mark();

    try {
      // Read the length of the entry.
      final int length = buffer.getInt();

      // If the buffer length is zero then return.
      if (length <= 0 || length > maxEntrySize) {
        buffer.reset();
        nextEntry = null;
        return;
      }

      // Read the checksum of the entry.
      long checksum = buffer.getInt() & 0xFFFFFFFFL;

      // Compute the checksum for the entry bytes.
      final CRC32 crc32 = new CRC32();
      ByteBuffer slice = buffer.slice();
      slice.limit(length);
      crc32.update(slice);

      // If the stored checksum equals the computed checksum, return the entry.
      if (checksum == crc32.getValue()) {
        slice.rewind();
        E entry = namespace.deserialize(slice);
        nextEntry = new Indexed<>(index, entry, length);
        buffer.position(buffer.position() + length);
      } else {
        buffer.reset();
        nextEntry = null;
      }
    } catch (BufferUnderflowException e) {
      buffer.reset();
      nextEntry = null;
    }
  }
14051
public synchronized int get(byte[] dst, int off, int len) {
        if (available == 0) {
            return 0;
        }

        // limit is last index to read + 1
        int limit = idxGet < idxPut ? idxPut : capacity;
        int count = Math.min(limit - idxGet, len);
        System.arraycopy(buffer, idxGet, dst, off, count);
        idxGet += count;

        if (idxGet == capacity) {
            // Array end reached, check if we have more
            int count2 = Math.min(len - count, idxPut);
            if (count2 > 0) {
                System.arraycopy(buffer, 0, dst, off + count, count2);
                idxGet = count2;
                count += count2;
            } else {
                idxGet = 0;
            }
        }
        available -= count;
        return count;
    }
528225
public boolean loadSegment(final DataSegment segment) throws SegmentLoadingException
  {
    final Segment adapter = getAdapter(segment);

    final SettableSupplier<Boolean> resultSupplier = new SettableSupplier<>();

    // compute() is used to ensure that the operation for a data source is executed atomically
    dataSources.compute(
        segment.getDataSource(),
        (k, v) -> {
          final DataSourceState dataSourceState = v == null ? new DataSourceState() : v;
          final VersionedIntervalTimeline<String, ReferenceCountingSegment> loadedIntervals =
              dataSourceState.getTimeline();
          final PartitionHolder<ReferenceCountingSegment> entry = loadedIntervals.findEntry(
              segment.getInterval(),
              segment.getVersion()
          );

          if ((entry != null) && (entry.getChunk(segment.getShardSpec().getPartitionNum()) != null)) {
            log.warn("Told to load an adapter for segment[%s] that already exists", segment.getId());
            resultSupplier.set(false);
          } else {
            loadedIntervals.add(
                segment.getInterval(),
                segment.getVersion(),
                segment.getShardSpec().createChunk(new ReferenceCountingSegment(adapter))
            );
            dataSourceState.addSegment(segment);
            resultSupplier.set(true);
          }
          return dataSourceState;
        }
    );

    return resultSupplier.get();
  }
864288
public boolean read(DataInputStream daIn, boolean bFixedLength) // Fixed length = false
    {
        try   {
            int iData = daIn.readInt();
            Integer inData = null;
            if (iData != NAN)
                inData = new Integer(iData);
            int iErrorCode = this.setData(inData, DBConstants.DONT_DISPLAY, DBConstants.READ_MOVE);
            return (iErrorCode == DBConstants.NORMAL_RETURN);    // Success
        } catch (IOException ex)    {
            ex.printStackTrace();
            return false;
        }
    }