JASSv2
serialise_integers.h
Go to the documentation of this file.
1 /*
2  SERIALISE_INTEGERS.H
3  --------------------
4  Copyright (c) 2017 Andrew Trotman
5  Released under the 2-clause BSD license (See:https://en.wikipedia.org/wiki/BSD_licenses)
6  */
13 #pragma once
14 
15 #include "file.h"
16 #include "index_manager.h"
17 
18 namespace JASS
19  {
20  /*
21  CLASS SERIALISE_INTEGERS
22  ------------------------
23  */
36  {
37  private:
40  index_postings_impact impact_ordered;
41 
42  public:
43  /*
44  SERIALISE_INTEGERS::SERIALISE_INTEGERS()
45  ----------------------------------------
46  */
51  serialise_integers(size_t documents_in_collection) :
52  index_manager::delegate(documents_in_collection),
53  postings_file("postings.bin", "w+b"),
54  impact_ordered(documents, memory)
55  {
56  /* Nothing. */
57  }
58 
59  /*
60  SERIALISE_INTEGERS::FINISH()
61  ----------------------------
62  */
66  void finish(void)
67  {
68  /* Nothing */
69  }
70 
71  /*
72  SERIALISE_INTEGERS::OPERATOR()()
73  --------------------------------
74  */
83  virtual void operator()(const slice &term, const index_postings &postings, compress_integer::integer document_frequency, compress_integer::integer *document_ids, index_postings_impact::impact_type *term_frequencies);
84 
85  /*
86  SERIALISE_INTEGERS::OPERATOR()()
87  --------------------------------
88  */
94  virtual void operator()(size_t document_id, const slice &primary_key)
95  {
96  /* Nothing. */
97  }
98 
99  /*
100  SERIALISE_INTEGERS::UNITTEST_ONE_COLLECTION()
101  ---------------------------------------------
102  */
108  static void unittest_one_collection(const std::string &document_collection, uint32_t expected_checksum);
109 
110  /*
111  SERIALISE_INTEGERS::UNITTEST()
112  ------------------------------
113  */
117  static void unittest(void);
118  };
119  }
static void unittest(void)
Unit test this class.
Definition: serialise_integers.cpp:86
Non-thread-safe object that accumulates a single postings list during indexing.
Definition: index_postings.h:40
C++ slices (string-descriptors)
Definition: slice.h:27
void finish(void)
Definition: serialise_integers.h:66
Base class for the indexer object that stored the actual index during indexing.
uint32_t integer
This class and descendants will work on integers of this size. Do not change without also changing JA...
Definition: compress_integer.h:40
Partial file and whole file based I/O methods.
Serialise an index in integer dump format.
Definition: serialise_integers.h:35
file postings_file
The postings file.
Definition: serialise_integers.h:38
virtual void operator()(size_t document_id, const slice &primary_key)
The callback function to serialise the primary keys (external document ids) is operator().
Definition: serialise_integers.h:94
serialise_integers(size_t documents_in_collection)
<< the impact-ordered postings list
Definition: serialise_integers.h:51
Holder class for an impact ordered postings list.
Definition: index_postings_impact.h:31
Simple block-allocator that internally allocates a large chunk then allocates smaller blocks from thi...
Definition: allocator_pool.h:61
delegate(size_t documents)
Destructor.
Definition: index_manager.h:60
Definition: document_id.h:16
virtual void operator()(const slice &term, const index_postings &postings, compress_integer::integer document_frequency, compress_integer::integer *document_ids, index_postings_impact::impact_type *term_frequencies)
The callback function to serialise the postings (given the term) is operator().
Definition: serialise_integers.cpp:23
uint16_t impact_type
An impact value (i.e. a term frequency value) is of this type.
Definition: index_postings_impact.h:41
size_t documents
The number of documents in the collection.
Definition: index_manager.h:50
File based I/O methods including whole file and partial files.
Definition: file.h:45
Base class for holding the index during indexing.
Definition: index_manager.h:33
Base class for the callback function called by iterate.
Definition: index_manager.h:47
allocator_pool memory
Memory used to store the impact-ordered postings list.
Definition: serialise_integers.h:39
Definition: compress_integer_elias_delta_simd.c:23
static void unittest_one_collection(const std::string &document_collection, uint32_t expected_checksum)
Validate over a single collection - JASS_assert on failure.
Definition: serialise_integers.cpp:58