Shop OBEX P1 Docs P2 Docs Learn Events
PropDBM with ADT — Parallax Forums

PropDBM with ADT

kuismakuisma Posts: 134
edited 2010-12-02 03:35 in Accessories
I am working on a dbm database for the Spinneret using the sd card as backend storage.

Features
- Store key/value pairs
- A layer of abstract data types for fifo, stack etc.
- Multiple object multiple cog access.

The basic API
db.store(db_id, key_ptr, key_len, data_ptr, data_len)

Arguments
- db_id - numeric 32 bit identifier of database to use
- key_ptr - pointer to key (arbitrary length < 496 byte)
- key_len - length of key
- data_prt - pointer to data
- data_len - length of data

Examples
#0, MYDB, MYLONGS
...
file byte "/my/file.txt", 0
...
db.store(MYDB, @file, strsize(@file), data_ptr, data_len)
db.store(MYLONGS, @an_index, 4, @a_long, 4)

Syntactic sugars to store common data types, e.g. longs, files etc.

store_long(database, key, long_value)
store_string(database, key, string_ptr)
store_file(database, filename, data_ptr, data_length)

I do not want the overhead of a file system on the sd card, but using it as a pure block device. This way the code will be small and efficient, but not suitable for transferring data to/from e.g. a PC. Instead simple get/put http commands to populate and backup database may be implemented.

The database is implemented as a hash table, using safe_spi for sd card block i/o. Other backend drivers may be used, as long they can store and retrieve block data.

Current status
- Basic API implemented.
- Syntactic sugers for longs and files.
- Lots of bugs.
- Object size limitations.

This thread is for a general discussion about this project. Feel free to add comments, suggestions etc.

Comments

  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2010-12-02 03:35
    @kuisma

    Interesting project. It seem that I've been out of tech school too long. I got stuck on the term Syntactic sugar . I'll add a reference for anyone else that doesn't know what Syntactic sugar means. :)

    From the Wiki:

    "Syntactic sugar is a computer science term that refers to syntax within a programming language that is designed to make things easier to read or to express, while alternative ways of expressing them exist.

    It makes the language "sweeter" for humans to use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer."



    etc ....

    http://en.wikipedia.org/wiki/Syntactic_sugar
Sign In or Register to comment.