コード例 #1
0
ファイル: BplusTreeLong.cs プロジェクト: katnegermis/BTree
 public static BplusNode BinaryRoot(BplusNode LeftNode, string key, BplusNode RightNode, BplusTreeLong owner)
 {
     BplusNode newRoot = new BplusNode(owner, null, -1, false);
     //newRoot.Clear(); // redundant
     newRoot.ChildKeys[0] = key;
     LeftNode.Reparent(newRoot, 0);
     RightNode.Reparent(newRoot, 1);
     // new root is stored elsewhere
     return newRoot;
 }
コード例 #2
0
ファイル: BplusTreeLong.cs プロジェクト: katnegermis/BTree
 /// <summary>
 /// Create a new BplusNode and install in parent if parent is not null.
 /// </summary>
 /// <param name="owner">tree containing the node</param>
 /// <param name="parent">parent node (if provided)</param>
 /// <param name="indexInParent">location in parent if provided</param>
 public BplusNode(BplusTreeLong owner, BplusNode parent, int indexInParent, bool isLeaf)
 {
     this.isLeaf = isLeaf;
     this.owner = owner;
     this.parent = parent;
     this.Size = owner.NodeSize;
     //this.isValid = true;
     this.Dirty = true;
     //			this.ChildBufferNumbers = new long[this.Size+1];
     //			this.ChildKeys = new string[this.Size];
     //			this.MaterializedChildNodes = new BplusNode[this.Size+1];
     this.Clear();
     if (parent!=null && indexInParent>=0)
     {
         if (indexInParent>this.Size)
         {
             throw new BplusTreeException("parent index too large");
         }
         // key info, etc, set elsewhere
         this.parent.MaterializedChildNodes[indexInParent] = this;
         this.myBufferNumber = this.parent.ChildBufferNumbers[indexInParent];
         this.indexInParent = indexInParent;
     }
 }
コード例 #3
0
ファイル: BplusTreeLong.cs プロジェクト: katnegermis/BTree
 /// <summary>
 /// check that key is ok for node of this size (put here for locality of relevant code).
 /// </summary>
 /// <param name="key">key to check</param>
 /// <param name="owner">tree to contain node containing the key</param>
 /// <returns>true if key is ok</returns>
 public static bool KeyOK(string key, BplusTreeLong owner)
 {
     if (key==null)
     {
         return false;
     }
     System.Text.Encoder encode = System.Text.Encoding.UTF8.GetEncoder();
     int maxKeyLength = owner.KeyLength;
     int maxKeyPayload = maxKeyLength - BufferFile.SHORTSTORAGE;
     char[] keyChars = key.ToCharArray();
     int charCount = encode.GetByteCount(keyChars, 0, keyChars.Length, true);
     if (charCount>maxKeyPayload)
     {
         return false;
     }
     return true;
 }
コード例 #4
0
ファイル: BplusTreeLong.cs プロジェクト: katnegermis/BTree
 public static BplusTreeLong InitializeInStream(System.IO.Stream fromfile, int KeyLength, int NodeSize, int CultureId, long StartSeek)
 {
     if (fromfile.Length>StartSeek)
     {
         throw new BplusTreeException("can't initialize bplus tree inside written area of stream");
     }
     BplusTreeLong result = new BplusTreeLong(fromfile, NodeSize, KeyLength, StartSeek, CultureId);
     result.setHeader();
     result.buffers = BufferFile.InitializeBufferFileInStream(fromfile, result.buffersize, StartSeek+result.headersize);
     return result;
 }
コード例 #5
0
ファイル: BplusTreeLong.cs プロジェクト: katnegermis/BTree
 public static BplusTreeLong SetupFromExistingStream(System.IO.Stream fromfile, long StartSeek)
 {
     int dummyId = System.Globalization.CultureInfo.InvariantCulture.LCID;
     BplusTreeLong result = new BplusTreeLong(fromfile, 7, 100, StartSeek, dummyId); // dummy values for nodesize, keysize
     result.readHeader();
     result.buffers = BufferFile.SetupFromExistingStream(fromfile, StartSeek+result.headersize);
     if (result.buffers.buffersize != result.buffersize)
     {
         throw new BplusTreeException("inner and outer buffer sizes should match");
     }
     if (result.rootSeek!=NULLBUFFERNUMBER)
     {
         result.root = new BplusNode(result, null, -1, true);
         result.root.LoadFromBuffer(result.rootSeek);
     }
     return result;
 }
