7 DbRetVal rv
= conn
.open("praba", "manager");
10 printf("Error during connection %d\n", rv
);
15 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
16 if (dbMgr
== NULL
) { printf("Auth failed\n"); return -1;}
18 tabDef
.addField("f1", typeInt
, 0, NULL
, true, true );
19 tabDef
.addField("f2", typeString
, 196);
20 rv
= dbMgr
->createTable("t1", tabDef
);
21 if (rv
!= OK
) { printf("Table creation failed\n"); return -1; }
22 printf("Table created\n");
23 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
24 strcpy(idxInfo
->tableName
, "t1");
25 idxInfo
->list
.append("f1");
26 idxInfo
->indType
= hashIndex
;
27 rv
= dbMgr
->createIndex("indx1", idxInfo
);
28 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
29 printf("Index created\n");
30 Table
*table
= dbMgr
->openTable("t1");
31 if (table
== NULL
) { printf("Unable to open table\n"); return -1; }
33 char name
[196] = "PRABAKARAN";
34 table
->bindFld("f1", &id
);
35 table
->bindFld("f2", name
);
41 for(i
= 0; i
< 100; i
++)
44 rv
= conn
.startTransaction();
45 if (rv
!= OK
) exit(1);
47 strcpy(name
, "PRABAKARAN0123456750590");
49 ret
= table
->insertTuple();
56 sprintf(msgBuf
,"Total rows inserted %d %lld %lld %lld\n",icount
, timer
.min(), timer
.max(), timer
.avg());
57 os::write(1,msgBuf
,strlen(msgBuf
));
59 int offset1
= os::align(sizeof(int));
62 p1
.setTerm("f1", OpEquals
, &val1
);
63 table
->setCondition(&p1
);
66 for(i
= 0; i
< 100; i
++)
69 rv
=conn
.startTransaction();
70 if (rv
!= OK
) exit(1);
73 tuple
= (char*)table
->fetch() ;
74 if (tuple
== NULL
) {printf("loop break in %d\n", i
);table
->close();break;}
75 //printf("tuple value is %d %s \n", *((int*)tuple), tuple+offset1);
81 sprintf(msgBuf
,"%d rows selected %lld %lld %lld\n", icount
, timer
.min(), timer
.max(), timer
.avg());
82 os::write(1,msgBuf
,strlen(msgBuf
));
84 for(i
= 0; i
< 100; i
++)
87 rv
= conn
.startTransaction();
88 if (rv
!= OK
) exit (1);
91 tuple
= (char*)table
->fetch() ;
92 if (tuple
== NULL
) {printf("loop break in %d\n", i
);table
->close();break;}
93 strcpy(name
, "PRABAKARAN0950576543210");
99 sprintf(msgBuf
,"%d rows updated %lld %lld %lld\n", i
, timer
.min(), timer
.max(), timer
.avg());
100 os::write(1,msgBuf
,strlen(msgBuf
));
102 for(i
= 0; i
< 100; i
++)
105 rv
= conn
.startTransaction();
106 if (rv
!= OK
) exit (1);
109 tuple
= (char*)table
->fetch() ;
110 if (tuple
== NULL
) {printf("loop break in %d\n", i
);table
->close();break;}
111 table
->deleteTuple();
117 printf("%d rows deleted %lld %lld %lld\n", icount
, timer
.min(), timer
.max(), timer
.avg());
121 for(i
= 0; i
< 100; i
++)
123 rv
= conn
.startTransaction();
124 if (rv
!= OK
) exit (1);
127 tuple
= (char*)table
->fetch() ;
128 if (tuple
== NULL
) {printf("loop break in %d\n", i
);table
->close();break;}
129 //printf("tuple value is %d %s \n", *((int*)tuple), tuple+offset1);
134 printf("Total rows selected %d\n", count
);
135 dbMgr
->closeTable(table
);
136 dbMgr
->dropTable("t1");