slang-users mailing list

[2005 Date Index] [2005 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] Slang modules and threads?


Ok, Thanks very much to Paul for some answers.

To clarify some things he pointed out:


SLAG is designed to be database independent from the onset. It is simply
a lot of LOWER S-lang C Routines rolled up into a few simple functions.
And as John pointed about SLWDG, his library works just to damn well. ;->

However, the idea is that when (and if) I can ever get around to doing a
RAD/IDE they need some sort of file system and the "Application" side
needs some control files as well.

My thoughts was that whatever I used, could become a "basic" multiuser database
engine , without the developer having to bring an outside DBM, which
would speed adoption and usage of SLAG. I do NOT wish to tie SLAG to any
particular DBM, and as it sits right now, it is just PURE S-Lang and C
function calls to CSLANG stuff.

I Guess 14 years of working on Multi Value (PICK like) databases has spoiled me.
You do not worry about fixed field lengths, typing, or layouts since MV databases
treat all fields as strings. A data dictionary to the File told the DBM how
to return the field to the program (a PRAGMA as it were). The nice thing
was those Multi values, so in a something like an Order Entry File, you
could store the "detail" line items and all of their information in the
same record, but those where like an array. What you got was a ROW record
that could contain "COLUMNS" of fields (like looking at a spreadsheet).

I fact, Appgens database manager is nothing more than a Key/Data type DBM
that has had some stuff added to to it.

Paul, do you think this could be emulated using T/GDBM ?

/*      AppGen Database File system
 *	db_int.h : The internal structure of a database (DB) file.
 */



/*
 *	_db_fia maps the Fixed Information Area at the beginning of each DB.
 */
#define	DB_APPEND_ONLY	0x01
#define	DB_FREELISTS 10		/* Number of FREELISTS       */

typedef struct
{
	unsign short	_padword;	/* space no longer used	*/
	unsign short	_opens;		/* number of opens on this db */
	byte	_openlock;		/* file opens have been locked out */
	byte	_flags;			/* flag bits                 */
	byte	_fia_align[2];	/* 32-bit alignment		  	*/
	long	_reccount;		/* number of bytes in record */
	long	_hashsize;		/* current number of hash table slots */
				/* in low 3 bytes, high byte determines  */
				/* which of several functions to use 	 */
	DBOFF	_hashstart;		/* offset to the hash table	 */
	long	_minsize;		/* Minimum record size       */
	long	_overpct;		/* Minimum percentage overhead */
	struct {
		long	size;		/* Max size on this list     */
		DBOFF	offset;		/* Offset to the first block */
	}	_freestart[DB_FREELISTS];	/* An array of Freelists     */
}   _db_fia;


/* 	Define the structure that was used for 1.7 and previous
 *	releases.  Needed for dbar in conversion mode.
 */
typedef struct
{
	unsign short	_padword;	/* space no longer used	*/
	unsign short	_opens;		/* number of opens on this db */
	long	_hashsize;		/* current number of hash table slots */
				/* in low 3 bytes, high byte determines  */
				/* which of several functions to use 	 */
	DBOFF	_hashstart;		/* offset to the hash table	 */
	DBOFF	_freestart;		/* offset to the freelist table	 */
	byte	_openlock;		/* file opens have been locked out */
	byte	_fia_align[3];	/* 32-bit alignment		  	*/
}   _db_fia17;


/*
 *	_db_block maps a generalized block in a db
 */

typedef struct
{
	long	_blocklen;		/* current block length (bytes)	*/
	long	_bytesused;		/* number of bytes in use	*/
	DBOFF	_next;			/* -> to next block, or NULL	*/
	DBOFF	_prev;			/* -> to previous block, or NULL */
	byte	_type;			/* type of this block		*/
	byte	_reclock;		/* flag set if record is locked */
	unsign short	_rdcount;	/* number of non-lock reads	*/
	byte	_rec_align[4];		/* alignment for 64 bit system 	*/
}   _db_block;

/*
 *	_db_data maps a block header plus a portion of the data area
 */

