Exemplo n.º 1
0
static rc_t rr_store_make ( rr_store ** rr )
{
    rc_t rc;
    if ( rr == NULL )
        rc = RC ( rcXF, rcFunction, rcConstructing, rcSelf, rcNull );
    else
    {
        KVector * v;
        *rr = NULL;
        rc = KVectorMake ( &v );
        if ( rc == 0 )
        {
            rr_store * obj = malloc ( sizeof * obj );
            if ( obj == NULL )
            {
                KVectorRelease ( v );
                rc = RC ( rcXF, rcFunction, rcConstructing, rcMemory, rcExhausted );
            }
            else
            {
                obj -> v = v;
                *rr = obj;
            }
        }
    }
    return rc;
}
Exemplo n.º 2
0
static rc_t TableWriterSeq_CollectStatistics(TableWriterSeq *self, const TableWriterData* primary_alignment_id)
{
    rc_t rc;
    int64_t mate[2] = {0, 0};
    uint64_t distance = 0;
    uint64_t count = 0;
    
    memcpy(mate, primary_alignment_id->buffer, sizeof(mate[0]) * primary_alignment_id->elements);
    if (mate[0] && mate[1]) {
        distance = (mate[0] < mate[1]) ? (mate[1] - mate[0]) : (mate[0] - mate[1]);
    }
    else
        return 0;
    if (self->stats == NULL) {
        rc = KVectorMake(&self->stats); if (rc) return rc;
    }
    rc = KVectorGetU64(self->stats, distance, &count);
    if (GetRCObject(rc) == rcItem && GetRCState(rc) == rcNotFound) {
        rc = KVectorSetU64(self->stats, distance, 1);
        if (rc == 0) ++self->statsCount;
    }
    else if (rc == 0) {
        ++count;
        rc = KVectorSetU64(self->stats, distance, count);
    }
    return rc;
}
Exemplo n.º 3
0
struct rna_splice_dict * make_rna_splice_dict( void )
{
    struct rna_splice_dict * res = NULL;
    KVector * v;
    rc_t rc = KVectorMake ( &v );
    if ( rc == 0 )
    {
        res = calloc( 1, sizeof * res );
        if ( res != NULL )
        {
            res->v = v;
        }
        else
        {
            KVectorRelease ( v );
        }
    }
    return res;
}
Exemplo n.º 4
0
static rc_t save_store( struct sorter * sorter )
{
    rc_t rc = 0;
    if ( sorter->bytes_in_store > 0 )
    {
        char buffer[ 4096 ];
        struct lookup_writer * writer;
        
        if ( sorter->params.mem_limit > 0 )
        {
            rc = make_subfilename( &sorter->params, sorter->sub_file_id, buffer, sizeof buffer );
            if ( rc == 0 )
                sorter->sub_file_id++;
        }
        else
            rc = make_dst_filename( &sorter->params, buffer, sizeof buffer );

        if ( rc == 0 )
            rc = make_lookup_writer( sorter->params.dir, NULL, &writer, sorter->params.buf_size, "%s", buffer );
        
        if ( rc == 0 )
        {
            rc = KVectorVisitPtr( sorter->store, false, on_store_entry, writer );
            release_lookup_writer( writer );
        }
        if ( rc == 0 )
        {
            sorter->bytes_in_store = 0;
            rc = KVectorRelease( sorter->store );
            if ( rc != 0 )
                ErrMsg( "KVectorRelease() -> %R", rc );
            else
            {
                sorter->store = NULL;
                rc = KVectorMake( &sorter->store );
                if ( rc != 0 )
                    ErrMsg( "KVectorMake() -> %R", rc );
            }
        }
    }
    return rc;
}
Exemplo n.º 5
0
static spotgrp * make_spotgrp( const char *src, const size_t len )
{
    spotgrp * sg = calloc( 1, sizeof sg[ 0 ] );
    if ( sg != NULL )
    {
        String s;
        StringInit( &s, src, len, len );
        if ( StringCopy ( &sg->name, &s ) != 0 )
        {
            free( sg );
            sg = NULL;
        }
#ifdef USE_JUDY
        else
        {
            KVectorMake ( &sg->v );
        }
#endif
    }
    return sg;
}
Exemplo n.º 6
0
static rc_t init_sorter( struct sorter * sorter, const sorter_params * params )
{
    rc_t rc = KVectorMake( &sorter->store );
    if ( rc != 0 )
        ErrMsg( "KVectorMake() -> %R", rc );
    else
    {
        rc = make_SBuffer( &sorter->buf, 4096 );
        if ( rc == 0 )
        {
            sorter->params.dir = params->dir;
            sorter->params.output_filename = params->output_filename;
            sorter->params.index_filename = NULL;
            sorter->params.temp_path = params->temp_path;
            sorter->params.src = params->src;
            sorter->params.buf_size = params->buf_size;
            sorter->params.mem_limit = params->mem_limit;
            sorter->params.prefix = params->prefix;
            sorter->bytes_in_store = 0;
            sorter->sub_file_id = 0;
        }
    }
    return rc;
}