示例#1
0
        public int BlocksAccessed()
        {
            var recordsPerBlock = _blockSize / _tableInfo.RecordLength;
            int blocksCount     = _statInfo.RecordsOutput / recordsPerBlock;

            return(BTreeIndex.SearchCost(blocksCount, recordsPerBlock));
        }
示例#2
0
 public void CanCreateBTreeIndex()
 {
     Assert.DoesNotThrow(() =>
     {
         index = new BTreeIndex("id", schema, transaction);
     });
 }
示例#3
0
        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));
            }
        }
示例#4
0
        public void CanStore()
        {
            var index = new BTreeIndex <string, bool, bool>(10);

            foreach (var s in strings)
            {
                index.EnsureValue(s);
            }
            Console.WriteLine(index.PlainIndex.Count);
        }
示例#5
0
        public void CanCountSearchCost()
        {
            var res = 0;

            Assert.DoesNotThrow(() =>
            {
                var res = BTreeIndex.SearchCost(0, 0);
            });

            Assert.AreEqual(0, res);
        }
示例#6
0
        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));
            }
        }
示例#7
0
        ///-------------------------------------------------------------------------------------------------
        /// <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);
        }
示例#8
0
        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("===================================================");
        }