code: def test_lengths_ram():
      s = fields.Schema(
          f1=fields.KEYWORD(stored=True, scorable=True),
          f2=fields.KEYWORD(stored=True, scorable=True),
      )
      st = RamStorage()
      ix = st.create_index(s)
      w = ix.writer()
      w.add_document(f1=u("A B C D E"), f2=u("X Y Z"))
      w.add_document(f1=u("B B B B C D D Q"), f2=u("Q R S T"))
      w.add_document(f1=u("D E F"), f2=u("U V A B C D E"))
      w.commit()
  
      dr = ix.reader()
      assert dr.stored_fields(0)["f1"] == "A B C D E"
      assert dr.doc_field_length(0, "f1") == 5
      assert dr.doc_field_length(1, "f1") == 8
      assert dr.doc_field_length(2, "f1") == 3
      assert dr.doc_field_length(0, "f2") == 3
      assert dr.doc_field_length(1, "f2") == 4
      assert dr.doc_field_length(2, "f2") == 7
  
      assert dr.field_length("f1") == 16
      assert dr.field_length("f2") == 14
      assert dr.max_field_length("f1") == 8
      assert dr.max_field_length("f2") == 7
  
imports: from __future__ import with_statement
  import random
  from collections import defaultdict
  from datetime import datetime
  import pytest
  from whoosh import analysis, fields, index, qparser, query, __version__
  from whoosh.compat import b, u, xrange, text_type, permutations
  from whoosh.filedb.filestore import RamStorage
  from whoosh.writing import IndexingError
  from whoosh.util.numeric import length_to_byte, byte_to_length
  from whoosh.util.testing import TempIndex, TempStorage
label_desc: Use image node_id 8 for calling a global function with example usage: test_lengths_ram() without return types