Fills the holes information into OPhysicalPosition object given as parameter.

@return true, if it's a valid hole, otherwise false
@throws IOException
12382
public synchronized ODataHoleInfo getHole(final int iPosition) {
    final ODataHoleInfo hole = availableHolesList.get(iPosition);
    if (hole.dataOffset == -1)
      return null;
    return hole;
  }
445207
protected final boolean readLine() throws IOException {
		if (this.stream == null || this.overLimit) {
			return false;
		}

		int countInWrapBuffer = 0;

		/* position of matching positions in the delimiter byte array */
		int i = 0;

		while (true) {
			if (this.readPos >= this.limit) {
				if (!fillBuffer()) {
					if (countInWrapBuffer > 0) {
						setResult(this.wrapBuffer, 0, countInWrapBuffer);
						return true;
					} else {
						return false;
					}
				}
			}

			int startPos = this.readPos;
			int count = 0;

			while (this.readPos < this.limit && i < this.delimiter.length) {
				if ((this.readBuffer[this.readPos++]) == this.delimiter[i]) {
					i++;
				} else {
					i = 0;
				}

			}

			// check why we dropped out
			if (i == this.delimiter.length) {
				// line end
				count = this.readPos - startPos - this.delimiter.length;

				// copy to byte array
				if (countInWrapBuffer > 0) {
					// check wrap buffer size
					if (this.wrapBuffer.length < countInWrapBuffer + count) {
						final byte[] nb = new byte[countInWrapBuffer + count];
						System.arraycopy(this.wrapBuffer, 0, nb, 0, countInWrapBuffer);
						this.wrapBuffer = nb;
					}
					if (count >= 0) {
						System.arraycopy(this.readBuffer, 0, this.wrapBuffer, countInWrapBuffer, count);
					}
					setResult(this.wrapBuffer, 0, countInWrapBuffer + count);
					return true;
				} else {
					setResult(this.readBuffer, startPos, count);
					return true;
				}
			} else {
				count = this.limit - startPos;
				
				// check against the maximum record length
				if ( ((long) countInWrapBuffer) + count > this.lineLengthLimit) {
					throw new IOException("The record length exceeded the maximum record length (" + 
							this.lineLengthLimit + ").");
				}

				// buffer exhausted
				if (this.wrapBuffer.length - countInWrapBuffer < count) {
					// reallocate
					byte[] tmp = new byte[Math.max(this.wrapBuffer.length * 2, countInWrapBuffer + count)];
					System.arraycopy(this.wrapBuffer, 0, tmp, 0, countInWrapBuffer);
					this.wrapBuffer = tmp;
				}

				System.arraycopy(this.readBuffer, startPos, this.wrapBuffer, countInWrapBuffer, count);
				countInWrapBuffer += count;
			}
		}
	}
549382
public boolean insert (ObjectInfo info)
    {
        // bail if it's already in the set
        int ipos = indexOf(info);
        if (ipos >= 0) {
            // log a warning because the caller shouldn't be doing this
            log.warning("Requested to add an object to a set that already " +
                        "contains such an object [ninfo=" + info +
                        ", oinfo=" + _objs[ipos] + "].", new Exception());
            return false;
        }

        // otherwise insert it
        ipos = -(ipos+1);
        _objs = ListUtil.insert(_objs, ipos, info);
        _size++;
        return true;
    }
1093607
public boolean isValid() {
        boolean valid = markers.isEmpty() || markers.size() >= 3;
        if (valid) {
            for (PolygonHoleMarkers hole : holes) {
                valid = hole.isValid();
                if (!valid) {
                    break;
                }
            }
        }
        return valid;
    }
992457
public boolean setPosition(long position) {
		try {
			long fileSize = reader.length();
			if (fileSize > position) {
				reader.seek(position);
				return true;
			} 
			
			logger.logp(Level.SEVERE, className, "setPosition", "HPEL_OffsetBeyondFileSize", new Object[]{file, Long.valueOf(position), Long.valueOf(fileSize)});
			
		} catch (IOException ex) {
			logger.logp(Level.SEVERE, className, "setPosition", "HPEL_ErrorSettingFileOffset", new Object[]{file, Long.valueOf(position), ex.getMessage()});
			// Fall through to return false.
		}
		return false;
	}
244489
public boolean isValid() {
		if (isEmpty()) {
			return true;
		}
		if (!isClosed()) {
			return false;
		}
		Coordinate[] coordinates = getCoordinates();

		if (coordinates.length < 4) {
			return false;
		}

		for (int i = 0; i < coordinates.length - 1; i++) {
			for (int j = 0; j < coordinates.length - 1; j++) {
				if (Mathlib.lineIntersects(coordinates[i], coordinates[i + 1], coordinates[j], coordinates[j + 1])) {
					return false;
				}
			}
		}

		return true;
	}
