Example #1
0
        public void TestSimpleQuery()
        {
            var sid = Guid.NewGuid().ToString();

            using (var store = _storeManager.CreateStore(Configuration.StoreLocation + "\\" + sid))
            {
                var t = new Triple
                {
                    Subject   = "http://www.networkedplanet.com/people/10",
                    Predicate = "http://www.networkedplanet.com/model/isa",
                    Object    = "http://www.networkedplanet.com/types/person"
                };
                store.InsertTriple(t);

                store.Commit(Guid.Empty);
            }
            using (var store = _storeManager.OpenStore(Configuration.StoreLocation + "\\" + sid))
            {
                var triples = store.GetResourceStatements("http://www.networkedplanet.com/people/10");
                Assert.AreEqual(1, triples.Count());

                // do query
                const string query =
                    "select ?t where { ?t <http://www.networkedplanet.com/model/isa> <http://www.networkedplanet.com/types/person> }";
                store.ExecuteSparqlQuery(query, SparqlResultsFormat.Xml);
            }
        }
        private string CreateStore(string storeId = null, bool withTransactionLog = true)
        {
            var sid = storeId ?? "StoreWorkerTests_" + Guid.NewGuid();

            using (_storeManager.CreateStore(Configuration.StoreLocation + Path.DirectorySeparatorChar + sid, false, withTransactionLog))
            {
                return(sid);
            }
        }
Example #3
0
        /// <summary>
        /// Creates a new store and returns the store id
        /// </summary>
        /// <returns></returns>
        public string CreateStore()
        {
            Logging.LogInfo("Create Store");
            var sid = Guid.NewGuid().ToString();

            _storeManager.CreateStore(Path.Combine(_baseLocation, sid), true);
            Logging.LogInfo("Store id is {0}", sid);
            return(sid);
        }
        private string CreateStore()
        {
            var sid = Guid.NewGuid().ToString();

            using (_storeManager.CreateStore(Configuration.StoreLocation + Path.DirectorySeparatorChar + sid))
            {
                return(sid);
            }
        }
Example #5
0
        public void TestCreateBtree()
        {
            var sid   = Guid.NewGuid().ToString();
            var store = _storeManager.CreateStore(Configuration.StoreLocation + "\\" + sid) as Store;

            var btree = store.MakeNewTree <ObjectRef>(5);

            store.Commit(Guid.Empty);

            var store1 = _storeManager.OpenStore(Configuration.StoreLocation + "\\" + sid) as Store;
            var tree   = store1.LoadObject <PersistentBTree <ObjectRef> >(btree.ObjectId);

            Assert.IsNotNull(tree);
            Assert.AreEqual(tree.ObjectId, btree.ObjectId);
        }
        private IStore InitializeDocTagStore()
        {
            var    storeLoc = Configuration.StoreLocation + "\\doctagstore";
            IStore store;

            if (_storeManager.DoesStoreExist(storeLoc))
            {
                store = _storeManager.OpenStore(storeLoc);
                const string sparql = "SELECT ?doc ?cat WHERE { ?doc <http://www.bs.com/tag> <http://www.bs.com/category/1> . ?doc <http://www.bs.com/tag> ?cat . }";
                store.ExecuteSparqlQuery(sparql, SparqlResultsFormat.Xml);
                return(store);
            }
            store = _storeManager.CreateStore(storeLoc);
            var rand = new Random();

            for (int i = 0; i < 1000000; i++)
            {
                store.InsertTriple("http://www.bs.com/doc/" + i,
                                   "http://www.bs.com/tag",
                                   "http://www.bs.com/category/" + rand.Next(50), false, null, null, Constants.DefaultGraphUri);
                store.InsertTriple("http://www.bs.com/doc/" + i,
                                   "http://www.bs.com/tag",
                                   "http://www.bs.com/category/" + rand.Next(50), false, null, null, Constants.DefaultGraphUri);
            }
            store.Commit(Guid.Empty);
            return(store);
        }
