예제 #1
0
        public override void Get(long index, sbyte[] into)
        {
            long pageId = pageId(index);
            int  offset = offset(index);

            try
            {
                using (PageCursor cursor = PagedFile.io(pageId, PF_SHARED_READ_LOCK))
                {
                    cursor.Next();
                    do
                    {
                        for (int i = 0; i < into.Length; i++)
                        {
                            into[i] = cursor.GetByte(offset + i);
                        }
                    } while (cursor.ShouldRetry());
                    CheckBounds(cursor);
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
예제 #2
0
        public override void Swap(long fromIndex, long toIndex)
        {
            long fromPageId = PageId(fromIndex);
            int  fromOffset = Offset(fromIndex);
            long toPageId   = PageId(toIndex);
            int  toOffset   = Offset(toIndex);

            try
            {
                using (PageCursor fromCursor = PagedFile.io(fromPageId, PF_SHARED_WRITE_LOCK), PageCursor toCursor = PagedFile.io(toPageId, PF_SHARED_WRITE_LOCK))
                {
                    fromCursor.Next();
                    toCursor.Next();
                    for (int i = 0; i < EntrySize; i++, fromOffset++, toOffset++)
                    {
                        sbyte intermediary = fromCursor.GetByte(fromOffset);
                        fromCursor.PutByte(fromOffset, toCursor.GetByte(toOffset));
                        toCursor.PutByte(toOffset, intermediary);
                    }
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
예제 #3
0
        public override int Get3ByteInt(long index, int offset)
        {
            long pageId = pageId(index);

            offset += offset(index);
            try
            {
                using (PageCursor cursor = PagedFile.io(pageId, PF_SHARED_READ_LOCK))
                {
                    cursor.Next();
                    int result;
                    do
                    {
                        int lowWord  = cursor.GetShort(offset) & 0xFFFF;
                        int highByte = cursor.GetByte(offset + Short.BYTES) & 0xFF;
                        result = lowWord | (highByte << (sizeof(short) * 8));
                    } while (cursor.ShouldRetry());
                    CheckBounds(cursor);
                    return(result == 0xFFFFFF ? -1 : result);
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
예제 #4
0
        public override long Get5ByteLong(long index, int offset)
        {
            long pageId = pageId(index);

            offset += offset(index);
            try
            {
                using (PageCursor cursor = PagedFile.io(pageId, PF_SHARED_READ_LOCK))
                {
                    cursor.Next();
                    long result;
                    do
                    {
                        long low4b  = cursor.GetInt(offset) & 0xFFFFFFFFL;
                        long high1b = cursor.GetByte(offset + Integer.BYTES) & 0xFF;
                        result = low4b | (high1b << (sizeof(int) * 8));
                    } while (cursor.ShouldRetry());
                    CheckBounds(cursor);
                    return(result == 0xFFFFFFFFFFL ? -1 : result);
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
예제 #5
0
        public override sbyte GetByte(long index, int offset)
        {
            long pageId = pageId(index);

            offset += offset(index);
            try
            {
                using (PageCursor cursor = PagedFile.io(pageId, PF_SHARED_READ_LOCK))
                {
                    cursor.Next();
                    sbyte result;
                    do
                    {
                        result = cursor.GetByte(offset);
                    } while (cursor.ShouldRetry());
                    CheckBounds(cursor);
                    return(result);
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
예제 #6
0
 internal static sbyte NodeType(PageCursor cursor)
 {
     return(cursor.GetByte(BYTE_POS_NODE_TYPE));
 }
예제 #7
0
        // HEADER METHODS

        internal static sbyte TreeNodeType(PageCursor cursor)
        {
            return(cursor.GetByte(BytePosType));
        }