Exemplo n.º 1
0
 private static void WriteBaseHeader(PageCursor cursor, sbyte type, long stableGeneration, long unstableGeneration)
 {
     cursor.PutByte(BYTE_POS_NODE_TYPE, NODE_TYPE_TREE_NODE);
     cursor.PutByte(BytePosType, type);
     SetGeneration(cursor, unstableGeneration);
     SetKeyCount(cursor, 0);
     SetRightSibling(cursor, NO_NODE_FLAG, stableGeneration, unstableGeneration);
     SetLeftSibling(cursor, NO_NODE_FLAG, stableGeneration, unstableGeneration);
     SetSuccessor(cursor, NO_NODE_FLAG, stableGeneration, unstableGeneration);
 }
Exemplo n.º 2
0
        public override void Write(Record record, PageCursor cursor)
        {
            StandardRecord r = ( StandardRecord )record;

            sbyte[] pathBytes = r.File.Path.getBytes(StandardCharsets.UTF_8);
            sbyte   fileByte  = pathBytes[pathBytes.Length - 1];

            cursor.PutByte(r.Type);
            cursor.PutByte(fileByte);
            cursor.PutShort(r.Fill1);
            cursor.PutInt(r.RecordId);
            cursor.PutLong(r.Fill2);
        }
Exemplo n.º 3
0
            protected internal override void DoWriteInternal(MyRecord record, PageCursor cursor)
            {
                int intsPerRecord = ShortsPerRecord;

                for (int i = 0; i < intsPerRecord; i++)
                {
                    short v = record.Value;
                    sbyte a = ( sbyte )((v & 0x0000FF00) >> 8);
                    sbyte b = unchecked (( sbyte )(v & 0x000000FF));
                    cursor.PutByte(a);
                    cursor.PutByte(b);
                }
            }
Exemplo n.º 4
0
        public override void Write(DynamicRecord record, PageCursor cursor, int recordSize)
        {
            if (record.InUse())
            {
                long nextBlock = record.NextBlock;
                int  highByteInFirstInteger = nextBlock == Record.NO_NEXT_BLOCK.intValue() ? 0 : (int)((nextBlock & 0xF00000000L) >> 8);
                highByteInFirstInteger |= Record.IN_USE.byteValue() << 28;
                highByteInFirstInteger |= (record.StartRecord ? 0 : 1) << 31;

                /*
                 * First 4b
                 * [x   ,    ][    ,    ][    ,    ][    ,    ] 0: start record, 1: linked record
                 * [   x,    ][    ,    ][    ,    ][    ,    ] inUse
                 * [    ,xxxx][    ,    ][    ,    ][    ,    ] high next block bits
                 * [    ,    ][xxxx,xxxx][xxxx,xxxx][xxxx,xxxx] nr of bytes in the data field in this record
                 *
                 */
                int firstInteger = record.Length;
                Debug.Assert(firstInteger < (1 << 24) - 1);

                firstInteger |= highByteInFirstInteger;

                cursor.PutInt(firstInteger);
                cursor.PutInt(( int )nextBlock);
                cursor.PutBytes(record.Data);
            }
            else
            {
                cursor.PutByte(Record.NOT_IN_USE.byteValue());
            }
        }
 public override void WriteHeader(PageCursor cursor)
 {
     for (int i = 0; i < RecordHeaderSize; i++)
     {
         cursor.PutByte(( sbyte )ThreadLocalRandom.current().Next());
     }
 }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 7
0
 public override void Write(DynamicRecord record, PageCursor cursor, int recordSize)
 {
     if (record.InUse())
     {
         Debug.Assert(record.Length < (1 << 24) - 1);
         sbyte headerByte = ( sbyte )((record.InUse() ? IN_USE_BIT : 0) | (record.StartRecord ? START_RECORD_BIT : 0));
         cursor.PutByte(headerByte);
         cursor.PutShort(( short )record.Length);
         cursor.PutByte(( sbyte )(( int )(( uint )record.Length >> 16)));
         cursor.PutLong(record.NextBlock);
         cursor.PutBytes(record.Data);
     }
     else
     {
         MarkAsUnused(cursor);
     }
 }