コード例 #6
0
ファイル: BplusTreeLong.cs プロジェクト: petlof/BplusDotNet
 /// <summary>
 /// check that key is ok for node of this size (put here for locality of relevant code).
 /// </summary>
 /// <param name="key">key to check</param>
 /// <param name="owner">tree to contain node containing the key</param>
 /// <returns>true if key is ok</returns>
 public static bool KeyOK(string key, BplusTreeLong owner)
 {
     if (key==null)
     {
         return false;
     }
     var encode = Encoding.UTF8.GetEncoder();
     var maxKeyLength = owner.KeyLength;
     var maxKeyPayload = maxKeyLength - BufferFile.Shortstorage;
     var keyChars = key.ToCharArray();
     var charCount = encode.GetByteCount(keyChars, 0, keyChars.Length, true);
     if (charCount>maxKeyPayload)
     {
         return false;
     }
     return true;
 }
コード例 #7
0
ファイル: BplusTreeLong.cs プロジェクト: katnegermis/BTree
 void Destroy()
 {
     // make sure the structure is useless, it should no longer be used.
     this.owner = null;
     this.parent = null;
     this.Size = -100;
     this.ChildBufferNumbers = null;
     this.ChildKeys = null;
     this.MaterializedChildNodes = null;
     this.myBufferNumber = BplusTreeLong.NULLBUFFERNUMBER;
     this.indexInParent = -100;
     this.Dirty = false;
 }
コード例 #8
0
ファイル: BplusTreeLong.cs プロジェクト: petlof/BplusDotNet
 public static BplusTreeLong SetupFromExistingStream(Stream fromfile, long startSeek)
 {
     var dummyId = CultureInfo.InvariantCulture.LCID;
     var result = new BplusTreeLong(fromfile, 7, 100, startSeek, dummyId); // dummy values for nodesize, keysize
     result.ReadHeader();
     result.Buffers = BufferFile.SetupFromExistingStream(fromfile, startSeek+result.m_headersize);
     if (result.Buffers.Buffersize != result.Buffersize)
     {
         throw new BplusTreeException("inner and outer buffer sizes should match");
     }
     if (result.m_rootSeek!=Nullbuffernumber)
     {
         result.m_root = new BplusNode(result, null, -1, true);
         result.m_root.LoadFromBuffer(result.m_rootSeek);
     }
     return result;
 }
コード例 #9
0
ファイル: BplusTreeLong.cs プロジェクト: petlof/BplusDotNet
 public static BplusTreeLong InitializeInStream(Stream fromfile, int keyLength, int nodeSize, int cultureId, long startSeek)
 {
     if (fromfile.Length>startSeek)
     {
         throw new BplusTreeException("can't initialize bplus tree inside written area of stream");
     }
     var result = new BplusTreeLong(fromfile, nodeSize, keyLength, startSeek, cultureId);
     result.SetHeader();
     result.Buffers = BufferFile.InitializeBufferFileInStream(fromfile, result.Buffersize, startSeek+result.m_headersize);
     return result;
 }
コード例 #10
0
ファイル: BplusTreeLong.cs プロジェクト: petlof/BplusDotNet
 void Destroy()
 {
     // make sure the structure is useless, it should no longer be used.
     m_owner = null;
     m_parent = null;
     m_size = -100;
     m_childBufferNumbers = null;
     m_childKeys = null;
     m_materializedChildNodes = null;
     MyBufferNumber = BplusTreeLong.Nullbuffernumber;
     m_indexInParent = -100;
     m_dirty = false;
 }
コード例 #11
0
ファイル: BplusTreeBytes.cs プロジェクト: anukat2015/sones
		public BplusTreeBytes(BplusTreeLong tree, LinkedFile archive)
		{
			this.tree = tree;
			this.archive = archive;
		}
コード例 #12
0
ファイル: BplusTreeBytes.cs プロジェクト: petlof/BplusDotNet
 public BplusTreeBytes(BplusTreeLong tree, LinkedFile archive)
 {
     m_tree = tree;
     m_archive = archive;
 }