// TODO this function should be somewhere in shared place
  @SuppressWarnings({"rawtypes", "unchecked"})
  protected final Object readAtOnce(LVReplicaPartition partition, LVColumn column)
      throws IOException {
    ColumnFileReaderBundle reader = getReader(partition, column);

    int tupleCount = reader.getDataReader().getTotalTuples();
    LOG.info("reading " + column.getName() + " at once...");
    ValueTraits traits = ValueTraitsFactory.getInstance(column.getType());
    Object array = traits.createArray(tupleCount);
    int read = ((TypedReader) reader.getDataReader()).readValues(array, 0, tupleCount);
    LOG.info("read.");
    reader.close();
    assert (read == tupleCount);

    return array;
  }
 // TODO this function should be somewhere in shared place
 protected final ColumnFileReaderBundle getReader(LVReplicaPartition partition, LVColumn column)
     throws IOException {
   assert (partition.getNodeId().intValue() == context.nodeId);
   LVColumnFile file =
       context.metaRepo.getColumnFileByReplicaPartitionAndColumn(
           partition.getPartitionId(), column.getColumnId());
   assert (file != null);
   ColumnFileBundle fileBundle = new ColumnFileBundle(file);
   return new ColumnFileReaderBundle(fileBundle, 0); // no buffering needed. we read them at once
 }