File indexing completed on 2025-11-05 09:55:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef ROOT_RSQLITEDS
0012 #define ROOT_RSQLITEDS
0013
0014 #include "ROOT/RDataFrame.hxx"
0015 #include "ROOT/RDataSource.hxx"
0016 #include <string_view>
0017
0018 #include <memory>
0019 #include <string>
0020 #include <vector>
0021
0022 namespace ROOT {
0023
0024 namespace RDF {
0025
0026 namespace Internal {
0027
0028 struct RSqliteDSDataSet;
0029 }
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 class RSqliteDS final : public ROOT::RDF::RDataSource {
0052 private:
0053
0054
0055 enum class ETypes {
0056 kInteger,
0057 kReal,
0058 kText,
0059 kBlob,
0060 kNull
0061 };
0062
0063
0064
0065 struct Value_t {
0066 explicit Value_t(ETypes type);
0067
0068 ETypes fType;
0069 bool fIsActive;
0070 Long64_t fInteger;
0071 double fReal;
0072 std::string fText;
0073 std::vector<unsigned char> fBlob;
0074 void *fNull;
0075 void *fPtr;
0076 };
0077
0078 void SqliteError(int errcode);
0079
0080 std::unique_ptr<Internal::RSqliteDSDataSet> fDataSet;
0081 ULong64_t fNRow;
0082 std::vector<std::string> fColumnNames;
0083 std::vector<ETypes> fColumnTypes;
0084
0085 std::vector<Value_t> fValues;
0086
0087
0088
0089 static constexpr char const *fgTypeNames[] = {
0090 "Long64_t",
0091 "double",
0092 "std::string",
0093 "std::vector<unsigned char>",
0094 "void *"
0095 };
0096
0097
0098 public:
0099 RSqliteDS(const std::string &fileName, const std::string &query);
0100
0101 RSqliteDS(const RSqliteDS &) = delete;
0102 RSqliteDS &operator=(const RSqliteDS &) = delete;
0103 RSqliteDS(RSqliteDS &&) = delete;
0104 RSqliteDS &operator=(RSqliteDS &&) = delete;
0105 ~RSqliteDS() final;
0106
0107 void SetNSlots(unsigned int nSlots) final;
0108 const std::vector<std::string> &GetColumnNames() const final;
0109 bool HasColumn(std::string_view colName) const final;
0110 std::string GetTypeName(std::string_view colName) const final;
0111 std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() final;
0112 bool SetEntry(unsigned int slot, ULong64_t entry) final;
0113 void Initialize() final;
0114 std::string GetLabel() final;
0115
0116 protected:
0117 Record_t GetColumnReadersImpl(std::string_view name, const std::type_info &) final;
0118 };
0119
0120 RDataFrame FromSqlite(std::string_view fileName, std::string_view query);
0121
0122 }
0123
0124 }
0125
0126 #endif