dbTalk Databases Forums  

Dbt not large enough for available data

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss Dbt not large enough for available data in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dane Foster
 
Posts: n/a

Default Dbt not large enough for available data - 09-15-2004 , 11:55 PM






THE SCENARIO:
I've got a database that uses fixed size keys (16 bytes) and variable
size values. The database is configured for BTREE and duplicates. To
extract the duplicates for a given key I use a Dbc and loop until I've
grabbed all the duplicates.

THE PROBLEM:
Whenever I create a Dbt object (as the key) and set the DB_DBT_USERMEM
flag, after the initial Dbc.get, subsequent gets throws a DbException
saying:
<quote-snippet>
Dbt not large enough for available data
at com.sleepycat.db.db_javaJNI.Dbc_get__SWIG_0(Native Method)
at com.sleepycat.db.Dbc.get(Dbc.java:791)
....
</quote-snippet>

I'm including the code of the method that causes the problem

<code>
public Collection<String> get( long k ) throws IOException
{
Collection<String> c = null;
Utf8StringDbt data = new Utf8StringDbt();
// Converts k to a Dbt by prefixing it w/ its parent key
Dbt key = convert( k );
key.setFlags( Db.DB_DBT_USERMEM );
try
{
Dbc cursor = bdDb.getBerkleyDb( dbName ).cursor( null, 0 );
try
{
if( 0 == cursor.get( key, data, Db.DB_SET ) )
{
c = new LinkedList<String>();
do
c.add( data.toString() );
while( 0 == cursor.get( key, data, Db.DB_NEXT_DUP ) );
}
}
finally
{
cursor.close();
}
}
catch( DbException e )
{
throw new RuntimeException( e );
}
return c;
}
</code>

If I remove the call to setFlag the error goes away. I know the keys
are only 16 bytes wide. I've even written debugging code where the key
used in the [while] loop is a freshly created Dbt. After each
iteration of the loop I print [to stderr] the offset and size of the
Dbt. It's always 0 and 16 respectively. In a moment of utter
frustration I modified the convert method to create a Dbt w/ a size of
1024 bytes, more than enough for even the data, but I still get the
Exception complaining about not big enough. Why won't Berkeley DB
accept my 'static' key?

--Sysconfig--
Hardware: Dell Inspiron 8500
Arch: Intel Pentium 4M 2.2GHz
Mem: 1.5GB
Disk: 80GB
O.S: Gentoo Linux
Kernel: 2.6.8.1
GLIBC:
GNU C Library stable release version 2.3.3, by Roland McGrath et al.
Compiled by GNU CC version 3.3.3 20040412 (Gentoo Linux 3.3.3-r6,
ssp-3.3.2-2, pie-8.7.6).
Compiled on a Linux 2.6.7 system on 2004-08-09.
Available extensions:
GNU libio by Per Bothner
crypt add-on version 2.1 by Michael Glad and others
NPTL 0.61 by Ulrich Drepper
BIND-8.2.3-T5B
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
Thread-local storage support included.
Report bugs using the `glibcbug' script to <bugs (AT) gnu (DOT) org>.
GCC: gcc (GCC) 3.3.3 20040412 (Gentoo Linux 3.3.3-r6, ssp-3.3.2-2,
pie-8.7.6)
FS: ReiserFS 3.6
BerkDb: 4.2.52.NC (w/ patches [built against preceeding JDK])
JDK: 1.5.0-rc-b63

Reply With Quote
  #2  
Old   
Ron Cohen
 
Posts: n/a

Default Re: Dbt not large enough for available data - 09-16-2004 , 11:27 AM






mrpoof (AT) hotmail (DOT) com (Dane Foster) wrote in message news:<be935692.0409152055.54b5358b (AT) posting (DOT) google.com>...
Quote:
THE SCENARIO:
I've got a database that uses fixed size keys (16 bytes) and variable
size values. The database is configured for BTREE and duplicates. To
extract the duplicates for a given key I use a Dbc and loop until I've
grabbed all the duplicates.

THE PROBLEM:
Whenever I create a Dbt object (as the key) and set the DB_DBT_USERMEM
flag, after the initial Dbc.get, subsequent gets throws a DbException
saying:
quote-snippet
Dbt not large enough for available data
at com.sleepycat.db.db_javaJNI.Dbc_get__SWIG_0(Native Method)
at com.sleepycat.db.Dbc.get(Dbc.java:791)
....
/quote-snippet

I'm including the code of the method that causes the problem

code
public Collection<String> get( long k ) throws IOException
{
Collection<String> c = null;
Utf8StringDbt data = new Utf8StringDbt();
// Converts k to a Dbt by prefixing it w/ its parent key
Dbt key = convert( k );
key.setFlags( Db.DB_DBT_USERMEM );
try
{
Dbc cursor = bdDb.getBerkleyDb( dbName ).cursor( null, 0 );
try
{
if( 0 == cursor.get( key, data, Db.DB_SET ) )
{
c = new LinkedList<String>();
do
c.add( data.toString() );
while( 0 == cursor.get( key, data, Db.DB_NEXT_DUP ) );
}
}
finally
{
cursor.close();
}
}
catch( DbException e )
{
throw new RuntimeException( e );
}
return c;
}
/code

If I remove the call to setFlag the error goes away. I know the keys
are only 16 bytes wide. I've even written debugging code where the key
used in the [while] loop is a freshly created Dbt. After each
iteration of the loop I print [to stderr] the offset and size of the
Dbt. It's always 0 and 16 respectively. In a moment of utter
frustration I modified the convert method to create a Dbt w/ a size of
1024 bytes, more than enough for even the data, but I still get the
Exception complaining about not big enough. Why won't Berkeley DB
accept my 'static' key?


If DB_DBT_USERMEM is specified, you need to specify the byte size of
the user-specified buffer .

key.setUserBufferLength(16);

For more information:

http://www.sleepycat.com/docs/java/index.html



Regards,

Ron
Sleepycat Software


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.