|
|
|
|
|
|
| Author |
Message |
Naveen *nix forums beginner
Joined: 16 May 2005
Posts: 12
|
Posted: Sun Jun 04, 2006 7:13 am Post subject:
Re: Compacting a database
|
|
|
Florian Weimer wrote:
| Quote: | * Naveen:
Yes, thats working .... But now I have found two files of db.h...One is
the older version and other is the new one.
You also need the correct copy of libdb.a. Usually, this means that
you need to change the linker search path with "-L".
|
Thanks Florian, its all working...........thanks a lot |
|
| Back to top |
|
 |
Florian Weimer *nix forums Guru
Joined: 19 Feb 2005
Posts: 418
|
Posted: Sat Jun 03, 2006 1:30 pm Post subject:
Re: Compacting a database
|
|
|
* Naveen:
| Quote: | Yes, thats working .... But now I have found two files of db.h...One is
the older version and other is the new one.
|
You also need the correct copy of libdb.a. Usually, this means that
you need to change the linker search path with "-L". |
|
| Back to top |
|
 |
Naveen *nix forums beginner
Joined: 16 May 2005
Posts: 12
|
Posted: Sat Jun 03, 2006 9:02 am Post subject:
Re: Compacting a database
|
|
|
Florian Weimer wrote:
| Quote: | * Naveen:
Florian Weimer wrote:
* Naveen:
Am using the latest version of Berkeley DB 4.4.20 and
I found the compact member in the db.h header file.
It's likely that your compiler picks up the wrong version of the file.
Try to specify "-I/opt/BerkeleyDB4.2/include" (or whatever path you
use) on the compiler command line.
Thanks Florian. It worked !!!!!!!!!! But I found another problem, when
i execute the program the open database fails and shows unknown error
!!!!! But when I remove compact() function and then compile as usual(
gcc -ldb pgmname) it works. !!! Why is it like that ??
You probably need to specify the correct path to the Berkeley DB
library, using "-L/opt/BerkeleyDB4.2/lib".
|
Yes, thats working .... But now I have found two files of db.h...One is
the older version and other is the new one.
If i compile with the latest version( compact() included in file ) its
success, but when I execute db_open() fails showing UNKNOWN ERROR.
Why is this so?? i have put the source code in earlier post.....
Please help me to find a solution |
|
| Back to top |
|
 |
Florian Weimer *nix forums Guru
Joined: 19 Feb 2005
Posts: 418
|
Posted: Fri Jun 02, 2006 1:22 pm Post subject:
Re: Compacting a database
|
|
|
* Naveen:
| Quote: | Florian Weimer wrote:
* Naveen:
Am using the latest version of Berkeley DB 4.4.20 and
I found the compact member in the db.h header file.
It's likely that your compiler picks up the wrong version of the file.
Try to specify "-I/opt/BerkeleyDB4.2/include" (or whatever path you
use) on the compiler command line.
Thanks Florian. It worked !!!!!!!!!! But I found another problem, when
i execute the program the open database fails and shows unknown error
!!!!! But when I remove compact() function and then compile as usual(
gcc -ldb pgmname) it works. !!! Why is it like that ??
|
You probably need to specify the correct path to the Berkeley DB
library, using "-L/opt/BerkeleyDB4.2/lib". |
|
| Back to top |
|
 |
