7 DbRetVal rv
= conn
.open("root", "manager");
10 printf("Error during connection %d\n", rv
);
13 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
14 if (dbMgr
== NULL
) { printf("Auth failed\n"); return -1;}
16 tabDef
.addField("f1", typeInt
, 0, NULL
, true);
17 tabDef
.addField("f2", typeString
, 196);
18 rv
= dbMgr
->createTable("t1", tabDef
);
19 if (rv
!= OK
) { printf("Table creation failed\n"); return -1; }
20 printf("Table created\n");
21 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
22 strcpy(idxInfo
->tableName
, "t1");
23 idxInfo
->list
.append("f1");
24 idxInfo
->indType
= treeIndex
;
25 rv
= dbMgr
->createIndex("indx1", idxInfo
);
26 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
27 printf("Index created\n");
28 Table
*table
= dbMgr
->openTable("t1");
29 if (table
== NULL
) { printf("Unable to open table\n"); return -1; }
31 char name
[196] = "PRABAKARAN";
32 table
->bindFld("f1", &id
);
33 table
->bindFld("f2", name
);
39 for(i
= 0; i
< 1000; i
++)
42 rv
= conn
.startTransaction();
43 if (rv
!= OK
) exit(1);
45 strcpy(name
, "PRABAKARAN0123456750590");
47 ret
= table
->insertTuple();
54 sprintf(msgBuf
,"Total rows inserted %d %lld %lld %lld\n",icount
, timer
.min(), timer
.max(), timer
.avg());
55 os::write(1,msgBuf
,strlen(msgBuf
));
57 int offset1
= os::align(sizeof(int));
60 p1
.setTerm("f1", OpGreaterThan
, &val1
);
61 table
->setCondition(&p1
);
65 for(i
= 0; i
< 100; i
++)
69 rv
=conn
.startTransaction();
70 if (rv
!= OK
) exit(1);
72 while ((tuple
= (char*)table
->fetch()) != NULL
) {
73 //printf("tuple value is %d %s \n", *((int*)tuple), tuple+offset1);
76 if (cnt
!= 100) printf("Error in fetching %d\n", cnt
);
82 sprintf(msgBuf
,"%d rows selected %lld %lld %lld\n", icount
, timer
.min(), timer
.max(), timer
.avg());
83 os::write(1,msgBuf
,strlen(msgBuf
));
85 dbMgr
->closeTable(table
);
86 dbMgr
->dropTable("t1");