Example #7
0
 /// <summary>
 /// Create a new B* store.
 /// </summary>
 /// <param name="storeId">The new store ID</param>
 /// <returns>True if the store was created successfully, false otherwise</returns>
 public bool CreateStore(string storeId)
 {
     try
     {
         IStoreManager storeManager = GetStoreManager();
         storeManager.CreateStore(storeId, false).Close();
         return(true);
     }
     catch (Exception ex)
     {
         Trace.TraceError(String.Format("StoreWorkerService.CreateStore failed with exception: {0}", ex));
         throw;
     }
 }
Example #8
0
 public void SetUp()
 {
     _storeLocation = "brightstar\\" + Guid.NewGuid();
     _store         = _storeManager.CreateStore(_storeLocation);
 }
Example #9
0
        private PersistentBTree <ObjectRef> BuildTree(Guid storeId)
        {
            var store = _storeManager.CreateStore(BrightstarDB.Configuration.StoreLocation + "\\" + storeId) as Store;
            var tree  = store.MakeNewTree <ObjectRef>(5);

            var root = tree.MakeNewNode();

            root.Keys.Add(new Entry <ObjectRef>('m', null));

            var rootLeft = tree.MakeNewNode(root.NodeId);

            root.ChildNodes.Add(rootLeft.NodeId);

            var rootRight = tree.MakeNewNode(root.NodeId);

            root.ChildNodes.Add(rootRight.NodeId);

            // do root left
            rootLeft.Keys.Add(new Entry <ObjectRef>('d', null));
            rootLeft.Keys.Add(new Entry <ObjectRef>('g', null));

            var rootLeft1 = tree.MakeNewNode(rootLeft.NodeId);

            rootLeft1.Keys.Add(new Entry <ObjectRef>('a', null));
            rootLeft1.Keys.Add(new Entry <ObjectRef>('c', null));

            var rootLeft2 = tree.MakeNewNode(rootLeft.NodeId);

            rootLeft2.Keys.Add(new Entry <ObjectRef>('e', null));
            rootLeft2.Keys.Add(new Entry <ObjectRef>('f', null));

            var rootLeft3 = tree.MakeNewNode(rootLeft.NodeId);

            rootLeft3.Keys.Add(new Entry <ObjectRef>('h', null));
            rootLeft3.Keys.Add(new Entry <ObjectRef>('k', null));
            rootLeft3.Keys.Add(new Entry <ObjectRef>('l', null));

            rootLeft.ChildNodes.Add(rootLeft1.NodeId);
            rootLeft.ChildNodes.Add(rootLeft2.NodeId);
            rootLeft.ChildNodes.Add(rootLeft3.NodeId);

            // do root right
            rootRight.Keys.Add(new Entry <ObjectRef>('q', null));
            rootRight.Keys.Add(new Entry <ObjectRef>('t', null));

            var rootRight1 = tree.MakeNewNode(rootRight.NodeId);

            rootRight1.Keys.Add(new Entry <ObjectRef>('n', null));
            rootRight1.Keys.Add(new Entry <ObjectRef>('p', null));

            var rootRight2 = tree.MakeNewNode(rootRight.NodeId);

            rootRight2.Keys.Add(new Entry <ObjectRef>('r', null));
            rootRight2.Keys.Add(new Entry <ObjectRef>('s', null));

            var rootRight3 = tree.MakeNewNode(rootRight.NodeId);

            rootRight3.Keys.Add(new Entry <ObjectRef>('w', null));
            rootRight3.Keys.Add(new Entry <ObjectRef>('x', null));
            rootRight3.Keys.Add(new Entry <ObjectRef>('y', null));
            rootRight3.Keys.Add(new Entry <ObjectRef>('z', null));

            rootRight.ChildNodes.Add(rootRight1.NodeId);
            rootRight.ChildNodes.Add(rootRight2.NodeId);
            rootRight.ChildNodes.Add(rootRight3.NodeId);

            tree.Root = root;
            return(tree);
        }