static rc_t write_statistic( statistic_writer *writer, statistic *data, uint64_t * written, bool show_progress ) { writer_ctx ctx; uint64_t count; ctx.writer = writer; ctx.rc = 0; ctx.progress = NULL; if ( show_progress ) { make_progressbar( &ctx.progress ); ctx.entries = data->entries; ctx.fract_digits = progressbar_calc_fract_digits( ctx.entries ); ctx.n = 0; } count = foreach_statistic( data, write_cb, &ctx ); if ( show_progress ) { destroy_progressbar( ctx.progress ); OUTMSG(( "\n" )); } if ( written != NULL ) *written = count; return ctx.rc; }
static rc_t cg_dump_src_dst_rows_cur( cg_dump_opts * opts, cg_dump_ctx * cg_ctx ) { /* preparations */ rc_t rc = cg_dump_prepare_seq_tab( cg_ctx ); /* if ( rc == 0 ) rc = cg_dump_prepare_prim_tab( cg_ctx ); */ if ( rc == 0 ) rc = cg_dump_adjust_rowrange( cg_ctx ); if ( rc == 0 ) rc = cg_dump_setup_progressbar( cg_ctx ); if ( rc == 0 ) rc = cg_dump_prepare_output( opts, cg_ctx ); /* loop through the SEQUENCE-table */ if ( rc == 0 ) { rc = cg_dump_loop( opts, cg_ctx ); /* <================== */ if ( cg_ctx->progress != NULL ) destroy_progressbar( cg_ctx->progress ); BSTreeWhack ( &cg_ctx->lanes, whack_lanes_nodes, NULL ); KDirectoryRelease( cg_ctx->out_dir ); } return rc; }
rc_t write_output_file( KDirectory *dir, statistic * data, const char * path, uint64_t * written ) { write_ctx wctx; rc_t rc; if ( written != NULL ) { *written = 0; } wctx.out = NULL; wctx.pos = 0; wctx.lines = 0; rc = KDirectoryCreateFile ( dir, &wctx.out, false, 0664, kcmInit, path ); if ( rc != 0 ) LogErr( klogInt, rc, "KDirectoryCreateFile() failed\n" ); else { char buffer[ 256 ]; size_t num_writ; rc = string_printf ( buffer, sizeof buffer, &num_writ, "SPOTGROUP\tCYCLE\tNRead\tDIMER\tGC_CONTENT\tHP_RUN\tMaxQ\tQuality\tTOTAL\tMISMATCH\n" ); if ( rc == 0 ) { size_t f_writ; rc = KFileWrite ( wctx.out, wctx.pos, buffer, num_writ, &f_writ ); if ( rc == 0 ) { if ( written != NULL ) *written = f_writ; wctx.pos += f_writ; make_progressbar( &wctx.progress ); wctx.entries = data->entries; wctx.fract_digits = progressbar_calc_fract_digits( wctx.entries ); foreach_statistic( data, write_to_file_cb, &wctx ); destroy_progressbar( wctx.progress ); OUTMSG(( "\n" )); KFileRelease ( wctx.out ); if ( written != NULL ) { *written = wctx.lines; } } } } return rc; }
static rc_t CC bg_progress_thread_func( const KThread *self, void *data ) { rc_t rc = 0; bg_progress * bgp = data; if ( bgp != NULL ) { rc = make_progressbar( & bgp -> progressbar, bgp -> digits ); if ( rc == 0 ) { bgp -> cur = 0; update_progressbar( bgp -> progressbar, bgp -> cur ); while ( atomic_read( &bgp -> done ) == 0 ) { bg_progress_steps( bgp ); KSleepMs( bgp -> sleep_time ); } bg_progress_steps( bgp ); destroy_progressbar( bgp -> progressbar ); } } return rc; }
static rc_t read_loop( statistic * data, context *ctx, statistic_reader *reader, const VCursor *my_cursor ) { int64_t first; uint64_t count; rc_t rc = query_reader_rowrange( reader, &first, &count ); if ( rc != 0 ) LogErr( klogInt, rc, "query_statistic_rowrange() failed\n" ); else { if ( num_gen_empty( ctx->row_generator ) ) { rc = num_gen_add( ctx->row_generator, first, count ); if ( rc != 0 ) LogErr( klogInt, rc, "num_gen_add() failed() failed\n" ); } else { rc = num_gen_trim( ctx->row_generator, first, count ); if ( rc != 0 ) LogErr( klogInt, rc, "num_gen_trim() failed() failed\n" ); } if ( rc == 0 ) { const num_gen_iter *iter; rc = num_gen_iterator_make( ctx->row_generator, &iter ); if ( rc != 0 ) LogErr( klogInt, rc, "num_gen_iterator_make() failed\n" ); else { uint64_t row_id; progressbar * progress; rc = make_progressbar( &progress ); if ( rc != 0 ) LogErr( klogInt, rc, "make_progressbar() failed\n" ); else { uint8_t fract_digits = calc_fract_digits( iter ); uint32_t percent; row_input row_data; while ( ( num_gen_iterator_next( iter, &row_id ) == 0 )&& ( rc == 0 ) ) { rc = Quitting(); if ( rc == 0 ) { /* ******************************************** */ rc = reader_get_data( reader, &row_data, row_id ); if ( rc == 0 ) { rc = extract_statistic_from_row( data, &row_data, row_id ); } /* ******************************************** */ if ( ctx->show_progress ) if ( num_gen_iterator_percent( iter, fract_digits, &percent ) == 0 ) update_progressbar( progress, fract_digits, percent ); } } destroy_progressbar( progress ); if ( ctx->show_progress ) OUTMSG(( "\n" )); } num_gen_iterator_destroy( iter ); } } } return rc; }