Exemplo n.º 8
0
        public override int CopyTo(int sourceOffset, PageCursor targetCursor, int targetOffset, int lengthInBytes)
        {
            if (sourceOffset < 0 || targetOffset < 0 || lengthInBytes < 0)
            {
                throw new System.ArgumentException(format("sourceOffset=%d, targetOffset=%d, lengthInBytes=%d, currentPageId=%d", sourceOffset, targetOffset, lengthInBytes, _currentPageId));
            }
            int bytesToCopy = Math.Min(lengthInBytes, Math.Min(_current.CurrentPageSize - sourceOffset, targetCursor.CurrentPageSize - targetOffset));

            for (int i = 0; i < bytesToCopy; i++)
            {
                targetCursor.PutByte(targetOffset + i, GetByte(sourceOffset + i));
            }
            return(bytesToCopy);
        }
Exemplo n.º 9
0
        public override void SetByte(long index, int offset, sbyte value)
        {
            long pageId = pageId(index);

            offset += offset(index);
            try
            {
                using (PageCursor cursor = PagedFile.io(pageId, PF_SHARED_WRITE_LOCK | PF_NO_GROW))
                {
                    cursor.Next();
                    cursor.PutByte(offset, value);
                    CheckBounds(cursor);
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustFinishInitialisationOfIncompleteStoreHeader() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustFinishInitialisationOfIncompleteStoreHeader()
        {
            CreateStore();
            int headerSizeInRecords = _store.NumberOfReservedLowIds;
            int headerSizeInBytes   = headerSizeInRecords * _store.RecordSize;

            using (PageCursor cursor = _store.pagedFile.io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PfSharedWriteLock))
            {
                assertTrue(cursor.Next());
                for (int i = 0; i < headerSizeInBytes; i++)
                {
                    cursor.PutByte(( sbyte )0);
                }
            }
            int pageSize = _store.pagedFile.pageSize();

            _store.close();
            _store.pageCache.map(_store.StorageFile, pageSize, StandardOpenOption.TRUNCATE_EXISTING).close();
            CreateStore();
        }
Exemplo n.º 11
0
        public override void Set3ByteInt(long index, int offset, int value)
        {
            long pageId = pageId(index);

            offset += offset(index);
            try
            {
                using (PageCursor cursor = PagedFile.io(pageId, PF_SHARED_WRITE_LOCK | PF_NO_GROW))
                {
                    cursor.Next();
                    cursor.PutShort(offset, ( short )value);
                    cursor.PutByte(offset + Short.BYTES, ( sbyte )(( int )(( uint )value >> (sizeof(short) * 8))));
                    CheckBounds(cursor);
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
Exemplo n.º 12
0
        public override void Set(long index, sbyte[] value)
        {
            Debug.Assert(value.Length == EntrySize);
            long pageId = pageId(index);
            int  offset = offset(index);

            try
            {
                using (PageCursor cursor = PagedFile.io(pageId, PF_SHARED_WRITE_LOCK | PF_NO_GROW))
                {
                    cursor.Next();
                    for (int i = 0; i < value.Length; i++)
                    {
                        cursor.PutByte(offset + i, value[i]);
                    }
                    CheckBounds(cursor);
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
Exemplo n.º 13
0
 public override void Write(MetaDataRecord record, PageCursor cursor, int recordSize)
 {
     Debug.Assert(record.InUse());
     cursor.PutByte(Record.IN_USE.byteValue());
     cursor.PutLong(record.Value);
 }
Exemplo n.º 14
0
 internal virtual void PutInternal(PageCursor cursor)
 {
     cursor.PutByte(TypeConflict.typeId);
     TypeConflict.putValue(cursor, this);
 }
Exemplo n.º 15
0
 private static void Put3BInt(PageCursor cursor, int value)
 {
     cursor.PutShort(( short )value);
     cursor.PutByte(( sbyte )(( int )(( uint )value >> (sizeof(short) * 8))));
 }
Exemplo n.º 16
0
 internal override void PutValue(PageCursor cursor, GenericKey state)
 {
     cursor.PutByte(( sbyte )state.Long1);
     PutArray(cursor, state, NumberArrayElementWriter(state));
 }