code: def test_varbytes_offsets():
      values = u(
          "alfa bravo charlie delta echo foxtrot golf hotel"
      ).split()
      vlen = len(values)
  
      # Without offsets:
      col = columns.VarBytesColumn(allow_offsets=False)
      schema = fields.Schema(name=fields.ID(sortable=col))
      with TempIndex(schema) as ix:
          with ix.writer() as w:
              for i in xrange(5000):
                  w.add_document(name=values[i % vlen])
  
          with ix.reader() as r:
              cr = r.column_reader("name")
              assert isinstance(cr, columns.TranslatingColumnReader)
              assert not cr.raw_column().had_stored_offsets
              for i in (10, 100, 1000, 3000):
                  assert cr[i] == values[i % vlen]
  
      # With offsets
      col = columns.VarBytesColumn(
          allow_offsets=True, write_offsets_cutoff=4096
      )
      schema = fields.Schema(name=fields.ID(sortable=col))
      with TempIndex(schema) as ix:
          with ix.writer() as w:
              for i in xrange(5000):
                  w.add_document(name=values[i % vlen])
  
          with ix.reader() as r:
              cr = r.column_reader("name")
              assert isinstance(cr, columns.TranslatingColumnReader)
              assert cr.raw_column().had_stored_offsets
              for i in (10, 100, 1000, 3000):
                  assert cr[i] == values[i % vlen]
  
file_path: whoosh/tests/test_columns.py
imports: from __future__ import with_statement
  import inspect, random, sys
  from whoosh import columns, fields, query
  from whoosh.codec.whoosh3 import W3Codec
  from whoosh.compat import b, u, BytesIO, bytes_type, text_type
  from whoosh.compat import izip, xrange, dumps, loads
  from whoosh.filedb import compound
  from whoosh.filedb.filestore import RamStorage
  from whoosh.util.testing import TempIndex, TempStorage
label_desc: Use image node_id 10 for calling a global function with example usage: test_varbytes_offsets() without return types