use of org.apache.cassandra.io.util.FileMark in project eiger by wlloyd.
the class SSTableNamesIterator method readIndexedColumns.
private void readIndexedColumns(CFMetaData metadata, FileDataInput file, SortedSet<ByteBuffer> columnNames, List<ByteBuffer> filteredColumnNames, List<IndexHelper.IndexInfo> indexList) throws IOException {
// column count
file.readInt();
/* get the various column ranges we have to read */
AbstractType comparator = metadata.comparator;
SortedSet<IndexHelper.IndexInfo> ranges = new TreeSet<IndexHelper.IndexInfo>(IndexHelper.getComparator(comparator, false));
for (ByteBuffer name : filteredColumnNames) {
int index = IndexHelper.indexFor(name, indexList, comparator, false);
if (index == indexList.size())
continue;
IndexHelper.IndexInfo indexInfo = indexList.get(index);
if (comparator.compare(name, indexInfo.firstName) < 0)
continue;
ranges.add(indexInfo);
}
FileMark mark = file.mark();
for (IndexHelper.IndexInfo indexInfo : ranges) {
file.reset(mark);
FileUtils.skipBytesFully(file, indexInfo.offset);
// TODO only completely deserialize columns we are interested in
while (file.bytesPastMark(mark) < indexInfo.offset + indexInfo.width) {
IColumn column = cf.getColumnSerializer().deserialize(file);
// we check vs the original Set, not the filtered List, for efficiency
if (columnNames.contains(column.name())) {
cf.addColumn(column);
}
}
}
}
use of org.apache.cassandra.io.util.FileMark in project eiger by wlloyd.
the class IndexHelper method deserializeIndex.
/**
* Deserialize the index into a structure and return it
*
* @param in - input source
*
* @return ArrayList<IndexInfo> - list of de-serialized indexes
* @throws IOException if an I/O error occurs.
*/
public static ArrayList<IndexInfo> deserializeIndex(FileDataInput in) throws IOException {
int columnIndexSize = in.readInt();
if (columnIndexSize == 0)
return null;
ArrayList<IndexInfo> indexList = new ArrayList<IndexInfo>();
FileMark mark = in.mark();
while (in.bytesPastMark(mark) < columnIndexSize) {
indexList.add(IndexInfo.deserialize(in));
}
assert in.bytesPastMark(mark) == columnIndexSize;
return indexList;
}
Aggregations