fluiddb
satya - Thursday, August 26, 2010 9:22:19 AM
how to use fluiddb
how to use fluiddb
satya - Thursday, August 26, 2010 9:22:33 AM
fluiddb sample
fluiddb sample
satya - Thursday, August 26, 2010 9:38:42 AM
related to
information retrieval
CQL
couchdb
mongodb
riak
terrastore
satya - Thursday, August 26, 2010 9:38:56 AM
query examples
tim/rating > 5
sally/opnion matches good
has sally/opinion
satya - Thursday, August 26, 2010 9:39:18 AM
permissions
tim/seen read closed tim, meg
mike/opinion update open
mike/ create closed mike
meg/rating see open
meg/rating read closed meg
satya - Thursday, August 26, 2010 9:41:42 AM
features
writable to the public
(similar to wiki)
data model is flexible
attribute value stores
similar to cql queries
supposedly simpler than sql
returns objects
permissions similar to queries
satya - Thursday, August 26, 2010 9:43:27 AM
here are client side libraries
satya - Thursday, August 26, 2010 9:46:42 AM
Is there an online Fluiddb browser
Is there an online Fluiddb browser
satya - Thursday, August 26, 2010 9:50:15 AM
Neo4J: graph database
Neo4J: graph database
satya - Thursday, August 26, 2010 9:53:56 AM
others
Amazon SimpleDB,
CouchDB,
Google App Engine,
and Persevere of NoSQL
satya - Thursday, August 26, 2010 9:58:26 AM
This seems like a good enough example
satya - Thursday, August 26, 2010 10:12:36 AM
jar file gson download
jar file gson download
satya - Thursday, August 26, 2010 10:13:51 AM
gson download
You will need this because jfluiddb uses json
satya - Thursday, August 26, 2010 10:19:09 AM
json java jar file download
json java jar file download
satya - Thursday, August 26, 2010 12:02:25 PM
examle
book1
name
isbn
author: satya
read: sonya
satya
fname
lname
child: kavitha
sonya
fname
lname
satya - Thursday, August 26, 2010 5:34:11 PM
To run the JFluidDb sample above you need
org.json.*
apache http client
commons lang 2.x
satya - Thursday, August 26, 2010 6:08:20 PM
Here is how you get a ref to the database
//Use a url to start off
FluidDB fdb = new FluidDB(FluidConnector.SandboxURL);
satya - Thursday, August 26, 2010 6:08:52 PM
Here is how you login
// Login to FluidDB with your credentials
String username = "test";
String password = "test";
fdb.Login(username, password);
satya - Thursday, August 26, 2010 6:09:19 PM
Here is how you create your own space
// Get the User object representing me
User u = fdb.getLoggedInUser();
// My root namespace
Namespace root = u.RootNamespace();
// Create a new namespace underneath my root namespace
Namespace books = fdb.getNamespace("com.ai.books");
if (books == null)
{
books =
root.createNamespace("com.ai.books",
"For storing tags about books I might be reading.");
}
satya - Thursday, August 26, 2010 6:10:04 PM
Here is how you create tags
Tag title = books.createTag("Title", "The title of a book I've read", true);
Tag authors = books.createTag("Authors", "The author list", true);
Tag hasRead = books.createTag("HasRead", "Indicates I've read this book", true);
Tag rating = books.createTag("Rating", "Marks out of ten", true);
Tag comment = books.createTag("Comment", "Some notes and commentary", false);
satya - Thursday, August 26, 2010 6:10:33 PM
Create a book
// Create a new object
Object seven_pillars = fdb.createObject("ISBN:0954641809");
Object book2 = fdb.createObject("ISBN2");
satya - Thursday, August 26, 2010 6:12:00 PM
Attach tags to an object
seven_pillars.tag(hasRead);
// We're associating values with the tags
seven_pillars.tag(title, "Seven Pillars of Wisdom");
seven_pillars.tag(authors, new String[]{"T.E.Lawrence"});
seven_pillars.tag(rating, 8);
seven_pillars.tag(comment, "dddddd");
satya - Thursday, August 26, 2010 6:14:57 PM
Searching
// A search of all objects that I have read
String[] result = fdb.searchObjects("has "+username+"/com.ai.books/HasRead");
// result will contain only one result...
// the id for the seven_pillars Object
// Lets instantiate it and get a list of
// the available tags I have permission to see
Object newObj = fdb.getObject(result[0]);
String[] tagPaths = newObj.getTagPaths();
// tagPaths will include my tags I created above...
// Lets get the first tag and find out what is in it...
Tag newTag = fdb.getTag(tagPaths[0]);
FluidResponse r = newObj.getTagValue(newTag);
// Assuming all is well the result is
// returned by calling r.getResponseContent();
satya - Thursday, August 26, 2010 6:16:21 PM
Permissions
// This will only give the current user
// and the fluiddb "superuser" account the ability
// to create namespaces underneath the namespace "book"
Permission p = new Permission(
Policy.CLOSED, new String[]{"fluidDB", username});
books.setPermission(Namespace.Actions.CREATE, p);
// Lets get the default permission policy
// for the user for updating the "books/rating" tag
Permission updateTag = rating.getTagPermission(Tag.TagActions.UPDATE);
// Calling GetPolicy() and GetExceptions()
// on an instance of the Permission class will
// tell you what the permissions
// are (as described in the FluidDB docs)
satya - Thursday, August 26, 2010 6:17:16 PM
Cleanup
newObj.deleteTag(title);
newObj.deleteTag(authors);
newObj.deleteTag(hasRead);
newObj.deleteTag(rating);
newObj.deleteTag(comment);
// Now delete the tags
title.delete();
authors.delete();
hasRead.delete();
rating.delete();
comment.delete();
// and finally the namespace
books.delete();