6 //Note: Set following parameters in csql.conf for this test
7 //MAX_SYS_DB_SIZE=10485760
8 //MAX_DB_SIZE=335544320
9 //you may have to set the kernel.shmmaxc kernel paremeter(login as root) using
10 //$sysctl -w kernel.shmmaxc=1000000000
16 DbRetVal rv
= conn
.open("root", "manager");
19 printf("Error during connection %d\n", rv
);
24 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
25 if (dbMgr
== NULL
) { printf("Auth failed\n"); return -1;}
27 tabDef
.addField("f1", typeInt
, 0, NULL
, true );
28 tabDef
.addField("f2", typeString
, 196);
29 rv
= dbMgr
->createTable("t1", tabDef
);
30 if (rv
!= OK
) { printf("Table creation failed\n"); return -1; }
31 printf("Table created\n");
32 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
33 strcpy(idxInfo
->tableName
, "t1");
34 idxInfo
->list
.append("f1");
35 idxInfo
->indType
= hashIndex
;
37 idxInfo
->bucketSize
= 100007;
39 idxInfo
->bucketSize
= 10007;
40 rv
= dbMgr
->createIndex("indx1", idxInfo
);
41 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
42 printf("Index created\n");
44 Table
*table
= dbMgr
->openTable("t1");
45 if (table
== NULL
) { printf("Unable to open table\n"); return -1; }
47 char name
[196] = "PRABAKARAN";
48 table
->bindFld("f1", &id
);
49 table
->bindFld("f2", name
);
55 TableImpl
*impl
= (TableImpl
*)table
;
56 impl
->setUndoLogging(false);
57 strcpy(name
, "PRABAKARAN0123456750590");
58 rv
= conn
.startTransaction();
59 if (rv
!= OK
) exit(1);
60 for(i
= 0; i
< LOAD
; i
++)
63 ret
= table
->insertTuple();
66 if (i
% 100 == 0 ) { rv
= conn
.commit();
67 if (rv
!= OK
) exit(1);
68 rv
= conn
.startTransaction();
69 if (rv
!= OK
) exit(1);
71 if (i
%50000 == 0) printf("%d rows inserted\n", i
);
74 impl
->setUndoLogging(true);
75 printf("Loaded %d records\n", icount
);
78 //TableImpl *impl = (TableImpl*)table;
79 //impl->setUndoLogging(false);
83 for(i
= LOAD
; i
< LOAD
+ITERATIONS
; i
++)
86 rv
= conn
.startTransaction();
87 if (rv
!= OK
) exit(1);
89 strcpy(name
, "PRABAKARAN0123456750590");
90 ret
= table
->insertTuple();
92 // printf("%d\n ", i);
97 printf("%d rows inserted %lld %lld %lld\n",icount
, timer
.minc(), timer
.maxc(), timer
.avg());
99 int offset1
= os::align(sizeof(int));
102 p1
.setTerm("f1", OpEquals
, &val1
);
103 table
->setCondition(&p1
);
108 for(i
= LOAD
; i
< LOAD
+ITERATIONS
; i
++)
111 rv
=conn
.startTransaction();
112 if (rv
!= OK
) exit(1);
115 tuple
= (char*)table
->fetch() ;
116 if (tuple
== NULL
) {printf("loop break in %d\n", i
);table
->closeScan();break;}
117 // printf(" %d tuple value is %d %s \n", i, *((int*)tuple), tuple+offset1);
123 printf("%d rows selected %lld %lld %lld\n", icount
, timer
.minc(), timer
.maxc(), timer
.avg());
126 for(i
= LOAD
; i
< LOAD
+ITERATIONS
; i
++)
129 rv
= conn
.startTransaction();
130 if (rv
!= OK
) exit (1);
133 tuple
= (char*)table
->fetch() ;
134 if (tuple
== NULL
) {printf("loop break in %d\n", i
);table
->closeScan();break;}
135 strcpy(name
, "PRABAKARAN0950576543210");
136 table
->updateTuple();
141 printf("%d rows updated %lld %lld %lld\n", i
- LOAD
, timer
.minc(), timer
.maxc(), timer
.avg());
145 for(i
= LOAD
; i
< LOAD
+ITERATIONS
; i
++)
148 rv
= conn
.startTransaction();
149 if (rv
!= OK
) exit (1);
152 tuple
= (char*)table
->fetch() ;
153 if (tuple
== NULL
) {printf("No record for %d\n", i
);table
->closeScan();break;}
154 table
->deleteTuple();
160 printf("%d rows deleted %lld %lld %lld\n", icount
, timer
.minc(), timer
.maxc(), timer
.avg());
163 dbMgr
->closeTable(table
);
164 dbMgr
->dropTable("t1");
165 printf("Table dropped\n");