Esempio n. 1
0
        private BinaryData EncodeSLBlock(SLEntry[] blockEntries)
        {
            var generator = BinaryDataGenerator.New();

            generator.Append((byte)0x02);
            generator.Append((byte)0x00);
            generator.Append((short)blockEntries.Length);
            generator.Append(BinaryData.OfSize(4));

            Array.ForEach(blockEntries, e => generator = generator.Append(e, slEntryEncoder));

            return(generator.GetData());
        }
Esempio n. 2
0
        private FPMap CreateFPMap(long mapOffset)
        {
            var data = BinaryData.OfSize(496, 0xFF);

            return
                (new FPMap(
                     data,
                     new PageTrailer(
                         Constants.ptypeFPMap,
                         Constants.ptypeFPMap,
                         0x0000,
                         (int)Crc32.ComputeCrc32(data.Value),
                         BID.OfValue(mapOffset))));
        }
Esempio n. 3
0
        public BID Allocate(IB blockOffset, int rawDataSize, bool internalBlock)
        {
            var bidIndex = headerUsageProvider.GetHeader().NextBID;

            headerUsageProvider.Use(header => header.IncrementBIDIndexForDataBlocks());

            var blockId = internalBlock ? BID.ForInternalBlock(bidIndex) : BID.ForExternalBlock(bidIndex);

            allocatedBlockBTreeEntries.Add(
                new LBBTEntry(
                    BREF.OfValue(blockId, blockOffset),
                    rawDataSize,
                    numberOfReferencesToThisBlock: 2,
                    padding: BinaryData.OfSize(4)));

            return(blockId);
        }
Esempio n. 4
0
        public InternalDataBlock Create(
            IB blockOffset,
            BID blockId,
            BlockIdsWithTotalNumberOfBytesInReferencedBlocks data)
        {
            var encodedExternalBlockIds = data.BlockIds.Encode(bidEncoder);

            return
                (new InternalDataBlock(
                     0x01,
                     blockLevel,
                     data.BlockIds.Length,
                     data.TotalNumberOfBytesInReferencedBlocks,
                     encodedExternalBlockIds,
                     BinaryData.OfSize(Utilities.GetInternalDataBlockPaddingSize(encodedExternalBlockIds.Length)),
                     new BlockTrailer(
                         encodedExternalBlockIds.Length + 8,
                         BlockSignature.Calculate(blockOffset, blockId),
                         Crc32.ComputeCrc32(GetDataToCalculateCrc32(encodedExternalBlockIds, data.BlockIds.Length, data.TotalNumberOfBytesInReferencedBlocks)),
                         blockId)));
        }