Git Product home page Git Product logo

xattrkv's Introduction

xattrkv

A key value store backed by Mac OS's HFS+ extended attributes, which are stored in a B-tree.

Example usage can be seen in test.c

  db = xattrkv_new("name");

Creates a new empty file.

  xattrkv_set(db, "key", "some long string");

Sets the key "key" to "some long string"

  value = xattrkv_get(db, "keyname");

Stores the value (if it exists) of key "keyname" in a string. Caller is responsible for freeing.

  xattrkv_keys(db, &keys, &nkeys);

Returns an array of strings of key names in (char **keys).

limitations

There are probably a lot of limitations. I am afraid to benchmark this on my computer because I don't know what effect storing lots of data in attributes will have on the over all filesystem :) I suggest making a separate disk image or sparse image to play with it on.

Individual values can be up to almost 2 gigabytes, but I haven't tried that, nor have I set any limitations on the size you can attempt to write. It's unclear if there is an OS imposed limit on the number of keys. I've been able to set 10 million.

If you create a store, then delete it, Mac OS seems to remember key names for that file (maybe not forever?) but doesn't keep any values.

If you do a directory listing in a directory where you stored lots of keys, it will take a long time.

Copying the file off the system won't also copy the extended attribute data.

Keys are limited by Mac OS to 127 characters, more than that will fail with EPERM. (should be ENAMETOOLONG according to the man page, but we get EPERM from the OS)

xattrkvtool

compile with:

gcc xattrkvtool.c xattrkv.c -o xattrkvtool

create a datastore by touching a file

# touch dbstore 

set keys

# xattrkvtool dbstore set awesome "the file is zero size, so you can store an infinite amount of data probably"

list keys

# xattrkvtool dbstore keys
awesome
#

get values

# xattrkvtool dbstore get awesome
the file is zero size, so you can store an infinite amount of data probably

delete keys

# xattrkvtool dbstore del awesome

xattrkv's People

Contributors

jwerle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xattrkv's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.