typedef struct
{
	long	_blocklen;		/* current block length (bytes)	*/
	long	_bytesused;		/* number of bytes in use	*/
	DBOFF	_next;			/* -> next block, or NULL	*/
	DBOFF	_prev;			/* -> previous block, or NULL	*/
	byte	_type;			/* record type (locked or unlocked) */
	byte	_reclock;		/* flag set if record is locked */
	unsign short	_rdcount;	/* number of non-lock reads	*/
	byte	_rec_align[4];		/* alignment for 64 bit system 	*/
	char	_recdata[DB_MAXKEY];	/* a portion of the data	*/
}   _db_data;



/*
 *	Data Record and Freelist Entry types:
 */

# define	EMPTY		1	/* this entry is not in use	*/
					/* iff no one is reading it.	*/
# define	DATA		2	/* contains live data		*/
# define	HASHSTORE	5	/* this entry is a hash table	*/

/*
 *	poly-functional hashing stuff
 */

# define HASHAPART(n)	((int) ((n) >> 24) & 0x00ff)
# define HASHSPART(n)	((n) & 0x00ffffff)
# define HASHSIZE(f)	HASHSPART((f)->_hashsize)
# define HASHPARM(s,a)	(HASHSPART(s) | (((long)(a)) << 24))

# define OLDHASH	0
# define NEWHASH	1

/*
 *	attribute and value marks
 */

# define 	ATRIBMARK	0x0000   /* Row Delimeters */
# define	VALUEMARK	0x00ff   /* Field Delimeters */
					/* use MARKCMP when comparing against */
					/* a MARK to avoid sign extension     */
# define	MARKCMP(m)	( ((int) (m)) & 0x00ff )

/*
 *	other stuff
 */

# define DB_REP		1
# define DB_INS		2
# define DB_DEL		4

/* System Compile Time Defaults */
# define	DB_MINREC	128
# define	DB_OVERPCT	20
# define	DB_FLINCR	128

/*
 *	data
 */

extern	_db_fia		_fiabuf;
extern	_db_data	_datbuf;
extern	int		_db_ccnt, _db_acnt, _db_vcnt;



/*
 *	functions
 */

extern	long	_db_hash();	/* calculate the hash function		*/
extern	int	_db_bdump();	/* write the buffer chain to the file	*/
extern	int	_db_frel();	/* release the record in the file	*/
extern	int	_db_mrel();	/* release the record in memory		*/
extern	int	_db_seek();	/* locate a field in the memory record	*/
extern	int	_db_splice();	/* perform surgery on the memory record	*/
extern	void	_db_kread();	/* take the first buffer from _datbuf	*/
extern	void	_db_sread();	/* for readnext, copy from seq buffer */
#ifdef CPLUSPLUS
extern	long	_db_get(CHANNEL ch, char buf[], CHOFF loc, long len);
#else
extern	long	_db_get();	/* vm_get() with error checking		*/
#endif
extern	long	_db_put();	/* vm_put() with error checking		*/

# define GETFIA(db)	_db_get(db->db_fd,(char*)&_fiabuf,(long) sizeof(_db_fia),0L)
# define PUTFIA(db)	_db_put(db->db_fd,(char*)&_fiabuf,(long) sizeof(_db_fia),0L)
# define GETBLK(db,loc)	_db_get(db->db_fd,(char*)&_datbuf, \
					(long) sizeof(_db_block),loc)
# define PUTBLK(db,loc)	_db_put(db->db_fd,(char*)&_datbuf, \
					(long) sizeof(_db_block),loc)


Paul Boekholt wrote:
On Wed, 13 Jul 2005 13:32:33 -0500, Ben Duncan <ben@xxxxxxxxxxxxxxxxxx> said:


Ok, am taking a VERY serious LOOK at Sleepy Cat DBM as my SLAG database engine.

If you use Sleepy Cat as your database engine and I need to write an
application that uses a MySQL database, can I still use SLAG?  I think there
are three possible answers:
-No.  Then SLAG will not be very useful.  FWIW I'm currently working on an
almost trivial database (in PHP) but a key/value pairs DBM would not do.
-Yes.  Then you can just finish SLAG and worry about databases later.
-Yes, but you still need the DBM as well because SLAG needs to store some
configuration variables there.  GDBM should be able to do that just as well.




--
Ben Duncan   - VersAccounting Software LLC 336 Elton Road  Jackson MS, 39212
"Never attribute to malice, that which can be adequately explained by stupidity"
       - Hanlon's Razor


_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


[2005 date index] [2005 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]