Naveen *nix forums beginner
Joined: 16 May 2005
Posts: 12
|
Posted: Fri Jun 02, 2006 10:22 am Post subject:
Re: Compacting a database
|
|
|
Florian Weimer wrote:
| Quote: | * Naveen:
Am using the latest version of Berkeley DB 4.4.20 and
I found the compact member in the db.h header file.
It's likely that your compiler picks up the wrong version of the file.
Try to specify "-I/opt/BerkeleyDB4.2/include" (or whatever path you
use) on the compiler command line.
|
Thanks Florian. It worked !!!!!!!!!! But I found another problem, when
i execute the program the open database fails and shows unknown error
!!!!! But when I remove compact() function and then compile as usual(
gcc -ldb pgmname) it works. !!! Why is it like that ??
#include<assert.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<gendata.h>
#include<Tdate.h>
#include<gettime.h>
#define SIZE 15
#include "db.h"
typedef struct my_struct
{
char stored[SIZE];
char dateTime[30];
}MY_STRUCT;
int main()
{
DBT key,data;
DB *dbp;
int ret;
MY_STRUCT user;
int i=1,j,pmkey=0;
double first=0,second=0,third=0;
char **str;char *date;
str=getString(str,SIZE-1,9);
assert(db_create(&dbp,NULL,0)==0);
ret=dbp->open(dbp,NULL,"mydb.db",NULL,DB_BTREE,DB_CREATE,0);
if(ret!=0)
{
fprintf(stderr,"Error opening database :%s\n",db_strerror(ret));
exit(-1);
}
for(i=1;i<=1000000;i++)
{
printf("i : %d\n", i);
pmkey=getNumber(1000000);
// printf("\nRandom number is :%d",pmkey);
if(pmkey !=0)
{
first=getTime();
memset(&key,0,sizeof(DBT));
memset(&data,0,sizeof(DBT));
key.data=&i;
key.size=sizeof(int);
ret=dbp->del(dbp,NULL,&key,0);
second=getTime();
if(ret!=0)
{
dbp->err(dbp,ret,"\n data already exist");
}
else
{
third+=(second-first);
// printf("\nRecord Number :%d inserted",i);
}
}
else
i--;
}
dbp->compact(dbp,NULL,NULL,NULL,NULL,0,NULL);
printf("\nTotal time elapsed for putting the record is :%lf",third);
if(dbp!=NULL)
{
dbp->close(dbp,0);
}
return 0;
} |
|
| Back to top |
|
 |
Florian Weimer *nix forums Guru
Joined: 19 Feb 2005
Posts: 418
|
Posted: Thu Jun 01, 2006 12:01 pm Post subject:
Re: Compacting a database
|
|
|
* Naveen:
| Quote: | Am using the latest version of Berkeley DB 4.4.20 and
I found the compact member in the db.h header file.
|
It's likely that your compiler picks up the wrong version of the file.
Try to specify "-I/opt/BerkeleyDB4.2/include" (or whatever path you
use) on the compiler command line. |
|
| Back to top |
|
 |
Naveen *nix forums beginner
Joined: 16 May 2005
Posts: 12
|
Posted: Thu Jun 01, 2006 9:18 am Post subject:
Re: Compacting a database
|
|
|
Mike wrote:
| Quote: | Naveen,
When a record is deleted from a database the space from that record is
generally available for use by records that would fall on the same page
as the deleted record. If all records on a page are deleted that page
is put on a free list in the file (unless it happens to be the last
page of the file, in which case it is returned to the file system).
Pages on the free list are availble to be used by any database in the
file. The DB->compact method is available in release 4.4. I suspect
you are using an eariler release.
Michael Ubell
Sleepycat Software.
|
Hi Michael,
Am using the latest version of Berkeley DB 4.4.20 and
I found the compact member in the db.h header file.
I am still getting the error everytime. Why is it so?? |
|
| Back to top |
|
 |
ubell@sleepycat.com *nix forums beginner
Joined: 06 Jun 2005
Posts: 49
|
Posted: Wed May 31, 2006 3:48 pm Post subject:
Re: Compacting a database
|
|
|
Naveen,
When a record is deleted from a database the space from that record is
generally available for use by records that would fall on the same page
as the deleted record. If all records on a page are deleted that page
is put on a free list in the file (unless it happens to be the last
page of the file, in which case it is returned to the file system).
Pages on the free list are availble to be used by any database in the
file. The DB->compact method is available in release 4.4. I suspect
you are using an eariler release.
Michael Ubell
Sleepycat Software. |
|
| Back to top |
|
 |
Naveen *nix forums beginner
Joined: 16 May 2005
Posts: 12
|
Posted: Tue May 30, 2006 6:35 am Post subject:
Compacting a database
|
|
|
hi,
I am using a DB_RECNO method for storing 1 million of data. So the
database size is 45Mb. After when I delete 2 Lakh record the database
size remains the same. Why is this so??
Is there any method by which I can compact this database. Please
suggest me a way with an example if possible.
I came to know about db->compact(). But when I used it I get an
error." error: 'struct __db' has no member named 'compact' ".
With Regards
Naveen Gopi |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Fri Jan 09, 2009 5:02 am | All times are GMT
|
|
Internet Advertising | Debt Consolidation | Advance Auto Parts | Loans | Bankruptcy
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|