From b27997bc118f2e6ce1159ec17091272e6892f7d9 Mon Sep 17 00:00:00 2001
From: Jakob Blomer <jblomer@cern.ch>
Date: Thu, 12 Jul 2018 10:35:07 +0200
Subject: [PATCH] [DF] Add skeleton for sqlite data source

---
 tree/dataframe/inc/ROOT/RSqliteDS.hxx | 46 +++++++++++++++
 tree/dataframe/src/RSqliteDS.cxx      | 80 +++++++++++++++++++++++++++
 2 files changed, 126 insertions(+)
 create mode 100644 tree/dataframe/inc/ROOT/RSqliteDS.hxx
 create mode 100644 tree/dataframe/src/RSqliteDS.cxx

diff --git a/tree/dataframe/inc/ROOT/RSqliteDS.hxx b/tree/dataframe/inc/ROOT/RSqliteDS.hxx
new file mode 100644
index 00000000000..9bcc8089117
--- /dev/null
+++ b/tree/dataframe/inc/ROOT/RSqliteDS.hxx
@@ -0,0 +1,46 @@
+// Author: Jakob Blomer CERN  07/2018
+
+/*************************************************************************
+ * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers.               *
+ * All rights reserved.                                                  *
+ *                                                                       *
+ * For the licensing terms see $ROOTSYS/LICENSE.                         *
+ * For the list of contributors see $ROOTSYS/README/CREDITS.             *
+ *************************************************************************/
+
+#ifndef ROOT_RSQLITEDS
+#define ROOT_RSQLITEDS
+
+#include "ROOT/RDataFrame.hxx"
+#include "ROOT/RDataSource.hxx"
+
+namespace ROOT {
+
+namespace RDF {
+
+class RSqliteDS final : public ROOT::RDF::RDataSource {
+public:
+   RSqliteDS(std::string_view fileName, std::string_view query);
+   ~RSqliteDS();
+   virtual void SetNSlots(unsigned int nSlots) override;
+   virtual const std::vector<std::string> &GetColumnNames() const override;
+   virtual bool HasColumn(std::string_view) const override;
+   virtual std::string GetTypeName(std::string_view) const override;
+   virtual std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() override;
+   virtual bool SetEntry(unsigned int slot, ULong64_t entry) override;
+
+protected:
+   virtual Record_t GetColumnReadersImpl(std::string_view name, const std::type_info &) override;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Factory method to create a SQlite RDataFrame.
+/// \param[in] fileName Path of the sqlite file.
+/// \param[in] SQL query that defines the data set.
+RDataFrame MakeSqliteDataFrame(std::string_view fileName, std::string_view query);
+
+} // ns RDF
+
+} // ns ROOT
+
+#endif
diff --git a/tree/dataframe/src/RSqliteDS.cxx b/tree/dataframe/src/RSqliteDS.cxx
new file mode 100644
index 00000000000..99220058d3b
--- /dev/null
+++ b/tree/dataframe/src/RSqliteDS.cxx
@@ -0,0 +1,80 @@
+// Author: Jakob Blomer CERN  07/2018
+
+/*************************************************************************
+ * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers.               *
+ * All rights reserved.                                                  *
+ *                                                                       *
+ * For the licensing terms see $ROOTSYS/LICENSE.                         *
+ * For the list of contributors see $ROOTSYS/README/CREDITS.             *
+ *************************************************************************/
+
+// clang-format off
+/** \class ROOT::RDF::RSqliteDS
+    \ingroup dataframe
+    \brief RDataFrame data source class for reading SQlite files.
+*/
+// clang-format on
+
+#include <ROOT/RSqliteDS.hxx>
+#include <ROOT/RDFUtils.hxx>
+#include <ROOT/RMakeUnique.hxx>
+#include <TError.h>
+
+namespace ROOT {
+
+namespace RDF {
+
+RSqliteDS::RSqliteDS(std::string_view fileName, std::string_view query)
+{
+}
+
+
+RSqliteDS::~RSqliteDS()
+{
+}
+
+
+const std::vector<std::string> &RSqliteDS::GetColumnNames() const
+{
+}
+
+
+RDataSource::Record_t RSqliteDS::GetColumnReadersImpl(std::string_view name, const std::type_info &)
+{
+}
+
+
+std::vector<std::pair<ULong64_t, ULong64_t>> RSqliteDS::GetEntryRanges()
+{
+}
+
+
+std::string RSqliteDS::GetTypeName(std::string_view) const
+{
+}
+
+
+bool RSqliteDS::HasColumn(std::string_view) const
+{
+}
+
+
+RDataFrame MakeSqliteDataFrame(std::string_view fileName, std::string_view query)
+{
+   ROOT::RDataFrame tdf(std::make_unique<RSqliteDS>(fileName, query));
+   return tdf;
+}
+
+
+bool RSqliteDS::SetEntry(unsigned int slot, ULong64_t entry)
+{
+}
+
+
+void RSqliteDS::SetNSlots(unsigned int nSlots)
+{
+}
+
+} // ns RDF
+
+} // ns ROOT
-- 
GitLab