Example #1
0
		/// <summary>
		/// Create the internal storage for the dbFile.
		/// Note:
		///   1. a helper file for segment managment b-tree is also created if this database file
		///      does not exist.
		/// </summary>
		/// <param name="dbFile"></param>
		public ObjectStore(string dbFileName)
		{
			m_dbFile = new DiskFile(dbFileName);
			m_indexFile = new DiskFile(dbFileName+".idx");
			m_indexPageManager = new memSegmentManager(m_indexFile);

			if (m_indexPageManager.Header.InitializeNeeded)
			{
				m_indexPageManager.Header.NextSegmentId = 0;
				m_indexPageManager.Header.NextObjectId = 0;
				m_indexPageManager.Header.NextClassId = 0;

				//initialize the segment b-tree's top node id
				OOD.Imp.Storage.BNode segTreeTop = new OOD.Imp.Storage.BNode();
				m_indexPageManager.GetNewSegment(segTreeTop);
				segTreeTop.SetOrder(m_segTreeNodeOrder);
				segTreeTop.Leaf = true;
				m_indexPageManager.Header.SegmentTreeTopNodeSId = segTreeTop.SegmentID;

				//initialize the space b-tree's top node id
				BNode spaceTreeTop = new BNode();
				m_indexPageManager.GetNewSegment(spaceTreeTop);
				spaceTreeTop.SetOrder(m_spaceTreeNodeOrder);
				spaceTreeTop.Leaf = true;
				m_indexPageManager.Header.FreeSpaceTreeTopNodeSId = spaceTreeTop.SegmentID;
			}

			m_segmentIndexTree = new SegTree(m_indexPageManager.Header.SegmentTreeTopNodeSId, m_indexPageManager);
			m_spaceIndexTree = new SpaceTree(m_indexPageManager.Header.FreeSpaceTreeTopNodeSId, m_indexPageManager, m_dbFile);

			m_dbSegmentManager = new dbSegmentManager(
				m_indexPageManager.Header.NextSegmentId,
				m_segmentIndexTree,
				m_spaceIndexTree,
				m_dbFile);


			if (m_indexPageManager.Header.InitializeNeeded)
			{
				BNode catalogTop = new BNode();
				m_dbSegmentManager.GetNewSegment(catalogTop);
				catalogTop.SetOrder(m_catalogTreeNodeOrder);
				catalogTop.Leaf = true;

				m_indexPageManager.Header.CatalogTreeTopNodeSId = catalogTop.SegmentID;
			}

			m_catalogTree = new CatalogTree(
				m_indexPageManager.Header.CatalogTreeTopNodeSId,
				m_dbSegmentManager,
				m_indexPageManager.Header.NextClassId);

			m_classCache = new LRUHashtable(m_cache_size, m_classCacheLimit);
			m_objectTreeCache = new LRUHashtable(m_cache_size, m_objectTreeCacheLimit);

			//bring top node's segment tree, space tree, catalog tree into cache, they will be needed anyway
			if (!m_indexPageManager.Header.InitializeNeeded)
			{
				m_indexPageManager.GetSegment(m_segmentIndexTree.TopNodSegId, new BNode(), new KSegId());
				m_indexPageManager.GetSegment(m_spaceIndexTree.TopNodeSId, new BNode(), new KOffset());
				m_dbSegmentManager.GetSegment(m_catalogTree.TopNodeSId, new BNode(), new KCatalog());
			}
		}
Example #2
0
			public MyEnumerator(LRUHashtable table) 
			{
				m_table = table;
			}