Hi,

I'm a bit torn about one aspect of the new index
framework<http://wiki.neo4j.org/content/Index_Framework>:
index creation.

My initial though with it was do creation just like you do with an embedded
graph database, i.e. there's no explicit "creation" phase for it, instead
you just instantiate a:

    new EmbeddedGraphDatabase( "my/dir" );
 or
    new EmbeddedGraphDatabase( "my/dir", myConfigMap );

and it will be created if it doesn't exist... even taking some parameters
from the map and storing permanently the first time so they cannot be
changed as long as the database is there (f.ex. string block size and more).
It's about usability IMO to not have to do:

   if ( dbDoesntExist( "my/dir" ) )
   {
       createDb( "my/dir" );
   }
   else
   {
       openDb( "my/dir" );
   }

or similar... Now looking at index creation, it's done in a similar fashion:

   // will create an index "persons" w/ default configuration if it doesn't
exist
   // else it will just return it w/ the config used when creating it.
   graphDb.index().forNodes( "persons" );

   // will create an index "persons" w supplied configuration if it doesn't
exist.
   // if it does exist then configuration must match the stored config.
   // if it already existed it will be returned w/ the config used when
created.
   graphDb.index().forNodes( "persons", myConfigMap );


Is it a bad thing or surprising that index creation happens as a side effect
of requesting? Of course it could be. Should there instead be:

   graphDb.index().forNodes( "persons" );
   graphDb.index().createForNodes( "persons", myConfigMap );

so that creation is explicit? Then your code would potentially have to do a:

  Index<Node> personIndex = null;
  if ( indexExists( "persons" ) )
     personIndex = graphDb.index().forNodes( "persons" );
  else
     personIndex = graphDb.index().createForNodes( "persons", myConfigMap );
  doStuffWith( personIndex );

If you don't have a place where such initialization occurs for each startup,
making sure all your needed indexes are created if they do not exist.


Input on this, anyone?

-- 
Mattias Persson, [matt...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to