Created
June 27, 2012 08:32
-
-
Save ib84/3002452 to your computer and use it in GitHub Desktop.
little hypergraphdb demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hgtest.storage | |
import org.hypergraphdb._ | |
import collection.JavaConversions._ | |
import org.hypergraphdb.HGQuery.hg | |
import org.hypergraphdb.query.AtomTypeCondition | |
import org.hypergraphdb.util.HGUtils | |
import storage.bje.BJEStorageImplementation | |
object Test extends App{ | |
var config: HGConfiguration = new HGConfiguration | |
val graph = new HyperGraph(); | |
config.setStoreImplementation(new BJEStorageImplementation); config | |
graph.setConfig(config) | |
graph.open("/home/ingvar/workspace/blankHgdbDBdir/") | |
val handles1 = (1 to 3).map(i => hg.assertAtom(graph, i.toString)).toArray[HGHandle] | |
val handles2 = Vector(2, 3, 6, 8).map(i => hg.assertAtom(graph, i.toString)).toArray[HGHandle] | |
val combo1 = graph.add(new HGPlainLink(handles1:_*)) | |
val combo2 = graph.add(new HGPlainLink(handles2:_*)) | |
val query23 : java.util.List[HGPersistentHandle] = hg.findAll(graph, hg.link(handles2(0), handles2(1))) | |
val found = if (query23.size > 0) query23.forall{result => result.equals(combo1.getPersistent) ||result.equals(combo2.getPersistent) } else false | |
println("found both links pointing to 2 and 3?" + found) | |
// => prints true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment