public override void Read(RelationshipGroupRecord record, PageCursor cursor, RecordLoad mode, int recordSize)
        {
            // [    ,   x] in use
            // [    ,xxx ] high next id bits
            // [ xxx,    ] high firstOut bits
            long headerByte = cursor.Byte;
            bool inUse      = isInUse(( sbyte )headerByte);

            record.InUse = inUse;
            if (mode.shouldLoad(inUse))
            {
                // [    ,xxx ] high firstIn bits
                // [ xxx,    ] high firstLoop bits
                long highByte = cursor.Byte;

                int  type            = cursor.Short & 0xFFFF;
                long nextLowBits     = cursor.Int & 0xFFFFFFFFL;
                long nextOutLowBits  = cursor.Int & 0xFFFFFFFFL;
                long nextInLowBits   = cursor.Int & 0xFFFFFFFFL;
                long nextLoopLowBits = cursor.Int & 0xFFFFFFFFL;
                long owningNode      = (cursor.Int & 0xFFFFFFFFL) | ((( long )cursor.Byte) << 32);

                long nextMod     = (headerByte & 0xE) << 31;
                long nextOutMod  = (headerByte & 0x70) << 28;
                long nextInMod   = (highByte & 0xE) << 31;
                long nextLoopMod = (highByte & 0x70) << 28;

                record.Initialize(inUse, type, BaseRecordFormat.longFromIntAndMod(nextOutLowBits, nextOutMod), BaseRecordFormat.longFromIntAndMod(nextInLowBits, nextInMod), BaseRecordFormat.longFromIntAndMod(nextLoopLowBits, nextLoopMod), owningNode, BaseRecordFormat.longFromIntAndMod(nextLowBits, nextMod));
            }
        }