742035
public boolean isConsitentWithIndex() throws IOException {
        byte[] b = new byte[keySize];
        long offset = 0;
        int maxChunk = getChunkIndex(getFilledUpFromContentStart());
        boolean isConsistent = true;
        for (int i = 1; i <= maxChunk; i++) {
            offset = i * getChunkSize() - elementSize;
            read(offset, ByteBuffer.wrap(b));
            if (KeyUtils.compareKey(getIndex().maxKeyPerChunk[i - 1], b) != 0) {
                logger.error("Index is not consistent to data. Expected {}, but found {}.",
                        Arrays.toString(getIndex().maxKeyPerChunk[i - 1]), Arrays.toString(b));
                isConsistent = false;
            }
        }
        return isConsistent;
    }
935546
private void position(long newPosition) throws IOException {

        check();
        checkPosition(newPosition);
        this.getRandomAccessFile().seek(newPosition + getHeaderLength());
    }
535663
private boolean goToNextStartPosition() throws IOException {
    int nextSpans1StartPosition;
    while ((nextSpans1StartPosition = spans1.spans
        .nextStartPosition()) != NO_MORE_POSITIONS) {
      if (nextSpans1StartPosition == lastSpans2EndPosition) {
        return true;
      } else {
        // clean up
        if (maximumSpans2EndPosition < nextSpans1StartPosition) {
          previousSpans2EndPositions.clear();
          maximumSpans2EndPosition = -1;
        } else if (previousSpans2EndPositions
            .contains(nextSpans1StartPosition)) {
          return true;
        }
        // try to find match
        while (lastSpans2StartPosition < nextSpans1StartPosition) {
          if (lastSpans2StartPosition != NO_MORE_POSITIONS) {
            lastSpans2StartPosition = spans2.spans.nextStartPosition();
          }
          if (lastSpans2StartPosition == NO_MORE_POSITIONS) {
            if (previousSpans2EndPositions.isEmpty()) {
              noMorePositions = true;
              return false;
            }
          } else {
            lastSpans2EndPosition = spans2.spans.endPosition();
            if (lastSpans2EndPosition >= nextSpans1StartPosition) {
              previousSpans2EndPositions.add(lastSpans2EndPosition);
              maximumSpans2EndPosition = Math.max(maximumSpans2EndPosition,
                  lastSpans2EndPosition);
            }
            if (nextSpans1StartPosition == lastSpans2EndPosition) {
              return true;
            }
          }
        }
      }
    }
    return false;
  }
955979
public int fillWithTimeout(long timeout)
    throws IOException
  {
    if (_readOffset < _readLength) {
      return _readLength - _readOffset;
    }

    if (_readBuffer == null) {
      _readOffset = 0;
      _readLength = 0;
      return -1;
    }

    _readOffset = 0;
    StreamImpl source = _source;

    if (source == null) {
      // return true on end of file
      return -1;
    }

    int readLength
      = source.readTimeout(_readBuffer, 0, _readBuffer.length, timeout);

    if (readLength > 0) {
      _readLength = readLength;
      _position += readLength;

      if (_isEnableReadTime) {
        _readTime = CurrentTime.currentTime();
      }

      return readLength;
    }
    else if (readLength == READ_TIMEOUT) {
      // timeout
      _readLength = 0;
      return 0;
    }
    else {
      // return false on end of file
      _readLength = 0;
      return -1;
    }
  }
604235
public boolean isConsistent() throws IOException {
        byte[] b = new byte[elementSize];
        long offset = 0;
        byte[] oldKey = null;
        int i = 0;
        while (offset < this.getFilledUpFromContentStart()) {
            this.read(offset, ByteBuffer.wrap(b));
            byte[] key = Arrays.copyOfRange(b, 0, keySize);
            if (oldKey != null && KeyUtils.compareKey(key, oldKey) != 1) {
                logger.error("File is not consistent at record {}. {} not larger than {}", new Object[] { i,
                        KeyUtils.toStringUnsignedInt(key), KeyUtils.toStringUnsignedInt(oldKey) });
                return false;
            }
            oldKey = Arrays.copyOf(key, keySize);
            offset += elementSize;
            i++;
        }
        return true;
    }
710088
public boolean open() throws IOException {
    if (!osFile.exists())
      throw new FileNotFoundException("File: " + osFile.getAbsolutePath());

    openChannel((int) osFile.length());

    OLogManager.instance().debug(this, "Checking file integrity of " + osFile.getName() + "...");

    init();

    final int fileSize = getFileSize();
    final int filledUpTo = getFilledUpTo();

    if (filledUpTo > 0 && filledUpTo > fileSize) {
      OLogManager
          .instance()
          .warn(
              this,
              "invalid filledUp value (%d) for file %s. Resetting the file size %d to the os file size: %d. Probably the file was not closed correctly last time",
              filledUpTo, getOsFile().getAbsolutePath(), fileSize, fileSize);
      setSize(fileSize);
    }

    if (filledUpTo > fileSize || filledUpTo < 0)
      OLogManager.instance().error(this, "Invalid filledUp size (=" + filledUpTo + "). The file could be corrupted", null,
          OStorageException.class);

    if (failCheck) {
      boolean softlyClosed = isSoftlyClosed();

      if (softlyClosed)
        setSoftlyClosed(false);

      return softlyClosed;
    }
    return true;
  }
