Skip to content

Commit

Permalink
User Interface: show user version at "-v" + add internal info to stat…
Browse files Browse the repository at this point in the history
…istics "-s"

  Note that now "-q" (quiet) will supress the internal info saving.
  • Loading branch information
Josef Ezra committed Jan 26, 2020
1 parent 1cb5fd4 commit 357a56a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 26 deletions.
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -82,4 +82,3 @@ Contact
-------
Josef Ezra (jezra at infinidat.com), (jezra at cpan.org)


14 changes: 8 additions & 6 deletions config.cpp
Expand Up @@ -41,6 +41,9 @@
#include "config.hpp"

// Globals
static const int internal_version = 6; // inernal version
static const char* user_version="2.03";

unsigned long long g_record_count = 0;
unsigned long long g_genofs_count = 0;

Expand Down Expand Up @@ -170,7 +173,7 @@ Usage: \n\
-v : version : internal version \n\
-h : help : this message \n\
-s : stat : information about a compressed file \n\
-q : (redundant, will be removed) \n\
-q : suppress extra stats info that could have been seen by -s \n\
\n\
DWIM (Do what I mean) - Intuitive use of 'slimfastq A B' : \n\
If A appears to be a fastq file, and:\n\
Expand Down Expand Up @@ -216,9 +219,9 @@ static void check_op(int something, char chr) {

Config::Config(){

version = 0;
version = internal_version;

quiet = true;
quiet = false;
profiling = false;
encode = true;
level = 3;
Expand All @@ -233,12 +236,11 @@ static int range_level(int level) {
}

static bool initialized = false;
void Config::init(int argc, char **argv, int ver) {
void Config::init(int argc, char **argv) {
if (initialized)
croak("Internal error: 2nd Config init");

initialized = true;
version = ver;

std::string usr, fil;
bool overwrite = false;
Expand All @@ -264,7 +266,7 @@ void Config::init(int argc, char **argv, int ver) {
case 'P': profiling = true ; break;
case 'q': quiet = true ; break;
case 'v':
printf("Version %u\n", version);
printf("Version %s\nInternal format version=%u\n", user_version, version);
exit(0);
case 'h':
usage();
Expand Down
2 changes: 1 addition & 1 deletion config.hpp
Expand Up @@ -37,7 +37,7 @@ class Config {
public:
Config();
~Config();
void init (int argc, char **argv, int ver);
void init (int argc, char **argv);
void finit();
FILE * file_usr() const { return reinterpret_cast<FILE*>(f_usr);}
int version, level, decoder_version;
Expand Down
5 changes: 2 additions & 3 deletions gens.cpp
Expand Up @@ -81,9 +81,8 @@ GenSave::GenSave() {

GenSave::~GenSave() {
rcoder.done();
if (not conf.quiet and filer and x_Ns and x_Nn)
fprintf(stderr, "::: GEN comp size: %lu \t| Ns: %lu, Nn: %lu\n",
filer->tell(), x_Ns->tell(), x_Nn->tell());
if (not conf.quiet) {
}
delete []ranger;
delete filer;

Expand Down
4 changes: 1 addition & 3 deletions main.cpp
Expand Up @@ -43,16 +43,14 @@
#include <errno.h>
#include <stdlib.h>

static const int version = 6; // inernal version

#include "common.hpp"
#include "config.hpp"
#include "usrs.hpp"

Config conf;
int main(int argc, char** argv) {

conf.init(argc, argv, version);
conf.init(argc, argv);
int ret =
conf.encode ?
UsrSave () . encode() :
Expand Down
7 changes: 5 additions & 2 deletions qlts.cpp
Expand Up @@ -54,8 +54,11 @@ QltSave::QltSave() {

QltSave::~QltSave() {
rcoder.done();
if (not conf.quiet and filer)
fprintf(stderr, "::: QLT comp size: %lu \t| high qlt cnt: %u\n", filer->tell(), m_last.extra_hi_qlt);
if (not conf.quiet) {
if (m_last.extra_hi_qlt) {
conf.set_info("qlt.extra.hi", m_last.extra_hi_qlt);
}
}

delete [] ranger;
delete filer;
Expand Down
6 changes: 2 additions & 4 deletions recs.cpp
Expand Up @@ -50,10 +50,8 @@ RecSave::RecSave() {

RecSave::~RecSave() {
rcoder.done();
if (not conf.quiet and filer and x_file)
fprintf(stderr, "::: REC comp size: %lu \t| EX size: %lu | bigint: %u | str num/size: %u/%u | newline num/size: %u/%u\n",
filer->tell(), x_file->tell(),
stats.big_i, stats.str_n, stats.str_l, stats.new_n, stats.new_l);
if (not conf.quiet) {
}

DELETE(filer);
DELETE(x_file);
Expand Down
26 changes: 20 additions & 6 deletions usrs.cpp
Expand Up @@ -62,12 +62,26 @@ UsrSave::UsrSave() {

UsrSave::~UsrSave(){
if (not conf.quiet) {
fprintf(stderr, "::: USR num recs: %llu \t| EX size len/qlen/sgen/sqlt: %lu/%lu/%lu/%lu\n", g_record_count-1,
x_llen->tell(), x_qlen->tell(), x_sgen->tell(), x_sqlt->tell());
if (x_lrec and
x_lrec->tell())
fprintf(stderr, "::: USR oversized records: rec/gen/qlt %lu/%lu/%lu\n",
x_lrec->tell(), x_lgen->tell(), x_lqlt->tell());
char b[0x100];
UINT64 long_gen=x_llen->tell();
UINT64 long_qlt=x_qlen->tell();
if (long_gen or long_qlt) {
sprintf(b, "gen:%llu qlt:%llu", long_gen, long_qlt);
conf.set_info("log.size.change", b);
}
UINT64 sol_gen_pf=x_sgen->tell();
UINT64 sol_qlt_pf=x_sqlt->tell();
if (sol_gen_pf or sol_qlt_pf) {
sprintf(b, "gen:%llu qlt:%llu", sol_gen_pf, sol_qlt_pf);
conf.set_info("log.solid.pf", b);
}
UINT64 os_rec=x_lrec->tell();
UINT64 os_gen=x_lgen->tell();
UINT64 os_qlt=x_lqlt->tell();
if (os_rec or os_gen or os_qlt) {
sprintf(b, "rec:%llu gen:%llu qlt:%llu", os_rec, os_gen, os_qlt);
conf.set_info("log.oversize", b);
}
}
DELETE(x_llen);
DELETE(x_qlen);
Expand Down

0 comments on commit 357a56a

Please sign in to comment.