Exemple #2
0
        public override void Read(NodeRecord record, PageCursor cursor, RecordLoad mode, int recordSize)
        {
            sbyte headerByte = cursor.Byte;
            bool  inUse      = IsInUse(headerByte);

            record.InUse = inUse;
            if (mode.shouldLoad(inUse))
            {
                long nextRel  = cursor.Int & 0xFFFFFFFFL;
                long nextProp = cursor.Int & 0xFFFFFFFFL;

                long relModifier  = (headerByte & 0xEL) << 31;
                long propModifier = (headerByte & 0xF0L) << 28;

                long  lsbLabels = cursor.Int & 0xFFFFFFFFL;
                long  hsbLabels = cursor.Byte & 0xFF;                        // so that a negative byte won't fill the "extended" bits with ones.
                long  labels    = lsbLabels | (hsbLabels << 32);
                sbyte extra     = cursor.Byte;
                bool  dense     = (extra & 0x1) > 0;

                record.Initialize(inUse, BaseRecordFormat.longFromIntAndMod(nextProp, propModifier), dense, BaseRecordFormat.longFromIntAndMod(nextRel, relModifier), labels);
            }
            else
            {
                int nextOffset = cursor.Offset + recordSize - HEADER_SIZE;
                cursor.Offset = nextOffset;
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void getRecordByCursor(long id, org.neo4j.kernel.impl.store.record.NodeRecord target, org.neo4j.kernel.impl.store.record.RecordLoad mode, org.neo4j.io.pagecache.PageCursor cursor) throws org.neo4j.kernel.impl.store.InvalidRecordException
            public override void getRecordByCursor(long id, NodeRecord target, RecordLoad mode, PageCursor cursor)
            {
                if (id == 3)
                {
                    _processor.stop();
                }
                base.getRecordByCursor(id, target, mode, cursor);
            }
Exemple #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void read(RECORD record, org.neo4j.io.pagecache.PageCursor primaryCursor, org.neo4j.kernel.impl.store.record.RecordLoad mode, int recordSize) throws java.io.IOException
        public override void Read(RECORD record, PageCursor primaryCursor, RecordLoad mode, int recordSize)
        {
            int   primaryStartOffset = primaryCursor.Offset;
            sbyte headerByte         = primaryCursor.Byte;
            bool  inUse            = isInUse(headerByte);
            bool  doubleRecordUnit = has(headerByte, HeaderBitRecordUnit);

            record.UseFixedReferences = false;
            if (doubleRecordUnit)
            {
                bool firstRecordUnit = has(headerByte, HeaderBitFirstRecordUnit);
                if (!firstRecordUnit)
                {
                    // This is a record unit and not even the first one, so you cannot go here directly and read it,
                    // it may only be read as part of reading the primary unit.
                    record.clear();
                    // Return and try again
                    primaryCursor.CursorException = "Expected record to be the first unit in the chain, but record header says it's not";
                    return;
                }

                // This is a record that is split into multiple record units. We need a bit more clever
                // data structures here. For the time being this means instantiating one object,
                // but the trade-off is a great reduction in complexity.
                long       secondaryId     = Reference.decode(primaryCursor);
                long       pageId          = pageIdForRecord(secondaryId, primaryCursor.CurrentPageSize, recordSize);
                int        offset          = offsetForId(secondaryId, primaryCursor.CurrentPageSize, recordSize);
                PageCursor secondaryCursor = primaryCursor.OpenLinkedCursor(pageId);
                if ((!secondaryCursor.Next()) | offset < 0)
                {
                    // We must have made an inconsistent read of the secondary record unit reference.
                    // No point in trying to read this.
                    record.clear();
                    primaryCursor.CursorException = IllegalSecondaryReferenceMessage(pageId);
                    return;
                }
                secondaryCursor.Offset = offset + HeaderByte;
                int primarySize = recordSize - (primaryCursor.Offset - primaryStartOffset);
                // We *could* sanity check the secondary record header byte here, but we won't. If it is wrong, then we most
                // likely did an inconsistent read, in which case we'll just retry. Otherwise, if the header byte is wrong,
                // then there is little we can do about it here, since we are not allowed to throw exceptions.

                int        secondarySize = recordSize - HeaderByte;
                PageCursor composite     = CompositePageCursor.compose(primaryCursor, primarySize, secondaryCursor, secondarySize);
                DoReadInternal(record, composite, recordSize, headerByte, inUse);
                record.SecondaryUnitId = secondaryId;
            }
            else
            {
                record.UseFixedReferences = IsUseFixedReferences(headerByte);
                DoReadInternal(record, primaryCursor, recordSize, headerByte, inUse);
            }

            // Set cursor offset to next record to prepare next read in case of scanning.
            primaryCursor.Offset = primaryStartOffset + recordSize;
        }
Exemple #5
0
        public override void Read(RECORD record, PageCursor cursor, RecordLoad mode, int recordSize)
        {
            sbyte inUseByte = cursor.Byte;
            bool  inUse     = isInUse(inUseByte);

            record.InUse = inUse;
            if (mode.shouldLoad(inUse))
            {
                ReadRecordData(cursor, record, inUse);
            }
        }
        public override void Read(RelationshipRecord record, PageCursor cursor, RecordLoad mode, int recordSize)
        {
            sbyte headerByte = cursor.Byte;
            bool  inUse      = IsInUse(headerByte);

            record.InUse = inUse;
            if (mode.shouldLoad(inUse))
            {
                // [    ,   x] in use flag
                // [    ,xxx ] first node high order bits
                // [xxxx,    ] next prop high order bits
                long firstNode    = cursor.Int & 0xFFFFFFFFL;
                long firstNodeMod = (headerByte & 0xEL) << 31;

                long secondNode = cursor.Int & 0xFFFFFFFFL;

                // [ xxx,    ][    ,    ][    ,    ][    ,    ] second node high order bits,     0x70000000
                // [    ,xxx ][    ,    ][    ,    ][    ,    ] first prev rel high order bits,  0xE000000
                // [    ,   x][xx  ,    ][    ,    ][    ,    ] first next rel high order bits,  0x1C00000
                // [    ,    ][  xx,x   ][    ,    ][    ,    ] second prev rel high order bits, 0x380000
                // [    ,    ][    , xxx][    ,    ][    ,    ] second next rel high order bits, 0x70000
                // [    ,    ][    ,    ][xxxx,xxxx][xxxx,xxxx] type
                long typeInt       = cursor.Int;
                long secondNodeMod = (typeInt & 0x70000000L) << 4;
                int  type          = ( int )(typeInt & 0xFFFF);

                long firstPrevRel    = cursor.Int & 0xFFFFFFFFL;
                long firstPrevRelMod = (typeInt & 0xE000000L) << 7;

                long firstNextRel    = cursor.Int & 0xFFFFFFFFL;
                long firstNextRelMod = (typeInt & 0x1C00000L) << 10;

                long secondPrevRel    = cursor.Int & 0xFFFFFFFFL;
                long secondPrevRelMod = (typeInt & 0x380000L) << 13;

                long secondNextRel    = cursor.Int & 0xFFFFFFFFL;
                long secondNextRelMod = (typeInt & 0x70000L) << 16;

                long nextProp    = cursor.Int & 0xFFFFFFFFL;
                long nextPropMod = (headerByte & 0xF0L) << 28;

                sbyte extraByte = cursor.Byte;

                record.Initialize(inUse, BaseRecordFormat.longFromIntAndMod(nextProp, nextPropMod), BaseRecordFormat.longFromIntAndMod(firstNode, firstNodeMod), BaseRecordFormat.longFromIntAndMod(secondNode, secondNodeMod), type, BaseRecordFormat.longFromIntAndMod(firstPrevRel, firstPrevRelMod), BaseRecordFormat.longFromIntAndMod(firstNextRel, firstNextRelMod), BaseRecordFormat.longFromIntAndMod(secondPrevRel, secondPrevRelMod), BaseRecordFormat.longFromIntAndMod(secondNextRel, secondNextRelMod), (extraByte & 0x1) != 0, (extraByte & 0x2) != 0);
            }
            else
            {
                int nextOffset = cursor.Offset + recordSize - HEADER_SIZE;
                cursor.Offset = nextOffset;
            }
        }
        public override void Read(PropertyRecord record, PageCursor cursor, RecordLoad mode, int recordSize)
        {
            int offsetAtBeginning = cursor.Offset;

            /*
             * [pppp,nnnn] previous, next high bits
             */
            sbyte modifiers = cursor.Byte;
            long  prevMod   = (modifiers & 0xF0L) << 28;
            long  nextMod   = (modifiers & 0x0FL) << 32;
            long  prevProp  = cursor.Int & 0xFFFFFFFFL;
            long  nextProp  = cursor.Int & 0xFFFFFFFFL;

            record.Initialize(false, BaseRecordFormat.longFromIntAndMod(prevProp, prevMod), BaseRecordFormat.longFromIntAndMod(nextProp, nextMod));
            while (cursor.Offset - offsetAtBeginning < RecordSize)
            {
                long         block = cursor.Long;
                PropertyType type  = PropertyType.getPropertyTypeOrNull(block);
                if (type == null)
                {
                    // We assume that storage is defragged
                    break;
                }

                record.InUse = true;
                record.AddLoadedBlock(block);
                int numberOfBlocksUsed = type.calculateNumberOfBlocksUsed(block);
                if (numberOfBlocksUsed == PropertyType.BLOCKS_USED_FOR_BAD_TYPE_OR_ENCODING)
                {
                    cursor.CursorException = "Invalid type or encoding of property block: " + block + " (type = " + type + ")";
                    return;
                }
                int additionalBlocks = numberOfBlocksUsed - 1;
                if (additionalBlocks * Long.BYTES > RecordSize - (cursor.Offset - offsetAtBeginning))
                {
                    cursor.CursorException = "PropertyRecord claims to have more property blocks than can fit in a record";
                    return;
                }
                while (additionalBlocks-- > 0)
                {
                    record.AddLoadedBlock(cursor.Long);
                }
            }
        }
Exemple #8
0
        public override void Read(PropertyRecord record, PageCursor cursor, RecordLoad mode, int recordSize)
        {
            int   offset     = cursor.Offset;
            sbyte headerByte = cursor.Byte;
            bool  inUse      = IsInUse(headerByte);

            if (mode.shouldLoad(inUse))
            {
                int  blockCount = ( int )(( uint )headerByte >> 4);
                long recordId   = record.Id;
                record.Initialize(inUse, toAbsolute(Reference.decode(cursor), recordId), toAbsolute(Reference.decode(cursor), recordId));
                if ((blockCount > record.BlockCapacity) | (RECORD_SIZE - (cursor.Offset - offset) < blockCount * Long.BYTES))
                {
                    cursor.CursorException = "PropertyRecord claims to contain more blocks than can fit in a record";
                    return;
                }
                while (blockCount-- > 0)
                {
                    record.AddLoadedBlock(cursor.Long);
                }
            }
        }
Exemple #9
0
 public override RECORD GetRecord(long id, RECORD record, RecordLoad load)
 {
     AccessStatsConflict.upRead(id);
     return(base.GetRecord(id, record, load));
 }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void read(RECORD record, org.neo4j.io.pagecache.PageCursor cursor, org.neo4j.kernel.impl.store.record.RecordLoad mode, int recordSize) throws java.io.IOException
        public override void Read(RECORD record, PageCursor cursor, RecordLoad mode, int recordSize)
        {
            _actual.read(record, cursor, mode, recordSize);
        }
Exemple #11
0
 public override void Read(RECORD record, PageCursor cursor, RecordLoad mode, int recordSize)
 {
     record.clear();
 }
Exemple #12
0
 public abstract void Read(RECORD record, PageCursor cursor, Org.Neo4j.Kernel.impl.store.record.RecordLoad mode, int recordSize);