Ejemplo n.º 1
0
static rc_t write_to_sorter( struct sorter * sorter, int64_t seq_spot_id, uint32_t seq_read_id,
        const String * unpacked_bases )
{
    /* we write it to the store...*/
    rc_t rc;
    const String * to_store;    
    pack_4na( unpacked_bases, &sorter->buf );
    rc = StringCopy( &to_store, &sorter->buf.S );
    if ( rc != 0 )
        ErrMsg( "StringCopy() -> %R", rc );
    else
    {
        uint64_t key = make_key( seq_spot_id, seq_read_id );
        rc = KVectorSetPtr( sorter->store, key, (const void *)to_store );
        if ( rc != 0 )
            ErrMsg( "KVectorSetPtr() -> %R", rc );
        else
        {
            size_t item_size = ( sizeof key ) + ( sizeof *to_store ) + to_store->size;
            sorter->bytes_in_store += item_size;
        }
    }
    
    if ( rc == 0 &&
         sorter->params.mem_limit > 0 &&
         sorter->bytes_in_store >= sorter->params.mem_limit )
        rc = save_store( sorter );
    return rc;
}
Ejemplo n.º 2
0
static bool rr_store_alignment( rr_store * rr, int64_t align_id, const VCursor * curs, uint32_t read_idx )
{
    bool res = false;
    const INSDC_4na_bin * read = NULL;
    uint32_t read_len;
    rc_t rc = VCursorCellDataDirect( curs, align_id, read_idx, NULL, ( const void** ) &read, NULL, &read_len );
    if ( rc == 0 )
    {
        rr_entry * entry;
        res = rr_entry_make ( &entry, read, read_len );
        if ( res )
        {
            uint64_t key = ( uint64_t ) align_id;
            res = ( KVectorSetPtr ( rr -> v, key, entry ) == 0 );
            if ( !res )
                rr_entry_release( key, entry, NULL );
        }
    }
    return res;
}