Read block from file

@param index of block
@return ByteBuffer from pool with data
492770
public ByteBuffer get(final int index) {
		if (!validState) {
			throw new InvalidStateException();
		}
		if (log.isDebugEnabled()) {
			log.debug("get(" + index + ")");
		}
		try {
			if (useMmap) {
				final MappedByteBuffer mbb = getMmapForIndex(index);
				if (mbb != null) {
					return mbb;
				}
				// Fallback to RAF
			}
			final ByteBuffer buf = bufstack.pop();
			fileChannel.position(index * blockSize).read(buf);
			buf.rewind();
			return buf;
		} catch (Exception e) {
			log.error("Exception in get(" + index + ")", e);
		}
		return null;
	}
990671
final long getBlockId(long refBlockId, int index)
        throws IOException
    {
        if (refBlockId == 0) {
            return 0;
        }
        return getBlockId(mBackingFile, refBlockId * mBlockSize + index);
    }
628925
public ByteBuffer getAttributeBuffer(int index) {
        final VertexAttribute attribute = getAttribute(index);
        if (attribute == null) {
            return null;
        }
        return attribute.getData();
    }
1019988
public ByteBuffer readRawBlock() throws IOException, EthereumBlockReadException {
		// basically an Ethereum Block is simply a RLP encoded list
		ByteBuffer result=null;
		// get size of list
		this.in.mark(10);
		byte[] listHeader = new byte[10];
		int totalRead = 0;
		int bRead=this.in.read(listHeader);
		if (bRead == -1) {
			// no further block to read
			return result;
		} else {
			totalRead += bRead;
			while (totalRead < 10) {
				bRead=this.in.read(listHeader, totalRead, 10 - totalRead);
				if (bRead == -1) {
					throw new EthereumBlockReadException("Error: Not enough block data available: " + String.valueOf(bRead));
				}
				totalRead += bRead;
			}
		}
		ByteBuffer sizeByteBuffer=ByteBuffer.wrap(listHeader);
		long blockSize = EthereumUtil.getRLPListSize(sizeByteBuffer); // gets block size including indicator
		this.in.reset();
		// check if blockSize is valid
		if (blockSize==0) {
			throw new EthereumBlockReadException("Error: Blocksize too small");
		}
		if (blockSize<0) {
			throw new EthereumBlockReadException("Error: This block size cannot be handled currently (larger then largest number in positive signed int)");
		}
		if (blockSize>this.maxSizeEthereumBlock) {
			throw new EthereumBlockReadException("Error: Block size is larger then defined in configuration - Please increase it if this is a valid block");
		}
		// read block
		int blockSizeInt=(int)(blockSize);
		byte[] fullBlock=new byte[blockSizeInt];
		int totalByteRead=0;
		int readByte;
		while ((readByte=this.in.read(fullBlock,totalByteRead,blockSizeInt-totalByteRead))>-1) {
				totalByteRead+=readByte;
				if (totalByteRead>=blockSize) {
					break;
				}
		}
		if (totalByteRead!=blockSize) {
			 throw new EthereumBlockReadException("Error: Could not read full block");
		}
		if (!(this.useDirectBuffer)) {
		 	result=ByteBuffer.wrap(fullBlock);	
		} else {
			preAllocatedDirectByteBuffer.clear(); // clear out old bytebuffer
			preAllocatedDirectByteBuffer.limit(fullBlock.length); // limit the bytebuffer
			result=preAllocatedDirectByteBuffer;
			result.put(fullBlock);
			result.flip(); // put in read mode
		}
		result.order(ByteOrder.LITTLE_ENDIAN);	
		return result;
	}
1274969
public byte getValueAsByte(int index) throws IOException {
        if (index >= structure.valueSizes.size()) {
            throw new IOException("Index " + index + " is out of range.");
        }
        return value[index];
    }
403881
public synchronized int read(int blockNumber, int blockOffset, byte[] buffer) 
			throws IOException {
		return read(blockNumber, blockOffset, buffer, 0, buffer.length);
	}
