Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
README

README

----------------------------------------------------------------------
- The UNIX filesystem as an object store
----------------------------------------------------------------------

With MP3 we have ID3; i.e. a standard for metadata. Thus we have audio
file organizers like iTunes, Amarok, and Banshee.

But what about PDF files (research papers, books, manuals)? Images?
Movies? The situation isn't as nice for these.

With the UNIX filesystem, a general scheme for metadata storage can be
acheived.

Every file goes in it's own "object" directory.

Suppose I have 'avatar.avi'. A directory is created, the name of which
is a unique id:

    00000001

Inside that directory are various files:

    budget  data.avi  date  director  starring  title

The metadata was stored as such:

    $ echo 'Avatar'          >  title
    $ echo '2009'            >  date
    $ echo 'James Cameron'   >  director
    $ echo 'Sam Worthington' >  starring
    $ echo 'Zoe Saldana'     >> starring
    $ echo '237000000'       >  budget

All the "object" directories are kept under a single directory:

    00000001
    00000002
    00000003
    ...

----------------------------------------------------------------------
- Views into the object store
----------------------------------------------------------------------

OK, so how do you get to your data after it's placed into the store?

You generate a "view" into the store based on some criteria.

If I'm in the store directory, a very simple criteria is simply "*",
i.e. all the objects.

Here I'm going to generate a view intended for display by Emacs's Org
Mode:

    $ md-org-view *

This is what I see after the view is created:

    http://i.imgur.com/oqDid.png

Each item in the list is a hyperlink to the media file corresponding
to that object.

Let me generate a view of objects with 'Scheme' in the title:

    $ md-org-view `md-grep title Scheme`

The md-grep command outputs a list of object IDs. The md-org-view
command accepts a list of IDs.

Let's generate a view of objects authored by Chomsky:

    $ md-org-view `md-grep author Chomsky`

----------------------------------------------------------------------
- Directory views
----------------------------------------------------------------------

The 'md-dir-view' command creates a directory with links to data
files.

For example, let's say I want a view of objects with the file
extension 'mp3':

    $ cd $(md-dir-view `md-ext mp3`)

I'm now in a the generated "view" directory:

    $ ls
    Bland Street Bloom  Government in the Future  Veil of Maya

What about a view of all pdf files, shown in nautilus:

    $ nautilus $(md-dir-view `md-ext pdf`)

This is an example of what you might see:

    http://i.imgur.com/tcf22.png

----------------------------------------------------------------------
- md-keys
----------------------------------------------------------------------

Returns all keys found in the store. For example:

    $ md-keys
    abstract
    album
    artist
    author
    authors
    date
    publisher
    summary
    title
    track

----------------------------------------------------------------------
- md-values KEY
----------------------------------------------------------------------

Finds all objects with KEY, retrieves the corresponding values, and
returns them. For example:

    $ md-values author
    Bjarne Stroustrup
    Jonathan Bartlett
    Noam Chomsky
    Peter Seibel
    Richard Blum

----------------------------------------------------------------------
- md-new-dir
----------------------------------------------------------------------

You can create a new object directory with 'md-new-dir':

    $ cd `md-new-dir`

----------------------------------------------------------------------
- md-set
----------------------------------------------------------------------

Creating a key value pair is as simple as:

    $ echo 2010-01-01 > date

You can use 'md-set' to do the same thing:

    $ md-set date 2010-01-01

One nice thing about 'md-set' is that bash can provide completion for
the key if you include this code in your 'bashrc':

    _md-set()
    {
    
        local cur
    
        cur=`_get_cword`
    
        COMPREPLY=( $( compgen -W "`cd .. ; md-keys`" -- $cur ) )
    
    }
    
    complete -F _md-set md-set

For example, on my system, I see this when I trigger completion:

    $ md-set 
    abstract   artist     authors    publisher  title      
    album      author     date       summary    track

----------------------------------------------------------------------
Something went wrong with that request. Please try again.