626489
private boolean refill() throws IOException {
    if (!byteBuffer.hasRemaining()) {
      byteBuffer.clear();
      int nRead = 0;
      while (nRead == 0) {
        nRead = fileChannel.read(byteBuffer);
      }
      if (nRead < 0) {
        return false;
      }
      byteBuffer.flip();
    }
    return true;
  }
145359
private void fill() throws IOException {
        byte[] buffer = getBufIfOpen();
        if (markpos < 0)
            pos = 0;            /* no mark: throw away the buffer */
        else if (pos >= buffer.length)  /* no room left in buffer */
            if (markpos > 0) {  /* can throw away early part of the buffer */
                int sz = pos - markpos;
                System.arraycopy(buffer, markpos, buffer, 0, sz);
                pos = sz;
                markpos = 0;
            } else if (buffer.length >= marklimit) {
                markpos = -1;   /* buffer got too big, invalidate mark */
                pos = 0;        /* drop buffer contents */
            } else if (buffer.length >= MAX_BUFFER_SIZE) {
                throw new OutOfMemoryError("Required array size too large");
            } else {            /* grow buffer */
                int nsz = (pos <= MAX_BUFFER_SIZE - pos) ?
                        pos * 2 : MAX_BUFFER_SIZE;
                if (nsz > marklimit)
                    nsz = marklimit;
                byte nbuf[] = new byte[nsz];
                System.arraycopy(buffer, 0, nbuf, 0, pos);
                if (!compareAndSetBuf(buffer, nbuf)) {
                    // Can't replace buf if there was an async close.
                    // Note: This would need to be changed if fill()
                    // is ever made accessible to multiple threads.
                    // But for now, the only way CAS can fail is via close.
                    // assert buf == null;
                    throw new IOException("Stream closed");
                }
                buffer = nbuf;
            }
        count = pos;
        int n = getInIfOpen().read(buffer, pos, buffer.length - pos);
        if (n > 0)
            count = n + pos;
    }
300115
private boolean twoPhaseCurrentDocMatches() throws IOException {
    if (docId != subSpans.docID()) {
      reset();
      docId = subSpans.docID();
      IndexDoc doc = mtasCodecInfo.getDoc(field, docId);
      if (doc != null) {
        minPosition = doc.minPosition;
        maxPosition = doc.maxPosition;
      } else {
        minPosition = NO_MORE_POSITIONS;
        maxPosition = NO_MORE_POSITIONS;
      }
    }
    if (docId == NO_MORE_DOCS) {
      return false;
    } else {
      return goToNextStartPosition();
    }
  }
1176441
public boolean setPosition(long pos)
    throws IOException
  {
    // Allow seeks to be reflected in the char Reader.
    if (_readEncoding != null) {
      _readEncoding = Encoding.getReadEncoding(this, _readEncodingName);
    }
    
    if (pos < 0) {
      // Return error on seek to negative stream position

      return false;
    }
    
    long delta = pos - getPosition();
    
    long newOffset = _readOffset + delta;
    
    if (newOffset >= 0 && newOffset < _readLength) {
      _readOffset = (int) newOffset;
      
      return true;
    }
    
    if (delta < 0) {
      // Seek backwards in the stream

      _position = pos;
      _readLength = _readOffset = 0;

      if (_source != null) {
        _source.seekStart(pos);

        return true;
      }
      else {
        return false;
      }
    }
    else {
      // Seek forward in the stream, skip any buffered bytes

      long n = pos - getPosition();

      return (skip(n) == n);
    }
  }
555736
private boolean goToNextStartPosition() throws IOException {
    int basicStartPosition;
    int basicEndPosition;
    if (docId == -1 || docId == NO_MORE_DOCS) {
      throw new IOException("no document");
    } else {
      while ((basicStartPosition = subSpans
          .nextStartPosition()) != NO_MORE_POSITIONS) {
        basicEndPosition = subSpans.endPosition();
        startPosition = Math.max(minPosition,
            (basicStartPosition - query.maximumLeft));
        endPosition = Math.min(maxPosition + 1,
            (basicEndPosition + query.maximumRight));
        if (startPosition <= (basicStartPosition - query.minimumLeft)
            && endPosition >= (basicEndPosition + query.minimumRight)) {
          return true;
        }
      }
      return false;
    }
  }