|
By Jesus Monroy, Jr. (jessemonroy@email.com
)
Berkeley DB (Data Base) is currently v2.x.x. There is a
perception that it can only has limited use. It's best use is as
persistent storage. And because it is a test library one can be
reasonably assured of a quality. In short, if you'd like to
"roll your own", Berkeley DB is excellent choice.
In this article, we will explore the advantages and
disadvantages, the services available, possible uses and some real
applications.
Advantages
- Library/Not a language
- Architecture-independent database
- Persistent and Volatile storage
- Native OS file storage
- Not a daemon/server
- A systems admin not required
- Learning curve is minimal
- Programming Interface is generic and easy
- Multiple APIs (C, C++, Perl, Tcl, Java)
- Thread-safe Library
- Large Key/Values pairs (up to 2^32 bytes)
- It's Open Source
Disadvantages
- Does not deal with relational databases easily
- Complex data means complex program and storage issues
- Not network aware
- No network access
- No SQL interface
It's More Than Just a Hash Table.
From it's historic past DB, formerly DBM (and NDBM), was based on
a key/data pair concept. The early releases also included the B+tree
access method. Along with this, Fixed- and Variable-length Records
were supported.
Today, in addition to the aforementioned access methods, Berkeley
DB supports a number of commercial improvements. Among them is
shared memory-mapped caching and files. Transactions that use
ACIDity (Atomic, Consistent, Isolatable, Durable) properties. Other
features include:
- Write-ahead logging
- Crash Recovery
- Check pointing service (synchronization of logs against
disk-writes)
- Two-phase locking (reduces deadlocks)
In short, Sleepy Cat has added quit a few features that take
Berkeley DB beyond the realm of “student work’.
Generic Interfaces
Like many traditional programming interfaces Berkeley DB provides
the minimal, which include:
- open() open the database in a prescribed fashion
- close() closes the database
- put() puts a record in database
- get() gets record from database
- del() deletes a record from the database
In addition, there is:
- fd() returns a file handle for use with fcntl(2) and flock(2)
- sync() flushes any pending data to persistent storage
- seq() returns the database in a sequential manner, usually
sorted
Extendable Functions
Except for open(), all the aforementioned routines are accessible
via pointers in a structure returned by open(). In addition, since
certain functions will never be "correct" for every
situation, Berkeley DB has hooks for certain key routines. The
include:
- hash() in hash, places the data in a hash of your creation
- compare() in btree, compares two (2) data items
- prefix() in btree, prefixes based on two (2) data items
Granular Storage Control
When using at open(), one can define the functional properties of
put() based on "cursor" locations. One can:
- Replace the key/data pair referenced
- Append to the data immediately after the cursor
- Insert to the data immediately before the cursor
- Enter only if the key does not previously exist
- Store at the key/data pair, setting or initialize it
Fast Access
Berkeley DB obtains fast access by doing "block" reads
and writes. As the term infers, DB reads and writes to the file
system in blocks; handling all the parsing in memory. This includes
records written with new lines ('\n') as record delimiters.
You may set the parameters manually for run-time optimization by
changing the following parameters:
btree -> psize // pagesize
hash -> bsize // blocksize
recno -> psize // pagesize
Possible Uses
In the Berkeley DB man pages the term “store back” is used.
In DB parlance this can be any storage device. In BSD UNIX systems
we use the hard disk as a “store back”. Most other OSes do also.
Some of the possible uses for Berkeley BD are:
- Persistent State Machine
- Application Configuration
- Transient Record Control
In next section we'll actually write some code to do this.
Some Applications
Here are some of the applications that Berkley DB have been used
to implement:
- Persistent State Machine.
- Application Configuration.
- Transient Record Control.
[Editor’s Note: This article was particularly relevant to me. I
am working with a firm that uses Sleepy Cat (Berkley DB under
commercial license for support and enhancements). It is used as a
fast distributed backing store that front-ends an Oracle database
backend.
By Reg. Charney
Arrogance and
Greed
By now, you must have heard about the arrest and detention of
Dmitri Sklyarov, the Russian programmer who wrote a decoder for
Adobe’s eBook file format. He was arrested after giving a
presentation at the Las Vegas Hacker’s conference. Dmitri was
accused of contravening the Digital Millennium Copyright Act (DMCA)
which says that it is illegal to digitally reproduce copyrighted
material for any reason or to write software that can be used for
that purpose. Dmitri wrote software for a Russian company that
allowed Adobe’s eBook file format to be read on devices other than
those originally supported. Based on Adobe’s complaint, the FBI
arrested Dmitri and held him incommunicado for days without access
to the Russian consul or to a lawyer. Is this right or are the Feds
trying to intimidate us all based on their power and arrogance?
Speaking of arrogance, the DMCA is a bad law, but also arrogant law.
What right do the companies who paid for the DMCA have to impose
U.S. laws on foreign firms, other than arrogance and greed? What
Dmitri did in Russia was legal. What if you wrote a program here and
went overseas for a vacation only to find yourself arrested because
writing such a program which was illegal there? Are you to be a
prisoner in the U.S. and in a given state, least one of your
legitimate activities is illegal outside your immediate
jurisdiction? The DMCA makes us all into potential criminals subject
to unrestricted arrest and seizure. Look at Dmitri—you could be
next.
Change and
Growth
As you may have noticed, there are a number of new contributors
to this issue of ACCent. It is with tremendous pleasure and pride
that I can welcome Ali Çehreli, who is now doing the Trends page.
Also, Jesse Monroy, Jr. has contributed immensely to this issue. He
has written the main article and also done the book review. At this
rate, he will soon replace me ;-).
By Allan Kelly
Most people who have studied software development will have
learned about methodologies like Jackson JSD, Yourdon and SSADM.,
but somehow these methodologies belong to alternative world of
software development, they are slow and lumbering, with formal
hierarchies and lots of useless documentation. While many of us have
experience parts of a methodology few of us have been unlucky enough
to experience an entire project run on formal basis.
While some methodology didn’t survive the coming of PCs and
object oriented programming they have not gone away altogether. A
few years ago Kent Beck came along with Extreme Programming (XP).
Beck seemed to say: “rather than design a methodology and force
people to work to it, lets take what works and structure it.”
Observant readers of ACCU literature will know that I’m less than
impressed by XP, but it does contain a lot of good ideas.
Well, it turns out that XP is not alone, around the same time
other people had similar ideas. They have adopted the title “Agile”
and formed an alliance of like minded new methodologists, you can
read their manifesto at www.agilealliance.org
.
The manifesto can seem a little abstract but fortunately Martin
Fowler (author of several books on UML, XP and patterns) has done a
good job of putting the whole thing in context in two papers, “The
New methodologies” and “The Agile Manifesto: where it came from”
both are available on his web site at www.martinfowler.com
.
There are several agile methodologies to choose from but all have
similar underpinnings: low ceremony, “lightweight”, short
iterations, open to change and, perhaps most importantly: people
centric. The traditional methodologies tended to treat developers as
plug-compatible programming units, the agile methodologies put the
people at the centre of the process. This dirty little secret of
software development has long been know by us, the practitioners:
all programmers are not created equal; however it always seemed that
MBAs don’t teach this fact.
Although not part of the Alliance Jim Coplien has conducted
research in similar areas and produced a set of organisational
patterns. More details at his web site www.bell-labs.com/user/cope
.
These methodologies and patterns are all in their early stages
yet and subject to change. Most actually encourage practitioners to
refine the process as they use it: this is something I have long
believed, all methodologies are models, each must be tailored to
your environment, your business model, your developers and your
requirements. Long term, the acceptance of the process feedback loop
may be even more dramatic than accepting that good people are
important.
By Jesus Monroy, Jr. (jessemonroy@email.com
)
Programming Embedded Systems in C and C++, 1st
Ed. by Michael Barr. Publisher: O'Reilly & Associates.
ISBN: 1-56592-354-5
The book, in the preface, claims to be written for two types of
readers: beginners - like college graduates; and embedded systems
programmers.
This is a good book for someone that knows something about
programming C or C++, but does not know embedded systems.
The coverage in the book was decent. However, embedded systems is
a large topic and therefore a difficult one to cover. The author's
coverage is light, at best. The author might have done better, if a
different approach was taken, or even a different title was given to
the book.
There were four disincentives to checking code in this book:
- The code was extremely simplistic.
- The code compiled on a compiler I did not have (Borland).
- The example code was supposed to run on an embedded system I
did not own.
- The author made no provision to provide the code in electronic
format.
The book does not rate well. I would mark it next to useless. I
found several items particularly annoying.
At the writing of this book, Linux was not available on many
embedded systems. Choosing the Arcom Target188EB was probably as
good as any. However, it is PC-104, making it unduly expensive -
$275 retail.
In one section of the book the author addresses the reader in a
female tone. This is particularly annoying. Here is a clip:
“After reading the first five chapters, she will be able to
put her programing skills …”
I’m for equal rights, but this is a particularly annoying
moniker. I've encountered this type of writing before. It is either
bad humor, bad writing, or just meant to annoy.
This books fills a vacuum, but not in a very good fashion. The
140+ pages might be better spent with on-line examples or having the
finally product do more than “Hello World!”.
As a final note to the author, this is a good start. You writing
style is good. The area intended for this book has a vacuum. You can
fill it. I would suggest writing the next book with less expensive
components - maybe even an obsolete system, like an 80286 PC, or a
MAC SE. Or maybe a book with some generic *useful* libraries.
By Ali Cehreli
New
person, same job market
Now it is my turn to be challenged to find interesting trends to
write about in the technology jobs market. As Reg. has been
repeating for many months now, the job market has been shrinking
steadily. The only interesting thing has been the change of this
change. This month is not different: Figure 1 shows how the drop in
the job market has changed last month. The drop is actually
dropping. Hopefully this will be more than just a hiccup like the
one in March 2001, and the market will finally start to grow.

I also want to look at some raw figures that display the relative
differences in language demand, along with the dramatic change in
the number of language related jobs that took place in the last two
years.

The interesting thing in this figure is how C/C++ and Java remain
constant in September-October 2000 timeframe while the others
continue to drop to a local dip only to recover temporarily. For
C/C++ and Java, a bigger drop comes at around January 2001.
Being a software engineer in the Silicon Valley, I’ve been
witnessing the drop in the job markets as the now-very-usual news of
layoffs here and there. Amazingly though the valley is still very
fertile with the numerous startup companies still looking for strong
engineering talents to beat their competition and come out on top.
|