user135962: I am trying to parse out the bitcoin data using Big Data and wanted to know more about the blk files themselves. I was wondering how does bitcoin split the transactions across the files. I know there is a 128 MiB limit on the files. Does that mean it is possible for transaction data to be split across a blk ? For instance the merkle root of the transaction is in one file and the output index is in another ? Or is block data retained in a single file ?

user208: Blocks are never split across files: the whole block, from magic to length, to header, to transaction data, is always stored in a single file, continuously.
However you may need to take into account:

Blocks in the blk*.dat files are stored in the order they are received from the network.l, which may not be the blocks' logical order.
It is possible that a block is in file N, and its descendant block is in file N-1.
The files contain all blocks ever received, including ones that are not part of the main chain but were reorged out.
There can be "gaps" of zeroes or garbage data between blocks in the blk*.dat files.


135962: <p>I am trying to parse out the bitcoin data using Big Data and wanted to know more about the blk files themselves. I was wondering how does bitcoin split the transactions across the files. I know there is a 128 MiB limit on the files. Does that mean it is possible for transaction data to be split across a blk ? For instance the merkle root of the transaction is in one file and the output index is in another ? Or is block data retained in a single file ?</p>
 208: <p>Blocks are never split across files: the whole block, from magic to length, to header, to transaction data, is always stored in a single file, continuously.</p>
<p>However you may need to take into account:</p>
<ul>
<li>Blocks in the blk*.dat files are stored in the order they are received from the network.l, which may not be the blocks' logical order.</li>
<li>It is possible that a block is in file N, and its descendant block is in file N-1.</li>
<li>The files contain all blocks ever received, including ones that are not part of the main chain but were reorged out.</li>
<li>There can be &quot;gaps&quot; of zeroes or garbage data between blocks in the blk*.dat files.</li>
</ul>
