public int BlocksAccessed() { var recordsPerBlock = _blockSize / _tableInfo.RecordLength; int blocksCount = _statInfo.RecordsOutput / recordsPerBlock; return(BTreeIndex.SearchCost(blocksCount, recordsPerBlock)); }
public void CanCreateBTreeIndex() { Assert.DoesNotThrow(() => { index = new BTreeIndex("id", schema, transaction); }); }
public void CanWriteAndRestoreFromBinary() { var index = new BTreeIndex <string, bool, bool>(10); foreach (var s in strings) { index.EnsureValue(s); } using (var stream = new MemoryStream()){ using (var sw = new BinaryWriter(stream, Encoding.UTF8, true)){ index.Write(sw); sw.Flush(); } index = new BTreeIndex <string, bool, bool>(10); stream.Position = 0; using (var sr = new BinaryReader(stream, Encoding.UTF8, true)) { index.Read(sr); } }; foreach (var s in strings) { Assert.NotNull(index.Find(s)); } }
public void CanStore() { var index = new BTreeIndex <string, bool, bool>(10); foreach (var s in strings) { index.EnsureValue(s); } Console.WriteLine(index.PlainIndex.Count); }
public void CanCountSearchCost() { var res = 0; Assert.DoesNotThrow(() => { var res = BTreeIndex.SearchCost(0, 0); }); Assert.AreEqual(0, res); }
public void CanRead() { var index = new BTreeIndex <string, bool, bool>(10); foreach (var s in strings) { index.EnsureValue(s); } foreach (var s in strings) { Assert.NotNull(index.Find(s)); } }
///------------------------------------------------------------------------------------------------- /// <summary> /// Constructor. /// </summary> /// <param name="graph"> /// The graph. /// </param> /// <param name="name"> /// The name. /// </param> /// <param name="metaClass"> /// The meta class. /// </param> /// <param name="unique"> /// true to unique. /// </param> /// <param name="propertyNames"> /// A list of names of the properties. /// </param> ///------------------------------------------------------------------------------------------------- public IndexDefinition(IHyperGraph graph, string name, ISchemaElement metaClass, bool unique, params string[] propertyNames) { DebugContract.Requires(graph); DebugContract.RequiresNotEmpty(name); DebugContract.Requires(metaClass); if (propertyNames.Length > 0) { PropertyNames = new string[propertyNames.Length]; for (var i = 0; i < propertyNames.Length; i++) { PropertyNames[i] = propertyNames[i]; } } MetaClass = metaClass; Index = new BTreeIndex(graph, name, unique); }
private void Write(BTreeIndex <string, bool, bool> index) { Console.WriteLine(); foreach (var b in index.PlainIndex.Values) { Console.WriteLine(b.Id); foreach (var value in b.Values) { Console.Write(value.ToString()); } Console.WriteLine(); Console.WriteLine("------------------------------------------"); } Console.WriteLine("==================================================="); }