anchor.diff:  
     ok = file:write(File, ChunkMap),
     {ok, Size}.
  +
  +read_chunk_map(#dbstate{} = State) ->
  +  ChunkMap = lists:map(fun({_Number, Offset}) ->
  +        {md, Timestamp, _Bid, _Ask} = read_full_md_at_offset(Offset, State),
  +        {Timestamp, Offset}
  +    end, nonzero_chunks(State)),
  +  State#dbstate{chunk_map = ChunkMap}.
   
   
   nonzero_chunks(#dbstate{file = File, chunk_size = ChunkSize, chunk_map_offset = ChunkMapOffset}) ->
  
positive.code:   lists:reverse(ReversedResult).
  
  
  start_chunk(Timestamp, #dbstate{daystart = undefined, date = Date} = State) ->
    DaystartSeconds = calendar:datetime_to_gregorian_seconds({Date, {0,0,0}}) - calendar:datetime_to_gregorian_seconds({{1970,1,1}, {0,0,0}}),
    Daystart = DaystartSeconds * 1000,
    ?D({daystart, Daystart}),
    start_chunk(Timestamp, State#dbstate{daystart = Daystart});
  
  start_chunk(Timestamp, State) ->
    #dbstate{
  
negative.code:   end, List1, List2).
  
  
  fast_forward(#dbstate{file = File, chunk_map_offset = ChunkMapOffset, chunk_map = ChunkMap} = State) ->
    {_Timestamp, LastChunkOffset} = lists:last(ChunkMap),
    AbsOffset = ChunkMapOffset + LastChunkOffset,
    {ok, FileSize} = file:position(File, eof),
  
    {ok, Buffer} = file:pread(File, {bof, AbsOffset}, FileSize - AbsOffset),
    {_Packets, LastState} = read_buffered_events(State#dbstate{buffer = Buffer}),
  
    LastState.
  
  
  read_full_md_at_offset(Offset, #dbstate{file = File, chunk_map_offset = ChunkMapOffset, depth = Depth} = State) ->
    PacketLen = 8 + 2 * 2 * 4 * Depth, % Timestamp 64 bit + (bid, ask) * (price, volume) * 32 bit * depth
    {ok, Buffer} = file:pread(File, {bof, ChunkMapOffset + Offset}, PacketLen),
  
    {Timestamp, BidAsk, _Tail} = stockdb_format:decode_full_md(Buffer, State#dbstate.depth),
    packet_from_mdentry(Timestamp, BidAsk, State).
  
  
  read_buffered_events(State) ->
    read_buffered_events(State, []).
  
  