Mongo::GridIO#seek broken after #read_all (or: GridIO#read_all breaks all future operations?)

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 1.1.5
    • Affects Version/s: 1.1.4
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      As of the Ruby mongo-1.1.4 gem, GridIO#read_all is defined as:

      1. Read a file in its entirety.
        def read_all
        buf = ''
        while true
        buf << @current_chunk['data'].to_s
        @current_chunk = get_chunk(@current_chunk['n'] + 1)
        break unless @current_chunk
        end
        buf
        end

      The shortcut of setting @current_chunk = get_chunk(next_n) has a side effect of breaking anything that depends on @current_chunk. read_length handles this properly, though it may be a few more instructions than is required when doing a read_all.

      WORKAROUND:
      Using GridIO#read_length(file_length_or_remaining_length) doesn't break further seeks, etc.

            Assignee:
            Kyle Banker (Inactive)
            Reporter:
            Doug Mayer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: