1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
* ndbapi_scan.cpp:
* Illustrates how to use the scan api in the NDBAPI.
* The example shows how to do scan, scan for update and scan for delete
* using NdbScanFilter and NdbScanOperation
*
* Classes and methods used in this example:
*
* Ndb
* init()
* waitUntilRead()
* getDictionary()
* startTransaction()
* closeTransaction()
* sendPreparedTransactions()
* pollNdb()
*
* NdbConnection
* getNdbOperation()
* executeAsynchPrepare()
* getNdbError()
* executeScan()
* nextScanResult()
*
* NdbDictionary::Dictionary
* getTable()
* dropTable()
* createTable()
*
* NdbDictionary::Column
* setName()
* setPrimaryKey()
* setType()
* setLength()
* setNullable()
*
* NdbDictionary::Table
* setName()
* addColumn()
*
* NdbOperation
* insertTuple()
* equal()
* setValue()
* openScanRead()
* openScanExclusive()
*
* NdbRecAttr
* aRef()
* u_32_value()
*
* NdbResultSet
* nextResult()
* deleteTuple()
* updateTuple()
*
* NdbScanOperation
* getValue()
* readTuplesExclusive()
*
* NdbScanFilter
* begin()
* eq()
* end()
*
*
*/
#include <ndb_global.h>
#include <NdbApi.hpp>
#include <NdbScanFilter.hpp>
// Used for cout
#include <iostream>
/**
* Helper sleep function
*/
int
milliSleep(int milliseconds){
int result = 0;
struct timespec sleeptime;
sleeptime.tv_sec = milliseconds / 1000;
sleeptime.tv_nsec = (milliseconds - (sleeptime.tv_sec * 1000)) * 1000000;
result = nanosleep(&sleeptime, NULL);
return result;
}
/**
* Helper sleep function
*/
#define APIERROR(error) \
{ std::cout << "Error in " << __FILE__ << ", line:" << __LINE__ << ", code:" \
<< error.code << ", msg: " << error.message << "." << std::endl; \
exit(-1); }
/*
* callback : This is called when the transaction is polled
*
* (This function must have three arguments:
* - The result of the transaction,
* - The NdbConnection object, and
* - A pointer to an arbitrary object.)
*/
static void
callback(int result, NdbConnection* myTrans, void* aObject)
{
if (result == -1) {
std::cout << "In callback: " << std::endl;
/**
* Put error checking code here (see ndb_async_example)
*/
APIERROR(myTrans->getNdbError());
} else {
/**
* Ok!
*/
return;
}
}
/**
* Function to create table
*/
int create_table(Ndb * myNdb)
{
NdbDictionary::Table myTable;
NdbDictionary::Column myColumn;
NdbDictionary::Dictionary* myDict = myNdb->getDictionary();
/*********************************************************
* Create a table named GARAGE if it does not exist *
*********************************************************/
if (myDict->getTable("GARAGE") != NULL) {
std::cout << "NDB already has example table: GARAGE. "
<< "Dropping it..." << std::endl;
if(myDict->dropTable("GARAGE") == -1)
{
std::cout << "Failed to drop: GARAGE." << std::endl;
exit(1);
}
}
myTable.setName("GARAGE");
myColumn.setName("REG_NO");
myColumn.setPrimaryKey(true);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
myColumn.setName("BRAND");
myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(20);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
myColumn.setName("COLOR");
myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(20);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
if (myDict->createTable(myTable) == -1) {
APIERROR(myDict->getNdbError());
return -1;
}
return 1;
}
int populate(Ndb * myNdb)
{
NdbConnection* myNdbConnection[15]; // For transactions
NdbOperation* myNdbOperation; // For operations
/******************************************************
* Insert (we do 15 insert transactions in parallel) *
******************************************************/
/**
* Five blue mercedes
*/
for (int i = 0; i < 5; i++)
{
myNdbConnection[i] = myNdb->startTransaction();
if (myNdbConnection[i] == NULL)
APIERROR(myNdb->getNdbError());
myNdbOperation = myNdbConnection[i]->getNdbOperation("GARAGE");
// Error check. If error, then maybe table GARAGE is not in database
if (myNdbOperation == NULL)
APIERROR(myNdbConnection[i]->getNdbError());
myNdbOperation->insertTuple();
myNdbOperation->equal("REG_NO", i);
myNdbOperation->setValue("BRAND", "Mercedes");
myNdbOperation->setValue("COLOR", "Blue");
// Prepare transaction (the transaction is NOT yet sent to NDB)
myNdbConnection[i]->executeAsynchPrepare(Commit, &callback, NULL);
}
/**
* Five black bmw
*/
for (int i = 5; i < 10; i++)
{
myNdbConnection[i] = myNdb->startTransaction();
if (myNdbConnection[i] == NULL)
APIERROR(myNdb->getNdbError());
myNdbOperation = myNdbConnection[i]->getNdbOperation("GARAGE");
// Error check. If error, then maybe table MYTABLENAME is not in database
if (myNdbOperation == NULL)
APIERROR(myNdbConnection[i]->getNdbError());
myNdbOperation->insertTuple();
myNdbOperation->equal("REG_NO", i);
myNdbOperation->setValue("BRAND", "BMW");
myNdbOperation->setValue("COLOR", "Black");
// Prepare transaction (the transaction is NOT yet sent to NDB)
myNdbConnection[i]->executeAsynchPrepare(Commit, &callback, NULL);
}
/**
* Five pink toyotas
*/
for (int i = 10; i < 15; i++) {
myNdbConnection[i] = myNdb->startTransaction();
if (myNdbConnection[i] == NULL) APIERROR(myNdb->getNdbError());
myNdbOperation = myNdbConnection[i]->getNdbOperation("GARAGE");
// Error check. If error, then maybe table MYTABLENAME is not in database
if (myNdbOperation == NULL) APIERROR(myNdbConnection[i]->getNdbError());
myNdbOperation->insertTuple();
myNdbOperation->equal("REG_NO", i);
myNdbOperation->setValue("BRAND", "Toyota");
myNdbOperation->setValue("COLOR", "Pink");
// Prepare transaction (the transaction is NOT yet sent to NDB)
myNdbConnection[i]->executeAsynchPrepare(Commit, &callback, NULL);
}
// Send all transactions to NDB
myNdb->sendPreparedTransactions(0);
// Poll all transactions
myNdb->pollNdb(3000, 0);
// it is also possible to use sendPollNdb instead of
// myNdb->sendPreparedTransactions(0); and myNdb->pollNdb(3000, 15); above.
// myNdb->sendPollNdb(3000,0);
// Note! Neither sendPollNdb or pollNdb returs until all 15 callbacks have
// executed.
// Close all transactions. It is also possible to close transactions
// in the callback.
for (int i = 0; i < 15; i++)
myNdb->closeTransaction(myNdbConnection[i]);
return 1;
}
int scan_delete(Ndb* myNdb,
int parallelism,
int column,
int column_len,
const char * color)
{
// Scan all records exclusive and delete
// them one by one
int retryAttempt = 0;
const int retryMax = 10;
int deletedRows = 0;
int check;
NdbError err;
NdbConnection *myTrans;
NdbScanOperation *myScanOp;
/**
* Loop as long as :
* retryMax not reached
* failed operations due to TEMPORARY erros
*
* Exit loop;
* retyrMax reached
* Permanent error (return -1)
*/
while (true)
{
if (retryAttempt >= retryMax)
{
std::cout << "ERROR: has retried this operation " << retryAttempt
<< " times, failing!" << std::endl;
return -1;
}
myTrans = myNdb->startTransaction();
if (myTrans == NULL)
{
const NdbError err = myNdb->getNdbError();
if (err.status == NdbError::TemporaryError)
{
milliSleep(50);
retryAttempt++;
continue;
}
std::cout << err.message << std::endl;
return -1;
}
/**
* Get a scan operation.
*/
myScanOp = myTrans->getNdbScanOperation("GARAGE");
if (myScanOp == NULL)
{
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* Define a result set for the scan.
*/
NdbResultSet * rs = myScanOp->readTuplesExclusive(parallelism);
if( rs == 0 ) {
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* Use NdbScanFilter to define a search critera
*/
NdbScanFilter filter(myScanOp) ;
if(filter.begin(NdbScanFilter::AND) < 0 ||
filter.eq(column, color, column_len, false) <0||
filter.end() <0)
{
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* Start scan (NoCommit since we are only reading at this stage);
*/
if(myTrans->execute(NoCommit) != 0){
err = myTrans->getNdbError();
if(err.status == NdbError::TemporaryError){
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
milliSleep(50);
continue;
}
std::cout << err.code << std::endl;
std::cout << myTrans->getNdbError().code << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* start of loop: nextResult(true) means that "parallelism" number of
* rows are fetched from NDB and cached in NDBAPI
*/
while((check = rs->nextResult(true)) == 0){
do {
if (rs->deleteTuple() != 0){
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
deletedRows++;
/**
* nextResult(false) means that the records
* cached in the NDBAPI are modified before
* fetching more rows from NDB.
*/
} while((check = rs->nextResult(false)) == 0);
/**
* Commit when all cached tuple have been marked for deletion
*/
if(check != -1){
check = myTrans->execute(Commit);
myTrans->releaseCompletedOperations();
}
/**
* Check for errors
*/
err = myTrans->getNdbError();
if(check == -1){
if(err.status == NdbError::TemporaryError){
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
milliSleep(50);
continue;
}
}
/**
* End of loop
*/
}
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return 0;
}
if(myTrans!=0) {
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
}
return -1;
}
int scan_update(Ndb* myNdb,
int parallelism,
int column_len,
int update_column,
const char * column_name,
const char * before_color,
const char * after_color)
{
// Scan all records exclusive and update
// them one by one
int retryAttempt = 0;
const int retryMax = 10;
int updatedRows = 0;
int check;
NdbError err;
NdbConnection *myTrans;
NdbScanOperation *myScanOp;
/**
* Loop as long as :
* retryMax not reached
* failed operations due to TEMPORARY erros
*
* Exit loop;
* retyrMax reached
* Permanent error (return -1)
*/
while (true)
{
if (retryAttempt >= retryMax)
{
std::cout << "ERROR: has retried this operation " << retryAttempt
<< " times, failing!" << std::endl;
return -1;
}
myTrans = myNdb->startTransaction();
if (myTrans == NULL)
{
const NdbError err = myNdb->getNdbError();
if (err.status == NdbError::TemporaryError)
{
milliSleep(50);
retryAttempt++;
continue;
}
std::cout << err.message << std::endl;
return -1;
}
/**
* Get a scan operation.
*/
myScanOp = myTrans->getNdbScanOperation("GARAGE");
if (myScanOp == NULL)
{
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* Define a result set for the scan.
*/
NdbResultSet * rs = myScanOp->readTuplesExclusive(parallelism);
if( rs == 0 ) {
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* Use NdbScanFilter to define a search critera
*/
NdbScanFilter filter(myScanOp) ;
if(filter.begin(NdbScanFilter::AND) < 0 ||
filter.eq(update_column, before_color, column_len, false) <0||
filter.end() <0)
{
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* Start scan (NoCommit since we are only reading at this stage);
*/
if(myTrans->execute(NoCommit) != 0){
err = myTrans->getNdbError();
if(err.status == NdbError::TemporaryError){
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
milliSleep(50);
continue;
}
std::cout << myTrans->getNdbError().code << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* Define an update operation
*/
NdbOperation * myUpdateOp;
/**
* start of loop: nextResult(true) means that "parallelism" number of
* rows are fetched from NDB and cached in NDBAPI
*/
while((check = rs->nextResult(true)) == 0){
do {
/**
* Get update operation
*/
myUpdateOp = rs->updateTuple();
if (myUpdateOp == 0){
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
updatedRows++;
/**
* do the update
*/
myUpdateOp->setValue(update_column,after_color);
/**
* nextResult(false) means that the records
* cached in the NDBAPI are modified before
* fetching more rows from NDB.
*/
} while((check = rs->nextResult(false)) == 0);
/**
* Commit when all cached tuple have been updated
*/
if(check != -1){
check = myTrans->execute(Commit);
myTrans->releaseCompletedOperations();
}
/**
* Check for errors
*/
err = myTrans->getNdbError();
if(check == -1){
if(err.status == NdbError::TemporaryError){
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
milliSleep(50);
continue;
}
}
/**
* End of loop
*/
}
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return 0;
}
if(myTrans!=0) {
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
}
return -1;
}
int scan_print(Ndb * myNdb, int parallelism,
int column_len_brand,
int column_len_color)
{
// Scan all records exclusive and update
// them one by one
int retryAttempt = 0;
const int retryMax = 10;
int fetchedRows = 0;
int check;
NdbError err;
NdbConnection *myTrans;
NdbScanOperation *myScanOp;
/* Result of reading attribute value, three columns:
REG_NO, BRAND, and COLOR
*/
NdbRecAttr * myRecAttr[3];
/**
* Loop as long as :
* retryMax not reached
* failed operations due to TEMPORARY erros
*
* Exit loop;
* retyrMax reached
* Permanent error (return -1)
*/
while (true)
{
if (retryAttempt >= retryMax)
{
std::cout << "ERROR: has retried this operation " << retryAttempt
<< " times, failing!" << std::endl;
return -1;
}
myTrans = myNdb->startTransaction();
if (myTrans == NULL)
{
const NdbError err = myNdb->getNdbError();
if (err.status == NdbError::TemporaryError)
{
milliSleep(50);
retryAttempt++;
continue;
}
std::cout << err.message << std::endl;
return -1;
}
/*
* Define a scan operation.
* NDBAPI.
*/
myScanOp = myTrans->getNdbScanOperation("GARAGE");
if (myScanOp == NULL)
{
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* Define a result set for the scan.
*/
NdbResultSet * rs = myScanOp->readTuplesExclusive(parallelism);
if( rs == 0 ) {
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* Define storage for fetched attributes.
* E.g., the resulting attributes of executing
* myOp->getValue("REG_NO") is placed in myRecAttr[0].
* No data exists in myRecAttr until transaction has commited!
*/
myRecAttr[0] = myScanOp->getValue("REG_NO");
myRecAttr[1] = myScanOp->getValue("BRAND");
myRecAttr[2] = myScanOp->getValue("COLOR");
if(myRecAttr[0] ==NULL || myRecAttr[1] == NULL || myRecAttr[2]==NULL)
{
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* Start scan (NoCommit since we are only reading at this stage);
*/
if(myTrans->execute(NoCommit) != 0){
err = myTrans->getNdbError();
if(err.status == NdbError::TemporaryError){
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
milliSleep(50);
continue;
}
std::cout << err.code << std::endl;
std::cout << myTrans->getNdbError().code << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* start of loop: nextResult(true) means that "parallelism" number of
* rows are fetched from NDB and cached in NDBAPI
*/
while((check = rs->nextResult(true)) == 0){
do {
fetchedRows++;
/**
* print REG_NO unsigned int
*/
std::cout << myRecAttr[0]->u_32_value() << "\t";
char * buf_brand = new char[column_len_brand+1];
char * buf_color = new char[column_len_color+1];
/**
* print BRAND character string
*/
memcpy(buf_brand, myRecAttr[1]->aRef(), column_len_brand);
buf_brand[column_len_brand] = 0;
std::cout << buf_brand << "\t";
delete [] buf_brand;
/**
* print COLOR character string
*/
memcpy(buf_color, myRecAttr[2]->aRef(), column_len_color);
buf_brand[column_len_color] = 0;
std::cout << buf_color << std::endl;
delete [] buf_color;
/**
* nextResult(false) means that the records
* cached in the NDBAPI are modified before
* fetching more rows from NDB.
*/
} while((check = rs->nextResult(false)) == 0);
}
myNdb->closeTransaction(myTrans);
return 1;
}
return -1;
}
int main()
{
ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB" ); // Object representing the database
/*******************************************
* Initialize NDB and wait until its ready *
*******************************************/
if (myNdb->init(1024) == -1) { // Set max 1024 parallel transactions
APIERROR(myNdb->getNdbError());
exit(-1);
}
if (myNdb->waitUntilReady(30) != 0) {
std::cout << "NDB was not ready within 30 secs." << std::endl;
exit(-1);
}
create_table(myNdb);
NdbDictionary::Dictionary* myDict = myNdb->getDictionary();
int column_color = myDict->getTable("GARAGE")->getColumn("COLOR")->getColumnNo();
int column_len_color =
myDict->getTable("GARAGE")->getColumn("COLOR")->getLength();
int column_len_brand =
myDict->getTable("GARAGE")->getColumn("BRAND")->getLength();
int parallelism = 16;
if(populate(myNdb) > 0)
std::cout << "populate: Success!" << std::endl;
if(scan_print(myNdb, parallelism, column_len_brand, column_len_color) > 0)
std::cout << "scan_print: Success!" << std::endl << std::endl;
std::cout << "Going to delete all pink cars!" << std::endl;
if(scan_delete(myNdb, parallelism, column_color,
column_len_color, "Pink") > 0)
std::cout << "scan_delete: Success!" << std::endl << std::endl;
if(scan_print(myNdb, parallelism, column_len_brand, column_len_color) > 0)
std::cout << "scan_print: Success!" << std::endl << std::endl;
std::cout << "Going to update all blue cars to black cars!" << std::endl;
if(scan_update(myNdb, parallelism, column_len_color, column_color,
"COLOR", "Blue", "Black") > 0)
{
std::cout << "scan_update: Success!" << std::endl << std::endl;
}
if(scan_print(myNdb, parallelism, column_len_brand, column_len_color) > 0)
std::cout << "scan_print: Success!" << std::endl << std::endl;
delete myNdb;
}