Search in sources :

Example 1 with FileMark

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);
            }
        }
    }
}
Also used : IndexHelper(org.apache.cassandra.io.sstable.IndexHelper) IColumn(org.apache.cassandra.db.IColumn) FileMark(org.apache.cassandra.io.util.FileMark) AbstractType(org.apache.cassandra.db.marshal.AbstractType) ByteBuffer(java.nio.ByteBuffer)

Example 2 with FileMark

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;
}
Also used : FileMark(org.apache.cassandra.io.util.FileMark) ArrayList(java.util.ArrayList)

Aggregations

FileMark (org.apache.cassandra.io.util.FileMark)2 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 IColumn (org.apache.cassandra.db.IColumn)1 AbstractType (org.apache.cassandra.db.marshal.AbstractType)1 IndexHelper (org.apache.cassandra.io.sstable.IndexHelper)1