GENIE
DeviceCodecFactory.h
Go to the documentation of this file.
1 #ifndef DEVICE_CODEC_FACTORY_H_
2 #define DEVICE_CODEC_FACTORY_H_
3 
4 #include <map>
5 #include <memory>
6 #include <string>
7 #include <vector>
8 
9 #include <thrust/device_vector.h>
10 
12 #include <genie/utility/Logger.h>
13 
14 #include "DeviceCodecs.h"
15 
16 namespace genie { namespace table {class inv_compr_table;}}
17 namespace genie { namespace query {class Query; }}
18 namespace genie { namespace matching {struct data_t; }}
19 
23 typedef void (*MatchIntegratedFunPtr)(
25  std::vector<genie::query::Query>&,
26  thrust::device_vector<genie::matching::data_t>&,
27  thrust::device_vector<u32>&, int, int,
28  thrust::device_vector<u32>&,
29  thrust::device_vector<u32>&,
30  thrust::device_vector<u32>&);
31 
32 namespace genie
33 {
34 
35 namespace compression
36 {
37 
39  NO_COMPRESSION = 0, // make (bool)NO_COMPRESSION evaluate as false
53 };
54 
59 
60 
61 
63 public:
64 
65  static const std::map<std::string, COMPRESSION_TYPE> compressionTypesMap;
66 
67  static const std::map<COMPRESSION_TYPE, std::string> compressionNamesMap;
68 
69  static const std::map<COMPRESSION_TYPE, MatchIntegratedFunPtr> integratedKernelsMap;
70 
71  // TODO test that the class inheritance structure works well (e.g. by calling getName())
72  static const std::map<COMPRESSION_TYPE, std::shared_ptr<DeviceIntegerCODEC>> codecInstancesMap;
73 
74  static const std::vector<COMPRESSION_TYPE> allCompressionTypes;
75 
76  static const std::vector<std::string> allCompressionNames;
77 
78  static std::string getCompressionName(COMPRESSION_TYPE type)
79  {
80  if (compressionNamesMap.find(type) == compressionNamesMap.end())
81  return "Unknown-Compression-Type";
82  return compressionNamesMap.at(type);
83  }
84 
85  static COMPRESSION_TYPE getCompressionType(const std::string &name)
86  {
87  if (compressionTypesMap.find(name) == compressionTypesMap.end())
88  return NO_COMPRESSION;
89  return compressionTypesMap.at(name);
90  }
91 
92  static std::shared_ptr<DeviceIntegerCODEC> getCodec(COMPRESSION_TYPE type)
93  {
94  if (codecInstancesMap.find(type) == codecInstancesMap.end())
95  {
96  genie::utility::Logger::log(genie::utility::Logger::ALERT, "Unknown codec requested (%d)!", (int)type);
97  return nullCodec;
98  }
99  return codecInstancesMap.at(type);
100  }
101 
103  {
104  if (integratedKernelsMap.find(type) == integratedKernelsMap.end())
105  {
107  "Unknown integrated matching function pointer requested (%d)!", (int)type);
108  return nullptr;
109  }
110  return integratedKernelsMap.at(type);
111  }
112 
113 protected:
114 
115  static const std::shared_ptr<DeviceIntegerCODEC> nullCodec;
116 
117 };
118 
119 } // namespace compression
120 } // namespace genie
121 
122 #endif
static const std::map< COMPRESSION_TYPE, std::shared_ptr< DeviceIntegerCODEC > > codecInstancesMap
static MatchIntegratedFunPtr getMatchingFunPtr(COMPRESSION_TYPE type)
static const std::vector< std::string > allCompressionNames
This is the top-level namespace of the project.
const COMPRESSION_TYPE DEFAULT_COMPRESSION_TYPE
Definition: interface.cc:48
static const std::vector< COMPRESSION_TYPE > allCompressionTypes
void(* MatchIntegratedFunPtr)(genie::table::inv_compr_table &, std::vector< genie::query::Query > &, thrust::device_vector< genie::matching::data_t > &, thrust::device_vector< u32 > &, int, int, thrust::device_vector< u32 > &, thrust::device_vector< u32 > &, thrust::device_vector< u32 > &)
static const std::map< COMPRESSION_TYPE, MatchIntegratedFunPtr > integratedKernelsMap
static std::shared_ptr< DeviceIntegerCODEC > getCodec(COMPRESSION_TYPE type)
static const std::shared_ptr< DeviceIntegerCODEC > nullCodec
const COMPRESSION_TYPE LIGHTWEIGHT_COMPRESSION_TYPE
Query class includes the functions for processing queries based on user&#39;s input.
static const std::map< std::string, COMPRESSION_TYPE > compressionTypesMap
static COMPRESSION_TYPE getCompressionType(const std::string &name)
const COMPRESSION_TYPE HEAVYWEIGHT_COMPRESSION_TYPE
static const int ALERT
Definition: Logger.h:47
static int log(int level, const char *fmt,...)
Record and print a message into log file.
Definition: Logger.cc:99
Record run-time information.
Basic utility functions to be used in matching kernels.
static const std::map< COMPRESSION_TYPE, std::string > compressionNamesMap
const COMPRESSION_TYPE MIDDLEWEIGHT_COMPRESSION_TYPE
static std::string getCompressionName(COMPRESSION_TYPE type)