Example #1
0
        private unsafe void BeginMainIndexRecovery(
            int version,
            IDevice device,
            ulong num_bytes,
            bool isAsync = false)
        {
            long totalSize = state[version].size * sizeof(HashBucket);

            int numChunks = 1;

            if (totalSize > uint.MaxValue)
            {
                numChunks = (int)Math.Ceiling((double)totalSize / (long)uint.MaxValue);
                numChunks = (int)Math.Pow(2, Math.Ceiling(Math.Log(numChunks, 2)));
            }

            uint chunkSize = (uint)(totalSize / numChunks);

            recoveryCountdown = new CountdownWrapper(numChunks, isAsync);
            HashBucket *start = state[version].tableAligned;

            ulong numBytesRead = 0;

            for (int index = 0; index < numChunks; index++)
            {
                IntPtr chunkStartBucket             = (IntPtr)(((byte *)start) + (index * chunkSize));
                HashIndexPageAsyncReadResult result = default;
                result.chunkIndex = index;
                device.ReadAsync(numBytesRead, chunkStartBucket, chunkSize, AsyncPageReadCallback, result);
                numBytesRead += chunkSize;
            }
            Debug.Assert(numBytesRead == num_bytes);
        }
Example #2
0
        private void BeginMainIndexRecovery(
            int version,
            IDevice device,
            ulong num_bytes)
        {
            int  numChunksToBeRecovered = 1;
            long totalSize = state[version].size * sizeof(HashBucket);

            Debug.Assert(totalSize < (long)uint.MaxValue); // required since numChunks = 1

            uint chunkSize = (uint)(totalSize / numChunksToBeRecovered);

            mainIndexRecoveryEvent = new CountdownEvent(numChunksToBeRecovered);
            HashBucket *start = state[version].tableAligned;

            ulong numBytesRead = 0;

            for (int index = 0; index < numChunksToBeRecovered; index++)
            {
                long chunkStartBucket = (long)start + (index * chunkSize);
                HashIndexPageAsyncReadResult result = default(HashIndexPageAsyncReadResult);
                result.chunkIndex = index;
                device.ReadAsync(numBytesRead, (IntPtr)chunkStartBucket, chunkSize, AsyncPageReadCallback, result);
                numBytesRead += chunkSize;
            }
            Debug.Assert(numBytesRead == num_bytes);
        }
Example #3
0
        private void _BeginMainIndexRecovery(
            int version,
            IDevice device,
            ulong num_bytes)
        {
            numChunksToBeRecovered = 1;                       // Constants.kNumMergeChunks;
            long        chunkSize  = state[version].size / 1; // Constants.kNumMergeChunks;
            HashBucket *start      = state[version].tableAligned;
            uint        sizeOfPage = (uint)chunkSize * (uint)sizeof(HashBucket);

            uint num_bytes_read = 0;

            for (int index = 0; index < 1 /*Constants.kNumMergeChunks*/; index++)
            {
                HashBucket *chunkStartBucket        = start + (index * chunkSize);
                HashIndexPageAsyncReadResult result = default(HashIndexPageAsyncReadResult);
                result.chunkIndex = index;
                device.ReadAsync(num_bytes_read, (IntPtr)chunkStartBucket, sizeOfPage, AsyncPageReadCallback, result);
                num_bytes_read += sizeOfPage;
            }
            Debug.Assert(num_bytes_read == num_bytes);
        }