예제 #1
0
static void CC qstats_whack(void *vp)
{
    self_t *self = vp;
    VTable *tbl;
    writer_ctx_t ctx;
    
    memset(&ctx, 0, sizeof(ctx));
    ctx.alignMode = self->alignMode;
    
    ctx.rc = OpenTableAndCursor(self->db, &tbl, &ctx.curs, self->alignMode ? 10 : 7);
    VDatabaseRelease(self->db);
    if (ctx.rc == 0) {
        foreach_statistic(&self->stat, qstats_write, self);
        VCursorRelease(ctx.curs);
        if (ctx.rc == 0)
            VTableReindex(tbl);
        VTableRelease(tbl);
    }
    whack_statistic(&self->stat);
    free(self);
}
예제 #2
0
static rc_t gater_and_write( context *ctx )
{
    KDirectory *dir;
    rc_t rc = KDirectoryNativeDir( &dir );
    if ( rc != 0 )
        LogErr( klogInt, rc, "KDirectoryNativeDir() failed\n" );
    else
    {
        statistic data;
        rc = make_statistic( &data, ctx->gc_window, ctx->ignore_mismatch );
        if ( rc == 0 )
        {
            rc = gather_statistic( &data, dir, ctx ); /* <--- the meat */
            if ( rc == 0 )
            {
                uint64_t written;

                if ( ctx->show_progress )
                {
                    OUTMSG(( "%lu statistic-entries gathered\n", data.entries ));
                    OUTMSG(( "max. cycles per read = %u\n", data.max_cycle ));
                }

                switch( ctx->output_mode[ 0 ] )
                {
                case 'f' :  if ( ctx->output_file_path != NULL )
                            {
                                rc = write_output_file( dir, &data,
                                        ctx->output_file_path, &written );
                                if ( rc == 0 && ctx->info )
                                {
                                    OUTMSG(( "%lu lines written to '%s'\n", 
                                            written, ctx->output_file_path ));
                                }
                            }
                            else
                                OUTMSG(( "the output-path is missing!\n" ));
                            break;

                case 'd' :  rc = write_statistic_into_db( dir, &data,
                                    ctx->src_schema_list, ctx->src_path, &written,
                                    ctx->show_progress );
                            if ( rc == 0 && ctx->info )
                            {
                                OUTMSG(( "%lu rows written to database\n", written ));
                            }
                            break;

                case 't' :  if ( ctx->output_file_path != NULL )
                            {
                                rc = write_statistic_into_tab( dir, &data, 
                                        ctx->src_schema_list, ctx->output_file_path, &written,
                                        ctx->show_progress );
                                if ( rc == 0 && ctx->info )
                                {
                                    OUTMSG(( "%lu rows written to table\n", written ));
                                }
                            }
                            else
                            {
                                OUTMSG(( "the output-path is missing!\n" ));
                            }
                            break;
                }
            }
            whack_statistic( &data );
        }
        KDirectoryRelease( dir );
    }
    return rc;
}