SQLExpress - Xb2.NET     ot4xb  
ot4xb.public
Re: Berkely DB
Thread Starter: Sander Elias Started: 9/10/2005 10:07 AM UTC
Replies: 5
Re: Berkely DB
Pablo,
Seems so interesting and powerfull, specially becacuse you can use it to index any kind of data.
It is also interesting because it is fairly simple to create
everything DBF/CDX had, but without the drawbacks! database size off
256TB for example, and fields up to 4GB!
also there is no conversion in it, so no nasty ASCII,->ANSI wrapping!
and there are more benefits to it.



Well, the main purpose of ot4xb at PRG level is handle memory structures
so you only need to create your structure class with the ot4xb commands
and just access members just as regular instance members of your object.
Good, so this open up an window for me. one problem tough, there is a vast amount off structures. It looks
like quite some work converting them this way.  It would be nice if
there was a way to automatically convert the .H file to a PRG holding
the structures! (how's that for wishful thinking!;) )

This will provide to MyDb() class  the functionality to handle your
Db methods and also access to the fields.
This is a good idea!


> It seems that I need  wrapping layer in C to make use off it.

There is not C++ name mangling in the exported functions so you can access easily
with DllCall() and some gwst classes to handle the structures 100% with Xbase++ code.
Good! this is nice to hear, I'm not up against a wall!


The other option can be use the C++ TXbClass to build the Xbase++ classes at C/C++ level, the advantadge is that
you can you can build a Xbase++ DLL using the Berkeley DB static lib and just use it in your apps.
This sounds very nice! I would prefer it this way. There is also an
C++ API wrapper, that consist out off objects, and almost no
structures. Maybe this is a starting point into this, but I have no
idea how to connect C++ objects to xbase!


The only thing that will be result into a great speed diference is if you need a custom compare function, the extra
overhead required to call your Xbase function can slow down your database operations.
I see no way around this! That is, beside witting the custom function
in C. (which is not (yet) for me)


I'm currently a bit workload to handle more projects at the same time, but if you want to start and work in the project I will happy to help you and contribute with some source. Maybe can be a new xodc project.
I would love to make this a open project, I'm working on some other
things also. But there is no rush in this project. Howver it would be nice if we can add support for this in DBF-server!
Regards
Sander Elias
Re: Berkely DB
> I have been looking trough the API's and the interface. it look's
> fairly structured to me, and no fancy(read difficult to follow) stuff
> around there.

Yes the API docs seems to be clear, the only trouble is that I still have a dbfcdx  head but I hope playing a bit with the provided samples can help me to familiarize with the DB.
My idea was/is to recreate the dbfcdx structure in the DB. this way,
we will have all the profits from the DBFCDX structure, without the
down-sides. No 2GB boundary, no problems with "memo-fields", no
problems with field-sizes! no problems with record sizes. Ah, way to
much pro's to sum up here!

My idea was to translate the dbfcdx structure to Berkeley DB as
follows
use a que to store a basic "record" (witch enables record locking and
stuff!)
create a seconds table as a record one for unlimited text-field/memo
usage
add as many binary trees as nesacery for index purposes, using
"secondary" tables!

regards
Sander Elias
Regards
Sander Elias
Re: Berkely DB
Sander


one problem tough, there is a vast amount off structures.
The most of this structures are just used internally so you only need to consider
the pointers to this structures just like a handle, but no need to worry about the content

This sounds very nice! I would prefer it this way. There is also an
C++ API wrapper, that consist out off objects, and almost no
structures. Maybe this is a starting point into this, but I have no
idea how to connect C++ objects to xbase!
TXbClass allow this

// at the class declaration
     pc->Method("XbMethodName", MyCFunction ,1 /* nParams*/ );

// method implementation
static void MyCFunction( TXbClsParams * px)
{
   MyCppClass * pc     = ( MyCppClass * ) px->GetSelfC();
 px->PutReturnDWord(  pc->MyCppMethod( px->ParamLockStr( 1 ) );
}

As you can see no need to worry about release containers or unlock
memory pointers, this is performed automatically. And you can also
add some methods like this:

pc->MethodCB("SayHello",{|Self|   QOut( \"Hello\") }" );

But there is no rush in this project.

Well , I think the hard work here ( at least for me)  will be
familiarize with the Berkeley DB and play a bit with some C/C++ samples
before start with the Xbase++ implementation.

Regards,
Pablo
Re: Berkely DB
you lost me here, my C isn't well ehhh....
See the same step by step

static void MyCFunction( TXbClsParams * px)
{

   // Get the C++ pointer stored in the Xbase++ object as (void *)
   // and cast to the C++ class type ( MyCppClass * )
   MyCppClass * pc     = ( MyCppClass * ) px->GetSelfC();
   // Get a String pointer from the 1st param of the Xbase++ method call
   LPSTR  pStr    = px->ParamLockStr( 1 ) ;
   DWORD  dwResult;
   // Call to the C++ method
   dwResult = pc->MyCppMethod( pStr);
   //    Return the result to Xbase++
   px->PutReturnDWord(  dwResult) ;
}

The procedure will be always the same
1) Get the C++ pointer
2) Get the Xbase++ params
3) call to the C++ method
4) return the result back to Xbase++

