Esempio 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;
}
Esempio n. 2
0
rc_t write_unpacked_to_lookup_writer( struct lookup_writer * writer,
                                      int64_t seq_spot_id,
                                      uint32_t seq_read_id,
                                      const String * bases_as_unpacked_4na )
{
    uint64_t key = make_key( seq_spot_id, seq_read_id ); /* helper.c */
    rc_t rc = pack_4na( bases_as_unpacked_4na, &writer -> buf ); /* helper.c */
    if ( rc != 0 )
        ErrMsg( "write_unpacked_to_lookup_writer() -> %R", rc );
    else
        rc = write_packed_to_lookup_writer( writer, key, &writer -> buf . S );
    return rc;
}