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)); } }
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; } }
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(DynamicRecord record, PageCursor cursor, RecordLoad mode, int recordSize) { /* * 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 * */ long firstInteger = cursor.Int & 0xFFFFFFFFL; bool isStartRecord = (firstInteger & 0x80000000) == 0; bool inUse = (firstInteger & 0x10000000) != 0; if (mode.shouldLoad(inUse)) { int dataSize = recordSize - RecordHeaderSize; int nrOfBytes = ( int )(firstInteger & 0xFFFFFF); if (nrOfBytes > recordSize) { // We must have performed an inconsistent read, // because this many bytes cannot possibly fit in a record! cursor.CursorException = PayloadTooBigErrorMessage(record, recordSize, nrOfBytes); return; } /* * Pointer to next block 4b (low bits of the pointer) */ long nextBlock = cursor.Int & 0xFFFFFFFFL; long nextModifier = (firstInteger & 0xF000000L) << 8; long longNextBlock = BaseRecordFormat.longFromIntAndMod(nextBlock, nextModifier); record.Initialize(inUse, isStartRecord, longNextBlock, -1, nrOfBytes); if (longNextBlock != Record.NO_NEXT_BLOCK.intValue() && nrOfBytes < dataSize || nrOfBytes > dataSize) { cursor.CursorException = IllegalBlockSizeMessage(record, dataSize); return; } ReadData(record, cursor); } else { record.InUse = inUse; } }
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); } } }