A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/dbapi__testspeed_8cpp_source.html below:

NCBI C++ ToolKit: src/dbapi/driver/samples/dbapi_testspeed/dbapi_testspeed.cpp Source File

37 #include "../dbapi_sample_base.hpp" 116  "Server:port for gateway database driver\n" 117  "(only one of -d/-g is required to be present)"

,

129  "b"

,

"text_blob_size"

,

130  "Text blob size in kilobytes"

,

136  "c"

,

"column_count"

,

137  "Column count 1..5 (int_val fl_val date_val str_val txt_val)"

,

149  "m"

,

"mode_character"

,

151  " r write and read as usual,\n" 152  " use CDB_Result->ReadItem() instead of GetItem() whenever possible\n" 153  " w write to the table, do not read, do not delete it\n" 154  " R read using ReadItem() (can be done many times after '-m w' )\n" 155  " G read using GetItem() (can be done many times after '-m w' )"

,

161  "FILE"

,

"mode_character"

,

162  "Upload the specified file as a blob into the table,\n" 163  "then download it to \"./testspeed.out\" \n" 164  "\"diff\" can then be used to verify the data.\n" 165  "-r -b -c parameterss are ignored.\n"

,

181  bool

readItems =

false

;

182  bool

writeOnly =

false

;

183  bool

selectOnly =

false

;

194

host_name = args[

"g"

].AsString();

198

port_num = host_name.substr(

i

+ 1 );

199

host_name.resize(

i

);

208

row_count = args[

"r"

].AsInteger();

209  if

