code: def test_plaintext_codec():
      pytest.importorskip("ast")
      from whoosh.codec.plaintext import PlainTextCodec
      from whoosh.codec.whoosh3 import W3Codec
  
      ana = analysis.StemmingAnalyzer()
      schema = fields.Schema(
          a=fields.TEXT(vector=True, sortable=True),
          b=fields.STORED,
          c=fields.NUMERIC(stored=True, sortable=True),
          d=fields.TEXT(analyzer=ana, spelling=True),
      )
  
      st = RamStorage()
      ix = st.create_index(schema)
      with ix.writer(codec=W3Codec()) 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"),
          )
  
      with ix.reader() as r:
          assert r.has_column("a")
          c = r.column_reader("a")
          assert c[2] == u("charlie delta echo")
  
      w = ix.writer(codec=PlainTextCodec())
      w.commit(optimize=True)
  
      with ix.searcher() as s:
          reader = s.reader()
          assert isinstance(reader.codec(), PlainTextCodec)
  
          r = s.search(query.Term("a", "delta"))
          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"
          )
  
          storage = ix.storage
          for fname in storage.list():
              if fname.endswith(".dcs"):
                  f = storage.open_file(fname)
                  # print(f.read().decode("utf8"))
  
          assert reader.doc_field_length(0, "a") == 3
          assert reader.doc_field_length(2, "a") == 3
  
          cfield = schema["c"]
          assert type(cfield), fields.NUMERIC
          sortables = list(cfield.sortable_terms(reader, "c"))
          assert sortables
          assert [cfield.from_bytes(t) for t in sortables] == [
              -200,
              -100,
              100,
              200,
              300,
          ]
  
          assert reader.has_column("a")
          c = reader.column_reader("a")
          assert c[2] == u("charlie delta echo")
  
          assert reader.has_column("c")
          c = reader.column_reader("c")
          assert list(c) == [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 17 for calling a global function with example usage: test_plaintext_codec() without return types