450332
private void readColumnBlock(int startIndex, int blockLength) throws Exception
   {
      int endIndex = startIndex + blockLength;
      List<Integer> blocks = new ArrayList<Integer>();
      for (int index = startIndex; index < endIndex - 11; index++)
      {
         if (matchChildBlock(index))
         {
            int childBlockStart = index - 2;
            blocks.add(Integer.valueOf(childBlockStart));
         }
      }
      blocks.add(Integer.valueOf(endIndex));

      int childBlockStart = -1;
      for (int childBlockEnd : blocks)
      {
         if (childBlockStart != -1)
         {
            int childblockLength = childBlockEnd - childBlockStart;
            try
            {
               readColumn(childBlockStart, childblockLength);
            }
            catch (UnexpectedStructureException ex)
            {
               logUnexpectedStructure();
            }
         }
         childBlockStart = childBlockEnd;
      }
   }
531510
@Override
    public byte get(int index) {
        Preconditions.checkElementIndex(index, this.length, "index");
        return this.array[index + this.startOffset];
    }
845121
public com.google.bigtable.v2.ReadRowsResponse.CellChunk getChunks(int index) {
    return chunks_.get(index);
  }
275404
final ByteBuffer readPointer(int index) {
    int pointerOffset = computePointerOffset(index);
    return sliceOutRange(pointerOffset, pointerOffset + POINTER_SIZE_BYTES);
  }
1218686
private BufferedReader getBulkBufferedReader(int index) throws AsyncApiException {
    return new BufferedReader(new InputStreamReader(
        this.bulkConnection.getQueryResultStream(this.bulkJob.getId(), this.bulkResultIdList.get(index).getBatchId(),
            this.bulkResultIdList.get(index).getResultId()), ConfigurationKeys.DEFAULT_CHARSET_ENCODING));
  }
648888
public byte getByte(final long index)
    {
        if (SHOULD_BOUNDS_CHECK)
        {
            boundsCheck(index);
        }

        return UNSAFE.getByte(null, addressOffset + index);
    }
1297702
public byte[] getByteArrayValue(int index)
   {
      byte[] result = null;

      if (m_array[index] != null)
      {
         result = (byte[]) m_array[index];
      }

      return (result);
   }
637582
void getBytes(byte[] output) {
        if (m_totalAvailable < output.length) {
            throw new IllegalStateException("Requested " + output.length + " bytes; only have "
                    + m_totalAvailable + " bytes; call tryRead() first");
        }

        int bytesCopied = 0;
        while (bytesCopied < output.length) {
            BBContainer firstC = m_readBBContainers.peekFirst();
            if (firstC == null) {
                // Steal the write buffer
                m_poolBBContainer.b().flip();
                m_readBBContainers.add(m_poolBBContainer);
                firstC = m_poolBBContainer;
                m_poolBBContainer = null;
            }
            ByteBuffer first = firstC.b();
            assert first.remaining() > 0;

            // Copy bytes from first into output
            int bytesRemaining = first.remaining();
            int bytesToCopy = output.length - bytesCopied;
            if (bytesToCopy > bytesRemaining) bytesToCopy = bytesRemaining;
            first.get(output, bytesCopied, bytesToCopy);
            bytesCopied += bytesToCopy;
            m_totalAvailable -= bytesToCopy;

            if (first.remaining() == 0) {
                // read an entire block: move it to the empty buffers list
                m_readBBContainers.poll();
                firstC.discard();
            }
        }
    }
283451
public boolean get(long index) throws IOException {
        try {
            lock().acquireReadLock();
            int value = mFile.read(index >> 3);
            return value > 0 && ((value << (index & 7)) & 0x80) != 0;
        }
        catch (InterruptedException e) {
            throw new InterruptedIOException();
        }
        finally {
            lock().releaseLock();
        }
    }
609230
public synchronized ByteBuffer getRecordBuffer(int index) throws IOException {
    if (index < 0 || index >= numrecs) {
      throw new IOException("Access beyond end of file.");
    }
    // Adjust buffer view
    synchronized (map) {
      map.limit(recordsize * (index + 1));
      map.position(recordsize * index);
      return map.slice();
    }
  }
11232
public boolean get(long index) {
    if (!(index < size))
      throw new IndexOutOfBoundsException();
    return (bytes.readLong(offset(index)) & (1l << (position(index)))) != 0;
  }