( row_count < 1 || row_count > 0x100000 ) {

210

cerr <<

"Error -- invalid row count; valid values are 1 .. 1 Meg.\n"

;

216

col_count = args[

"g"

].AsInteger();

220

blob_size = args[

"b"

].AsInteger();

221  if

( blob_size < 1 || blob_size > 1024000 ) {

222

cerr <<

"Error -- invalid blob size; valid values are 1 (kb) to 1000 (kb)\n"

;

225  if

( col_count < 5 ) {

226

cerr <<

"Error -- blob size makes sense for '-c 5' only.\n"

;

235  string

key_value = args[

"m"

].AsString();

237  switch

( key_value[0] ) {

252

cerr <<

"Error -- invalid mode character '"

<< key_value <<

"'\n"

;

258  if

(args[

"FILE"

]) {

259

fileParam = args[

"FILE"

].AsString();

264  if

( !host_name.empty() ) {

267  if

( !port_num.empty() ) {

272

unique_ptr<CDB_LangCmd> set_cmd;

273

unique_ptr<CDB_LangCmd> ins_cmd;

274

unique_ptr<CDB_BCPInCmd> bcp;

276  string

cmd_str(

"set textsize 1024000"

);

279  while

( set_cmd->HasMoreResults() ) {

280

unique_ptr<CDB_Result>

r

(set_cmd->Result());

287

cout <<

", rows "

<< row_count;

288

cout <<

", cols "

<< col_count;

289

cout <<

", blob size "

<< blob_size <<

"\n"

;

291  if

( col_count > 4 ) {

295  string

s =

"insert into "

;

300  if

( col_count > 1 ) {

304  if

( col_count > 2 ) {

308  if

( col_count > 3 ) {

327  if

( !fileParam.empty() ) {

330  if

( !

f

.is_open() ) {

331

cerr <<

"Error -- cannot read '"

<< fileParam <<

"'\n"

;

336  while

(

f

.good() && !

f

.eof() ) {

337  f

.read(

buf

,

sizeof

(

buf

) );

338

sz = (size_t)

f

.gcount();

339  if

( sz == 0 )

break

;

341  if

( sz !=

sizeof

(

buf

) )

break

;

347

}

else if

( col_count > 4 ) {

348  for

(

i

= 0;

i

< blob_size; ++

i

) {

350  for

(

int

j = 0; j < 32; ++j ) {

351

pTxt.

Append

(

"If you want to know who we are--"

);

360

bcp->Bind(0, &int_val);

361  if

( col_count > 1 ) bcp->Bind(1, &fl_val );

362  if

( col_count > 2 ) bcp->Bind(2, &date_val);

363  if

( col_count > 3 ) bcp->Bind(3, &str_val );

364  if

( col_count > 4 ) bcp->Bind(4, &pTxt );

367  if

( !ins_cmd->BindParam(

"@i"

, &int_val) ) {

368

cerr <<

"Error in BindParam()\n"

;

373  if

( col_count > 1 ) ins_cmd->BindParam(

"@f"

, &fl_val );

374  if

( col_count > 2 ) ins_cmd->BindParam(

"@d"

, &date_val );

375  if

( col_count > 3 ) ins_cmd->BindParam(

"@s"

, &str_val );

378  for

(

i

= 0;

i

< row_count; ++

i

) {

380

fl_val =

static_cast<float>

(

i

+ 0.999);

381  if

( !fileParam.empty() ) {

384

fileEntry.

GetTime

(&fileTime);

389

date_val = date_val.

Value

();

390

str_val =

string

(

"Franz Joseph Haydn symphony # "

) +

399

bcp->CompleteBatch();

406  while

( ins_cmd->HasMoreResults() ) {

407

unique_ptr<CDB_Result>

r

(ins_cmd->Result());

414

timeElapsed = timer.

Elapsed

();

423  if

( !fileParam.empty() ) {

428

timeElapsed = timer.

Elapsed

();

433  if

( !(selectOnly || writeOnly) ) {

454  string query

=

"select date_val,str_val,txt_val from "

;

460  while

( lcmd->HasMoreResults() ) {

461

unique_ptr<CDB_Result>

r

(lcmd->Result());

462  if

( !

r

.get() )

continue

;

465  while

(

r

->Fetch() ) {

468  for

(

unsigned int

j = 0; j <

r

->NofItems(); j++ ) {

471  if

( readItems && rt ==

eDB_Text

) {

477  size_t

len_txt =

r

->ReadItem

478

(txt_buf,

sizeof

(txt_buf), &isNull);

480  if

( isNull || len_txt<=0 )

break

;

481  f

.write(txt_buf, len_txt);

489  r

->GetItem(&str_val);

492  r

->GetItem(&date_val);

495  r

->GetItem(&text_val);

497  if

( text_val.

IsNULL

() ) {

504

= text_val.

Read

(txt_buf,

sizeof

(txt_buf));

505  if

(len_txt == 0)

break

;

506  f

.write(txt_buf, len_txt);

520

cout <<

"File "

<< str_val.

AsString

() <<

" dated " 521

<< date_val.

Value

().

AsString

() <<

" was written to testspeed.out using " 522

<< (readItems?

"ReadItem"

:

"GetItem"

) <<

"\n"

;

532  string query

=

"select int_val,fl_val,date_val,str_val,txt_val from "

;

538  while

( lcmd->HasMoreResults() ) {

539

unique_ptr<CDB_Result>

r

(lcmd->Result());

540  if

( !

r

.get() )

continue

;

543  while

(

r

->Fetch() ) {

545  for

(

unsigned int

j = 0; j <

r

->NofItems(); ++j ) {

548  const string

iname =

r

->ItemName(j);

557  while

( j == (

unsigned int

)

r

->CurrentItemNo() ) {

558

sz +=

r

->ReadItem(

buf

,

sizeof

(

buf

), &isNull);

566  r

->GetItem(&str_val);

571  r

->GetItem(&int_val);

572  if

( int_val.

IsNULL

() ) {

579  r

->GetItem(&fl_val);

580  if

( fl_val.

IsNULL

() ) {

587  r

->GetItem(&fl_val);

588  if

( fl_val.

IsNULL

() ) {

595  r

->GetItem(&date_val);

596  if

( date_val.

IsNULL

() ) {

603  r

->GetItem(&text_val);

605  if

( text_val.

IsNULL

() ) {

626 int main

(

int

argc,

char

* argv[])

void DeleteTable(const string &table_name)

void SetDriverName(const string &name)

Set driver name.

void SetDatabaseParameter(const string &name, const string &value)

Set database connection parameter.

const string & GetDriverName(void) const

Return current driver name.

void DeleteLostTables(void)

Delete tables which are lost after previous tests.

CDB_Connection & GetConnection(void)

Get connection created using server, username and password specified in the application command line.

void CreateTable(const string &table_name)

function CreateTable is creating table in the database

virtual void InitSample(CArgDescriptions &arg_desc)

Override these 3 to suit your test's needs.

void FetchResults(const string &table_name, bool readItems)

virtual ~CDbapiTestSpeedApp(void)

string GetTableName(void) const

virtual int RunSample(void)

void FetchFile(const string &table_name, bool readItems)

int main(int argc, char *argv[])

std::ofstream out("events_result.xml")

main entry point for tests

static const char table_name[]

virtual const CArgs & GetArgs(void) const

Get parsed command line arguments.

int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)

Main function (entry point) for the NCBI application.

void SetConstraint(const string &name, const CArgAllow *constraint, EConstraintNegate negate=eConstraint)

Set additional user defined constraint on argument value.

void AddOptionalKey(const string &name, const string &synopsis, const string &comment, EType type, TFlags flags=0)

Add description for optional key without default value.

void AddDefaultKey(const string &name, const string &synopsis, const string &comment, EType type, const string &default_value, TFlags flags=0, const string &env_var=kEmptyStr, const char *display_value=nullptr)

Add description for optional key with default value.

@ eInputFile

Name of file (must exist and be readable)

@ eString

An arbitrary string.

@ eInteger

Convertible into an integer number (int or Int8)

static CDB_UserHandler & GetDefault(void)

virtual bool HandleIt(CDB_Exception *ex)=0

Handle the exceptions resulting from a native API call, one-by-one.

virtual size_t Append(const void *buff, size_t nof_bytes)

virtual bool MoveTo(size_t byte_number)

const string & AsString(void) const

virtual size_t Read(void *buff, size_t nof_bytes)

const CTime & Value(void) const

bool GetTime(CTime *modification, CTime *last_access=0, CTime *creation=0) const

Get time stamp(s) of a directory entry.

IO_PREFIX::ofstream CNcbiOfstream

Portable alias for ofstream.

IO_PREFIX::ifstream CNcbiIfstream

Portable alias for ifstream.

NCBI_NS_STD::string::size_type SIZE_TYPE

static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)

Convert double to string.

static string IntToString(int value, TNumToStringFlags flags=0, int base=10)

Convert int to string.

static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)

Find the pattern in the string.

double Elapsed(void) const

Return time elapsed since first Start() or last Restart() call (in seconds).

string AsString(const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const

Transform time to string.

void Start(void)

Start the timer.

@ eCurrent

Use current time. See also CCurrentTime.

constexpr bool empty(list< Ts... >) noexcept

Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...

Defines: CTimeFormat - storage class for time format.

std::istream & in(std::istream &in_, double &x_)

double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4