The MyCFunction( TXbClsParams * px) will be called inside a frame that will
provide and destroy the TXbClsParams object and will release automatically
handles and pointers obtained directly from TXbClsParams.

TXbClsParams have also methods to generate a Xbase++ error object and launch
the errorsys if a C/C++ exception inside MyCFunction( TXbClsParams * px) the external
frame will catch it and generate a standard Xbase++ error that you can handle in your PRG.

I have been looking trough the API's and the interface. it look's
fairly structured to me, and no fancy(read difficult to follow) stuff
around there.

Yes the API docs seems to be clear, the only trouble is that I still have a dbfcdx  head but I hope playing a bit with the provided samples can help me to familiarize with the DB.

Regards,
Pablo
Re: Berkely DB
Sander,

one problem tough, there is a vast amount off structures. It looks
like quite some work converting them this way.  It would be nice if
there was a way to automatically convert the .H file to a PRG holding
the structures! (how's that for wishful thinking!;) )

A perl script should be able to do this for you, it is pretty good at this
sort of things.

Regards,
-- Phil Ide

*******************************************
*   Xbase++ FAQ, Libraries and Sources:   *
*   goto: http://www.idep.org.uk/xbase    *
* --------------------------------------- *
* www.xodc.org.uk - openSource Dev-Center *
*******************************************

Paranoids are never alone.
Re: Berkely DB
Pablo,

> This sounds very nice! I would prefer it this way. There is also an
> C++ API wrapper, that consist out off objects, and almost no
> structures. Maybe this is a starting point into this, but I have no
> idea how to connect C++ objects to xbase!
TXbClass allow this
Good,


// at the class declaration
    pc->Method("XbMethodName", MyCFunction ,1 /* nParams*/ );

I can follow this!

// method implementation
static void MyCFunction( TXbClsParams * px)
{
  MyCppClass * pc     = ( MyCppClass * ) px->GetSelfC();
px->PutReturnDWord(  pc->MyCppMethod( px->ParamLockStr( 1 ) );
}
you lost me here, my C isn't well ehhh....

As you can see no need to worry about release containers or unlock
memory pointers, this is performed automatically. And you can also
add some methods like this:
This I can follow, and it is really nice to know this!


Well , I think the hard work here ( at least for me)  will be
familiarize with the Berkeley DB and play a bit with some C/C++ samples
before start with the Xbase++ implementation.
I have been looking trough the API's and the interface. it look's
fairly structured to me, and no fancy(read difficult to follow) stuff
around there. Howver I can be wrong, it is possible that I
oversimplified the C samples. but I looked like something I could
follow. given my C knowledge that's a good thing!

Regards
Sander Elias
Regards
Sander Elias