亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bplustreelong.cs

?? R樹與B樹的混合樹
?? CS
?? 第 1 頁 / 共 5 頁
字號:
using System;
using System.Collections;

// delete next

namespace BplusDotNet
{
	/// <summary>
	/// Bplustree mapping fixed length strings (byte sequences) to longs (seek positions in file indexed).
	/// "Next leaf pointer" is not used since it increases the chance of file corruption on failure.
	/// All modifications are "shadowed" until a flush of all modifications succeeds.  Modifications are
	/// "hardened" when the header record is rewritten with a new root.  This design trades a few "unneeded"
	/// buffer writes for lower likelihood of file corruption.
	/// </summary>
	public class BplusTreeLong: ITreeIndex
	{
		public System.IO.Stream fromfile;
		// should be read only
		public bool DontUseCulture = false;
		public System.Globalization.CultureInfo cultureContext;
		System.Globalization.CompareInfo cmp = null;
		// should be read only
		public BufferFile buffers;
		// should be read only
		public int buffersize;
		// should be read only
		public int KeyLength;
		public long seekStart = 0;
		public static byte[] HEADERPREFIX = { 98, 112, 78, 98, 112 };
		// header consists of 
		// prefix | version | node size | key size | culture id | buffer number of root | buffer number of free list head
		int headersize = HEADERPREFIX.Length + 1 + BufferFile.INTSTORAGE*3 + BufferFile.LONGSTORAGE*2;
		public const byte VERSION = 0;
		// size of allocated key space in each node (should be a read only property)
		public int NodeSize;
		BplusNode root = null;
		long rootSeek; 
		long freeHeadSeek;
		public Hashtable FreeBuffersOnCommit = new Hashtable();
		public Hashtable FreeBuffersOnAbort = new Hashtable();
		Hashtable IdToTerminalNode = new Hashtable();
		Hashtable TerminalNodeToId = new Hashtable();
		int TerminalNodeCount = 0;
		int LowerTerminalNodeCount = 0;
		int FifoLimit = 100;
		public static int NULLBUFFERNUMBER = -1;
		public static byte NONLEAF = 0, LEAF = 1, FREE = 2;

		public BplusTreeLong(System.IO.Stream fromfile, int NodeSize, int KeyLength, long StartSeek, int CultureId)
		{
			this.cultureContext = new System.Globalization.CultureInfo(CultureId);
			this.cmp = this.cultureContext.CompareInfo;
			this.fromfile = fromfile;
			this.NodeSize = NodeSize;
			this.seekStart = StartSeek;
			// add in key prefix overhead
			this.KeyLength = KeyLength + BufferFile.SHORTSTORAGE;
			this.rootSeek = NULLBUFFERNUMBER;
			this.root = null;
			this.freeHeadSeek = NULLBUFFERNUMBER;
			this.SanityCheck();
		}
		
