Exemple #1
0
        public void JetPrereadKeys()
        {
            if (!EsentVersion.SupportsWindows7Features)
            {
                return;
            }

            // We need enough records to force a vertical split. ESENT returns
            // 0 for keysPreread when we have a single-level tree.
            const int NumRecords = 128;

            byte[][] keys       = new byte[NumRecords][];
            int[]    keyLengths = new int[NumRecords];

            Api.JetBeginTransaction(this.sesid);

            // This table uses a sequential index so the records will
            // be in key order.
            for (int i = 0; i < NumRecords; ++i)
            {
                Api.JetPrepareUpdate(this.sesid, this.tableid, JET_prep.Insert);
                this.SetColumnFromString(Any.StringOfLength(255));
                this.UpdateAndGotoBookmark();

                keys[i]       = Api.RetrieveKey(this.sesid, this.tableid, RetrieveKeyGrbit.None);
                keyLengths[i] = keys[i].Length;
            }

            Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.None);

            int keysPreread;

            Windows7Api.JetPrereadKeys(this.sesid, this.tableid, keys, keyLengths, NumRecords, out keysPreread, PrereadKeysGrbit.Forward);
            Assert.AreNotEqual(0, keysPreread, "No keys were preread?!");
        }
        public void JetPrereadKeys()
        {
            if (!EsentVersion.SupportsWindows7Features)
            {
                return;
            }

            // We need enough records to force a vertical split. ESENT returns
            // 0 for keysPreread when we have a single-level tree.
            const int NumRecords = 1024;

            byte[][] keys       = new byte[NumRecords][];
            int[]    keyLengths = new int[NumRecords];

            // Setting a fixed cache size improves reliability of this test case because,
            // due to optimization reasons, we may drop pre-reads with a small cache size.
            // But first, we'll set the cache to a very small value and only grow it later
            // so that we know for sure we'll have available buffers.
            int cacheSizeMinOriginal = SystemParameters.CacheSizeMin;
            int cacheSizeMaxOriginal = SystemParameters.CacheSizeMax;

            SystemParameters.CacheSizeMin = 128;
            SystemParameters.CacheSizeMax = 128;

            try
            {
                Api.JetBeginTransaction(this.sesid);

                // This table uses a sequential index so the records will
                // be in key order.
                for (int i = 0; i < NumRecords; ++i)
                {
                    Api.JetPrepareUpdate(this.sesid, this.tableid, JET_prep.Insert);
                    this.SetColumnFromString(Any.StringOfLength(1024));
                    this.UpdateAndGotoBookmark();

                    keys[i]       = Api.RetrieveKey(this.sesid, this.tableid, RetrieveKeyGrbit.None);
                    keyLengths[i] = keys[i].Length;
                }

                Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.None);

                SystemParameters.CacheSizeMin = 1024;
                SystemParameters.CacheSizeMax = 1024;

                int keysPreread;
                Windows7Api.JetPrereadKeys(this.sesid, this.tableid, keys, keyLengths, NumRecords, out keysPreread, PrereadKeysGrbit.Forward);
                Assert.AreNotEqual(0, keysPreread, "No keys were preread?!");
            }
            finally
            {
                SystemParameters.CacheSizeMin = cacheSizeMinOriginal;
                SystemParameters.CacheSizeMax = cacheSizeMaxOriginal;
            }
        }
Exemple #3
0
        private void PrereadKeys()
        {
            Console.WriteLine("\tPrereadKeys");
            JET_TABLEID tableid;

            Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out tableid);

            var keys = new byte[4][];

            for (int i = 0; i < keys.Length; ++i)
            {
                Api.MakeKey(this.sesid, tableid, i, MakeKeyGrbit.NewKey);
                keys[i] = Api.RetrieveKey(this.sesid, tableid, RetrieveKeyGrbit.RetrieveCopy);
            }

            int[] keyLengths = (from x in keys select x.Length).ToArray();

            int ignored;

            Windows7Api.JetPrereadKeys(
                this.sesid, tableid, keys, keyLengths, keys.Length, out ignored, PrereadKeysGrbit.Forward);

            Api.JetCloseTable(this.sesid, tableid);
        }
        public void VerifyXpThrowsExceptionOnJetPrereadKeys()
        {
            int ignored;

            Windows7Api.JetPrereadKeys(JET_SESID.Nil, JET_TABLEID.Nil, null, null, 0, out ignored, PrereadKeysGrbit.Forward);
        }