code: def test_memory_codec():
      from whoosh.codec import memory
      from whoosh.searching import Searcher
  
      ana = analysis.StemmingAnalyzer()
      schema = fields.Schema(
          a=fields.TEXT(vector=True),
          b=fields.STORED,
          c=fields.NUMERIC(stored=True, sortable=True),
          d=fields.TEXT(analyzer=ana, spelling=True),
      )
  
      codec = memory.MemoryCodec()
      with codec.writer(schema) as w:
          w.add_document(
              a=u("alfa bravo charlie"),
              b="hello",
              c=100,
              d=u("quelling whining echoing"),
          )
          w.add_document(
              a=u("bravo charlie delta"),
              b=1000,
              c=200,
              d=u("rolling timing yelling"),
          )
          w.add_document(
              a=u("charlie delta echo"),
              b=5.5,
              c=300,
              d=u("using opening pulling"),
          )
          w.add_document(
              a=u("delta echo foxtrot"),
              b=True,
              c=-100,
              d=u("aching selling dipping"),
          )
          w.add_document(
              a=u("echo foxtrot india"),
              b=None,
              c=-200,
              d=u("filling going hopping"),
          )
  
      reader = codec.reader(schema)
      s = Searcher(reader)
  
      assert ("a", "delta") in reader
      q = query.Term("a", "delta")
      r = s.search(q)
      assert len(r) == 3
      assert [hit["b"] for hit in r] == [1000, 5.5, True]
  
      assert (
          " ".join(s.field_terms("a"))
          == "alfa bravo charlie delta echo foxtrot india"
      )
  
      cfield = schema["c"]
      c_sortables = cfield.sortable_terms(reader, "c")
      c_values = [cfield.from_bytes(t) for t in c_sortables]
      assert c_values, [-200, -100, 100, 200, 300]
  
      assert reader.has_column("c")
      c_values = list(reader.column_reader("c"))
      assert c_values == [100, 200, 300, -100, -200]
  
      assert s.has_vector(2, "a")
      v = s.vector(2, "a")
      assert " ".join(v.all_ids()) == "charlie delta echo"
  
imports: from __future__ import with_statement
  import random
  from array import array
  import pytest
  from whoosh import analysis, fields, formats, query
  from whoosh.compat import u, b, text_type
  from whoosh.compat import array_tobytes, xrange
  from whoosh.codec import default_codec
  from whoosh.filedb.filestore import RamStorage
  from whoosh.util.testing import TempStorage
label_desc: Use image node_id 18 for calling a global function with example usage: test_memory_codec() without return types