		public int MaxKeyLength() 
		{
			return this.KeyLength-BufferFile.SHORTSTORAGE;
		}
		public void Shutdown()
		{
			this.fromfile.Flush();
			this.fromfile.Close();
		}
		public int Compare(string left, string right) 
		{
			//System.Globalization.CompareInfo cmp = this.cultureContext.CompareInfo;
			if (this.cultureContext==null || this.DontUseCulture) 
			{
				// no culture context: use miscellaneous total ordering on unicode strings
				int i = 0;
				while (i<left.Length && i<right.Length) 
				{
					int leftOrd = Convert.ToInt32(left[i]);
					int rightOrd = Convert.ToInt32(right[i]);
					if (leftOrd<rightOrd) 
					{
						return -1;
					}
					if (leftOrd>rightOrd)
					{
						return 1;
					}
					i++;
				}
				if (left.Length<right.Length) 
				{
					return -1;
				}
				if (left.Length>right.Length) 
				{
					return 1;
				}
				return 0;
			}
			if (this.cmp==null) 
			{
				this.cmp = this.cultureContext.CompareInfo;
			}
			return this.cmp.Compare(left, right);
		}
		public void SanityCheck(bool strong) 
		{
			this.SanityCheck();
			if (strong) 
			{
				this.Recover(false);
				// look at all deferred deallocations -- they should not be free
				byte[] buffer = new byte[1];
				foreach (DictionaryEntry thing in this.FreeBuffersOnAbort) 
				{
					long buffernumber = (long) thing.Key;
					this.buffers.getBuffer(buffernumber, buffer, 0, 1);
					if (buffer[0]==FREE) 
					{
						throw new BplusTreeException("free on abort buffer already marked free "+buffernumber);
					}
				}
				foreach (DictionaryEntry thing in this.FreeBuffersOnCommit) 
				{
					long buffernumber = (long) thing.Key;
					this.buffers.getBuffer(buffernumber, buffer, 0, 1);
					if (buffer[0]==FREE) 
					{
						throw new BplusTreeException("free on commit buffer already marked free "+buffernumber);
					}
				}
			}
		}
		public void Recover(bool CorrectErrors) 
		{
			Hashtable visited = new Hashtable();
			if (this.root!=null) 
			{
				// find all reachable nodes
				this.root.SanityCheck(visited);
			}
			// traverse the free list
			long freebuffernumber = this.freeHeadSeek;
			while (freebuffernumber!=NULLBUFFERNUMBER) 
			{
				if (visited.ContainsKey(freebuffernumber) ) 
				{
					throw new BplusTreeException("free buffer visited twice "+freebuffernumber);
				}
				visited[freebuffernumber] = FREE;
				freebuffernumber = this.parseFreeBuffer(freebuffernumber);
			}
			// find out what is missing
			Hashtable Missing = new Hashtable();
			long maxbuffer = this.buffers.nextBufferNumber();
			for (long i=0; i<maxbuffer; i++) 
			{
				if (!visited.ContainsKey(i)) 
				{
					Missing[i] = i;
				}
			}
			// remove from missing any free-on-commit blocks
			foreach (DictionaryEntry thing in this.FreeBuffersOnCommit) 
			{
				long tobefreed = (long) thing.Key;
				Missing.Remove(tobefreed);
			}
			// add the missing values to the free list
			if (CorrectErrors) 
			{
				if (Missing.Count>0) 
				{
					System.Diagnostics.Debug.WriteLine("correcting "+Missing.Count+" unreachable buffers");
				}
				ArrayList missingL = new ArrayList();
				foreach (DictionaryEntry d in Missing) 
				{
					missingL.Add(d.Key);
				}
				missingL.Sort();
				missingL.Reverse();
				foreach (object thing in missingL) 
				{
					long buffernumber = (long) thing;
					this.deallocateBuffer(buffernumber);
				}
				//this.ResetBookkeeping();
			} 
			else if (Missing.Count>0)
			{
				string buffers = "";
				foreach (DictionaryEntry thing in Missing) 
				{
					buffers += " "+thing.Key;
				}
				throw new BplusTreeException("found "+Missing.Count+" unreachable buffers."+buffers);
			}
		}
		public void SerializationCheck()  
		{
			if (this.root==null) 
			{
				throw new BplusTreeException("serialization check requires initialized root, sorry");
			}
			this.root.SerializationCheck();
		}
		void SanityCheck() 
		{
			if (this.NodeSize<2) 
			{
				throw new BplusTreeException("node size must be larger than 2");
			}
			if (this.KeyLength<5) 
			{
				throw new BplusTreeException("Key length must be larger than 5");
			}
			if (this.seekStart<0) 
			{
				throw new BplusTreeException("start seek may not be negative");
			}
			// compute the buffer size
			// indicator | seek position | [ key storage | seek position ]*
			int keystorage = this.KeyLength + BufferFile.SHORTSTORAGE;
			this.buffersize = 1 + BufferFile.LONGSTORAGE + (keystorage + BufferFile.LONGSTORAGE)*this.NodeSize;
		}
		public string toHtml() 
		{
			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			sb.Append("<h1>BplusTree</h1>\r\n");
			sb.Append("\r\n<br> nodesize="+this.NodeSize);
			sb.Append("\r\n<br> seekstart="+this.seekStart);
			sb.Append("\r\n<br> rootseek="+this.rootSeek);
			sb.Append("\r\n<br> free on commit "+this.FreeBuffersOnCommit.Count+" ::");
			foreach (DictionaryEntry thing in this.FreeBuffersOnCommit) 
			{
				sb.Append(" "+thing.Key);
			}
			sb.Append("\r\n<br> Freebuffers : ");
			Hashtable freevisit = new Hashtable();
			long free = this.freeHeadSeek;
			string allfree = "freehead="+free+" :: ";
			while (free!=NULLBUFFERNUMBER) 
			{
				allfree = allfree+" "+free;
				if (freevisit.ContainsKey(free)) 
				{
					throw new BplusTreeException("cycle in freelist "+free);
				}
				freevisit[free] = free;
				free = this.parseFreeBuffer(free);
			}
			if (allfree.Length==0) 
			{
				sb.Append("empty list");
			} 
			else 
			{
				sb.Append(allfree);
			}
			foreach (DictionaryEntry thing in this.FreeBuffersOnCommit) 
			{
				sb.Append(" "+thing.Key);
			}
			sb.Append("\r\n<br> free on abort "+this.FreeBuffersOnAbort.Count+" ::");
			foreach (DictionaryEntry thing in this.FreeBuffersOnAbort) 
			{
				sb.Append(" "+thing.Key);
			}
			sb.Append("\r\n<br>\r\n");

			//... add more
			if (this.root==null) 
			{
				sb.Append("<br><b>NULL ROOT</b>\r\n");
			} 
			else 
			{
				this.root.AsHtml(sb);
			}
			return sb.ToString();
		}
		public BplusTreeLong(System.IO.Stream fromfile, int KeyLength, int NodeSize, int CultureId):
			this(fromfile, NodeSize, KeyLength, (long)0, CultureId) 
		{
			// just start seek at 0
		}
		public static BplusTreeLong SetupFromExistingStream(System.IO.Stream fromfile) 
		{
			return SetupFromExistingStream(fromfile, (long)0);
		}
		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;
		}
		public static BplusTreeLong InitializeInStream(System.IO.Stream fromfile, int KeyLength, int NodeSize) 
		{
			int dummyId = System.Globalization.CultureInfo.InvariantCulture.LCID;
			return InitializeInStream(fromfile, KeyLength, NodeSize, dummyId);
		}
		public static BplusTreeLong InitializeInStream(System.IO.Stream fromfile, int KeyLength, int NodeSize, int CultureId) 
		{
			return InitializeInStream(fromfile, KeyLength, NodeSize, CultureId, (long)0);
		}
		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;
		}
		public void SetFootPrintLimit(int limit) 
		{
			if (limit<5) 
			{
				throw new BplusTreeException("foot print limit less than 5 is too small");
			}
			this.FifoLimit = limit;
		}
		public void RemoveKey(string key) 
		{
			if (this.root==null) 
			{
				throw new BplusTreeKeyMissing("tree is empty: cannot delete");
			}
			bool MergeMe;
			BplusNode theroot = this.root;
			theroot.Delete(key, out MergeMe);
			// if the root is not a leaf and contains only one child (no key), reroot
			if (MergeMe && !this.root.isLeaf && this.root.SizeInUse()==0) 
			{
				this.root = this.root.FirstChild();
				this.rootSeek = this.root.makeRoot();
				theroot.Free();
			}
		}
		public long this[string key] 
		{
			get 
			{
				long valueFound;
				bool test = this.ContainsKey(key, out valueFound);
				if (!test) 
				{
					throw new BplusTreeKeyMissing("no such key found: "+key);
				}
				return valueFound;
			}
			set 
			{
				if (!BplusNode.KeyOK(key, this)) 
				{
					throw new BplusTreeBadKeyValue("null or too large key cannot be inserted into tree: "+key);
				}
				bool rootinit = false;
				if (this.root==null) 
				{
					// allocate root
					this.root = new BplusNode(this, null, -1, true);
					rootinit = true;
					//this.rootSeek = root.DumpToFreshBuffer();
				}
				// insert into root...
				string splitString;
				BplusNode splitNode;
				root.Insert(key, value, out splitString, out splitNode);
				if (splitNode!=null) 
				{
					// split of root: make a new root.
					rootinit = true;
					BplusNode oldRoot = this.root;
					this.root = BplusNode.BinaryRoot(oldRoot, splitString, splitNode, this);
				}
				if (rootinit) 
				{
					this.rootSeek = root.DumpToFreshBuffer();
				}
				// check size in memory

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲午夜久久久久中文字幕久| 久久久不卡网国产精品二区| 91麻豆精东视频| 波多野结衣中文字幕一区二区三区| 国产很黄免费观看久久| 国产精品自在在线| 不卡av在线网| 欧美性一二三区| 欧美日本不卡视频| 欧美一级日韩免费不卡| 日韩欧美精品三级| 久久美女高清视频| 国产精品国产馆在线真实露脸| 亚洲天堂福利av| 亚洲一区日韩精品中文字幕| 日本在线不卡一区| 国内精品国产三级国产a久久| 懂色av中文字幕一区二区三区| 成人高清免费观看| 色嗨嗨av一区二区三区| 91精品一区二区三区久久久久久| 精品少妇一区二区三区视频免付费| 久久精品综合网| 一区二区三区四区激情| 奇米一区二区三区av| 高清免费成人av| 欧美日韩二区三区| 精品sm在线观看| 亚洲伦理在线精品| 日韩av午夜在线观看| 国产成人精品影视| 欧美性生活久久| 久久久精品日韩欧美| 亚洲激情六月丁香| 麻豆成人久久精品二区三区小说| 成人中文字幕电影| 欧美一区二区国产| 中文字幕一区二区不卡| 婷婷中文字幕综合| 99精品久久免费看蜜臀剧情介绍| 制服丝袜亚洲网站| 中文字幕免费一区| 蜜臀av一区二区在线免费观看| 成人激情小说网站| 日韩视频永久免费| 亚洲免费av在线| 国产精一区二区三区| 欧美三级韩国三级日本一级| 国产喷白浆一区二区三区| 婷婷久久综合九色国产成人| www.亚洲人| 久久综合九色综合97_久久久| 亚洲在线一区二区三区| 成人综合婷婷国产精品久久| 精品欧美久久久| 亚洲二区在线视频| 一本到不卡免费一区二区| 久久久www成人免费毛片麻豆 | 亚洲精选一二三| 国产真实乱子伦精品视频| 欧美日韩和欧美的一区二区| 中文字幕日本不卡| 国产盗摄精品一区二区三区在线| 日韩一区二区三区四区| 午夜av区久久| 欧美体内she精视频| 亚洲码国产岛国毛片在线| 成人少妇影院yyyy| 中文字幕第一区二区| 国产精品一区二区在线观看网站| 欧美成人福利视频| 国产自产v一区二区三区c| www久久精品| 国模一区二区三区白浆| 久久久亚洲午夜电影| 国产麻豆视频精品| 久久综合九色综合欧美98| 国产乱国产乱300精品| 国产欧美日韩中文久久| 国产精品18久久久久久久网站| 欧美mv日韩mv国产网站| 国产美女视频一区| 日本一区二区久久| 91麻豆视频网站| 亚洲综合在线第一页| 欧美人与性动xxxx| 美女视频黄免费的久久| 久久综合色之久久综合| 国产很黄免费观看久久| 国产精品久久二区二区| 色视频一区二区| 日韩精彩视频在线观看| 亚洲精品在线观看视频| 成人在线综合网| 亚洲午夜精品17c| 日韩美女在线视频| 国产精品99久久久| 一区二区久久久| 欧美一区二区国产| 成人午夜电影久久影院| 一区二区三区欧美日韩| 正在播放亚洲一区| 国产成人在线免费观看| 亚洲男人天堂av网| 日韩一区二区三区电影| 高清不卡一区二区| 亚洲福利视频三区| 国产欧美一区视频| 欧美体内she精视频| 国内精品久久久久影院色| 亚洲日本va在线观看| 日韩欧美在线观看一区二区三区| 成人一区在线观看| 青草国产精品久久久久久| 日本一区免费视频| 欧美日韩国产综合一区二区| 成人激情小说网站| 另类小说欧美激情| 午夜欧美大尺度福利影院在线看| 26uuu色噜噜精品一区二区| 在线影视一区二区三区| 国产精品18久久久| 亚州成人在线电影| 一区视频在线播放| 精品国产1区2区3区| 欧美日韩五月天| 一本久久a久久免费精品不卡| 国产在线不卡视频| 视频一区中文字幕国产| 亚洲精品高清在线| 中日韩av电影| 久久午夜色播影院免费高清 | 亚洲精品一线二线三线| 欧美图片一区二区三区| thepron国产精品| 国产精品夜夜爽| 蜜臀国产一区二区三区在线播放| 亚洲一二三四区不卡| 亚洲欧美日韩国产中文在线| 中文字幕欧美区| 欧美国产成人在线| 中文字幕欧美激情一区| 久久久91精品国产一区二区精品| 日韩欧美三级在线| 91精品在线免费观看| 在线成人午夜影院| 欧美精品日日鲁夜夜添| 欧美色网站导航| 欧美视频一区二区三区在线观看| 99国产一区二区三精品乱码| 不卡在线视频中文字幕| 粉嫩av一区二区三区在线播放| 国产成人亚洲综合a∨婷婷| 国产综合久久久久久久久久久久| 久久99国产精品久久99果冻传媒| 免费在线观看日韩欧美| 久久成人麻豆午夜电影| 精品一区二区三区久久| 久久国产精品99久久人人澡| 精品在线你懂的| 国产精品一区久久久久| 大胆欧美人体老妇| 色婷婷久久久亚洲一区二区三区| 色丁香久综合在线久综合在线观看| 99久久国产免费看| 欧美性大战久久久| 欧美一区二区三区视频在线观看| 欧美一区二区三区在线看| 日韩欧美一区二区免费| 国产午夜精品久久久久久久 | 91精品国产色综合久久不卡蜜臀| 日韩三级免费观看| www日韩大片| 亚洲图片欧美激情| 亚洲国产日韩一级| 日本91福利区| 成人小视频在线| 欧美视频一区二区三区在线观看| 91精品欧美综合在线观看最新| 精品久久久久久久人人人人传媒| 国产欧美久久久精品影院 | 91极品视觉盛宴| 精品日韩一区二区三区 | 亚洲mv在线观看| 国产最新精品精品你懂的| 99精品久久只有精品| 91精品午夜视频| 中文字幕一区二区三区不卡| 日本欧美一区二区三区| 丁香婷婷深情五月亚洲| 欧美日韩激情在线| 中文字幕欧美三区| 日韩高清在线不卡| 97精品久久久午夜一区二区三区 | 一二三四社区欧美黄| 狠狠色狠狠色综合| 欧美亚洲一区三区| 国产日韩欧美电影| 日韩国产高清影视| 日本韩国精品在线|