Skip to content

Commit 7a67f68

Browse files
committed
comments and code trimming
1 parent 0202bcc commit 7a67f68

9 files changed

Lines changed: 62 additions & 119 deletions

File tree

CMakeLists.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ message("-- Boost include dir " ${Boost_INCLUDE_DIR})
110110
# add_library(ServiceXHandler ServiceXHandler.cpp ServiceXHandler.h)
111111
add_library(Math SHARED src/MathLibrary.cpp include/MathLibrary.h)
112112

113-
add_library(XDataFrameLib SHARED
114-
src/Hasher.cpp
115-
src/MCache.cpp
116-
src/MathLibrary.cpp
117-
src/RDataFrameHandler.cpp
118-
src/Request.cpp
119-
src/ServiceXHandler.cpp
120-
src/User.cpp
121-
)
113+
# add_library(XDataFrameLib SHARED
114+
# src/Hasher.cpp
115+
# src/MCache.cpp
116+
# src/MathLibrary.cpp
117+
# src/RDataFrameHandler.cpp
118+
# src/Request.cpp
119+
# src/ServiceXHandler.cpp
120+
# src/User.cpp
121+
# )
122122

123123

124124
file(GLOB SOURCES src/*.cpp)
@@ -192,6 +192,11 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
192192
# include(CTest)
193193
# endif()
194194

195+
# install(TARGETS XDataFrameLib
196+
# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
197+
# PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
198+
# )
199+
195200
install(TARGETS XDataFrame
196201
CONFIGURATIONS Debug
197202
RUNTIME DESTINATION ${CMAKE_BINARY_DIR}/../install/+bin)

exe/XDataFrame.cxx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@
4242
#include "Hasher.h"
4343
#include "MCache.h"
4444

45-
46-
// size_t writeFunction(void* ptr, size_t size, size_t nmemb, std::string* data) {
47-
// data->append((char*)ptr, size * nmemb);
48-
// return size * nmemb;
49-
// }
50-
51-
5245
// Helper Functions
5346

5447
/**
@@ -73,8 +66,6 @@ std::string ReadJsonFromFile(std::string filename){
7366
}
7467

7568

76-
77-
7869
int main(int argc, char* argv[]){
7970
if(argc > 1){
8071
if (strcmp(argv[1], "--version") == 0) {
@@ -89,11 +80,8 @@ int main(int argc, char* argv[]){
8980

9081
ServiceXHandler xHandler;
9182
std::vector<std::string> userYaml;
92-
// User theUser();
9383
std::map<std::string, std::string> values = xHandler.parseYaml("/servicex.yaml");
9484

95-
// std::string jsonstringresponse = xHandler.FetchData("345974d4-d2ec-49bb-bef2-6683b7e461d5");
96-
9785
Request testRequest;
9886

9987
MCache cache;
@@ -124,7 +112,8 @@ int main(int argc, char* argv[]){
124112
RDataFrameHandler rdfHandler;
125113
rdfHandler.AddFiles(filenameList);
126114
ROOT::RDataFrame myDataFrame = rdfHandler.CreateRDataFrame();
127-
115+
auto d1 = myDataFrame.Display();
116+
d1->Print();
128117
// rdfHandler.DisplayRDF();
129118

130119
std::cout << "Finished\n";

include/MCache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class MCache {
1212

1313
public:
1414
void LoadCache();
15-
bool SaveRequestId(std::string hash, std::string request_id);
1615
bool CreateCacheEntry(std::string hash);
1716
bool WriteRequestID(std::string hash, std::string requestId);
1817
std::string ReadRequestId(std::string hash);

src/Hasher.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,9 @@ std::string Hasher::GetHashOf(std::string filenameString){
4444

4545
tmp << myFile.rdbuf();
4646
std::string s = tmp.str();
47-
// std::cout << s << std::endl;
48-
4947

5048
hash.process_bytes(s.data(), s.size());
5149
hash.get_digest(digest);
5250

53-
// std::cout << "md5(" << s << ") = " << toString(digest) << '\n';
54-
55-
// std::cout << "returning " << toString(digest) << std::endl;
56-
5751
return toString(digest);
58-
}
59-
60-
61-
// while(std::getline(my_file, s)) {
62-
// md5 hash;
63-
// md5::digest_type digest;
64-
65-
// hash.process_bytes(s.data(), s.size());
66-
// hash.get_digest(digest);
67-
68-
// std::cout << "md5(" << s << ") = " << toString(digest) << '\n';
69-
// }
52+
}

src/MCache.cpp

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,11 @@ bool MCache::EntryExists(std::string hash){
5050
}
5151
}
5252

53-
5453
/**
55-
* @brief Save request_id to the hash folder.
54+
* @brief Sets the cache directory to the absolute file directory "directory"
5655
*
57-
* @param hash
58-
* @param request_id
59-
* @return true
60-
* @return false
56+
* @param directory
6157
*/
62-
bool MCache::SaveRequestId(std::string hash, std::string request_id){
63-
const char* homeDir = getenv("HOME");
64-
65-
// Check if hash exists.
66-
// If it doesn't, create it
67-
68-
return 0;
69-
}
70-
7158
void MCache::SetCacheDir(std::string directory){
7259
cacheDir = directory;
7360
}
@@ -76,6 +63,12 @@ std::string MCache::GetCacheDir(){
7663
return cacheDir;
7764
}
7865

66+
/**
67+
* @brief Gets the request_id of a given hash entry
68+
*
69+
* @param hash
70+
* @return std::string
71+
*/
7972
std::string MCache::ReadRequestId(std::string hash){
8073
fs::path hashFolderPath = fs::path(cacheDir + "/" + hash);
8174
if( fs::is_directory(hashFolderPath)) {
@@ -103,6 +96,15 @@ std::string MCache::ReadRequestId(std::string hash){
10396
return "";
10497
}
10598

99+
/**
100+
* @brief Writes a given request_id into the cache entry corresponding to a given hash.
101+
* Stores this in a file in the hash folder called "request_id.txt"
102+
*
103+
* @param hash
104+
* @param requestId
105+
* @return true
106+
* @return false
107+
*/
106108
bool MCache::WriteRequestID(std::string hash, std::string requestId){
107109
fs::path cachePath = fs::path(cacheDir);
108110
if(fs::is_directory(cachePath)){
@@ -133,6 +135,13 @@ bool MCache::WriteRequestID(std::string hash, std::string requestId){
133135
return 0;
134136
}
135137

138+
/**
139+
* @brief Creates an entry in the cache from a given hash
140+
*
141+
* @param hash
142+
* @return true
143+
* @return false
144+
*/
136145
bool MCache::CreateCacheEntry(std::string hash){
137146
// std::string tmpDir = fs::temp_directory_path();
138147
fs::path home = fs::path(std::getenv("HOME"));

src/RDataFrameHandler.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,15 @@ Much of this (for now) takes from theh RDataFrame tutorial
1313

1414
#include "RDataFrameHandler.h"
1515

16-
void RDataFrameHandler::fill_tree(const char *treeName, const char *fileName){
17-
ROOT::RDataFrame d(10);
18-
int i(0);
19-
d.Define("b1", [&i]() { return (double)i; })
20-
.Define("b2",
21-
[&i]() {
22-
auto j = i * i;
23-
++i;
24-
return j;
25-
})
26-
.Snapshot(treeName, fileName);
27-
return;
28-
}
29-
3016
/**
3117
* @brief Creates the RDataFrame objecct with the file list in the RDataFrameHandler
3218
* Returns 0 if successful
3319
* Returns 1 if not successful
3420
* @return ROOT::RDataFrame
3521
*/
3622
ROOT::RDataFrame RDataFrameHandler::CreateRDataFrame(){
37-
// auto fileName = "df001_introduction.root";
23+
// TODO: read the files fetched and get the tree name they have
3824
auto treeName = "treeme";
39-
// fill_tree(treeName, fileName);
4025

4126
// We read the tree from the file and create a RDataFrame, a class that
4227
// allows us to interact with the data contained in the tree.
@@ -48,6 +33,8 @@ ROOT::RDataFrame RDataFrameHandler::CreateRDataFrame(){
4833

4934
RDataFrameObject = &df;
5035

36+
// Testing for printing out the RDF.
37+
5138
std::cout << "Displaying\n";
5239

5340
auto d1 = df.Display();
@@ -90,9 +77,7 @@ int RDataFrameHandler::AddFiles(std::vector<std::string> filenames){
9077
return 0;
9178
}
9279

93-
RDataFrameHandler::RDataFrameHandler(){
94-
95-
}
80+
RDataFrameHandler::RDataFrameHandler(){}
9681

9782

9883
void RDataFrameHandler::DisplayRDF(){

src/Request.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020

2121
#include "MCache.h"
2222

23+
/**
24+
* @brief Gets the status of a servicex endpoint. Only for one hardcoded endpoint, can be extended/refactored
25+
* to fetch the status from an endpoint specified by an argument. Not needed at the moment.
26+
*
27+
* @return std::string
28+
*/
2329
std::string Request::GetStatus(){
2430
// Check if the endpoint exists
2531

src/ServiceXHandler.cpp

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,6 @@ std::map<std::string, std::string> ServiceXHandler::parseYaml(std::string target
9090
std::ifstream myfile (fullDir);
9191
if (myfile.is_open())
9292
{
93-
// std::string fields;
94-
// while ( getline (myfile,line) ){
95-
// std::cout << line << '\n';
96-
// fields << line << std::endl;
97-
// }
98-
9993
std::string content;
10094
content.assign( (std::istreambuf_iterator<char>(myfile) ),
10195
(std::istreambuf_iterator<char>() ) );
@@ -127,31 +121,13 @@ std::map<std::string, std::string> ServiceXHandler::parseYaml(std::string target
127121

128122
// TODO: Needs to search and verify that the nodes are there before they are referenced.
129123

130-
// show_val(tree["sub"].child(0)[0]); // "foo: 1"
131-
// show_val(subFirst[0]);
132-
// show_keyval(api_endpointNode[0]);
133-
// std::cout << "Number of children of endpoint: " << api_endpointNode.num_children() << std::endl;
134-
135-
// show_val(typeNode[0]);
136-
// show_val(tokenNode[0]);
137-
138124
show_keyval(endpointNode);
139-
// show_keyval(tokenNode);
140-
// show_keyval(typeNode);
141125

142126
std::string endpoint;
143127
std::string token;
144128
std::string mytype;
145129

146130
c4::from_chars(endpointNode.val(), &endpoint);
147-
// c4::from_chars(tokenNode.val(), &token);
148-
// c4::from_chars(typeNode.val(), &mytype);
149-
150-
// std::cout << "Endpoint: " << endpoint << std::endl;
151-
// std::cout << "Token: " << token << std::endl;
152-
// std::cout << "Type: " << mytype << std::endl;
153-
154-
155131

156132
myfile.close();
157133

@@ -170,6 +146,12 @@ std::map<std::string, std::string> ServiceXHandler::parseYaml(std::string target
170146
return properties;
171147
}
172148

149+
/**
150+
* @brief Deprecated. Fetched data from a hardcoded servicex endpoint.
151+
*
152+
* @param request_id
153+
* @return std::string
154+
*/
173155
std::string ServiceXHandler::FetchData(std::string request_id){
174156
// CURL *curl = curl_easy_init();
175157
// std::string request_id = "345974d4-d2ec-49bb-bef2-6683b7e461d5";
@@ -288,8 +270,8 @@ Json::Value ServiceXHandler::JsonFromStr(std::string jsonStr){
288270

289271

290272
/**
291-
* @brief Gets MinIO bucket data and prints it. For now, uses a hard-coded bucket name and
292-
* request_id
273+
* @brief Gets MinIO bucket data and prints it. Takes in a bucket name (request_id) and a pathkey
274+
* that specifies where the program will write the downloaded files to disk.
293275
*
294276
* @return A list of downloaded file names
295277
*/
@@ -382,25 +364,8 @@ std::vector<std::string> ServiceXHandler::GetMinIOData(std::string bucketName, s
382364
return filenames;
383365
}
384366

385-
386-
387-
// bool ServiceXHandler::GetMd5(std::string &str_md5, const char * const buffer, size_t buffer_size){
388-
// if (buffer == nullptr){
389-
// return false;
390-
// }
391-
// boost::uuids::detail::md5 boost_md5;
392-
// boost_md5.process_bytes(buffer, buffer_size);
393-
// boost::uuids::detail::md5::digest_type digest;
394-
// boost_md5.get_digest(digest);
395-
// const auto char_digest = reinterpret_cast<const char*>(&digest);
396-
// str_md5.clear();
397-
// boost::algorithm::hex(char_digest,char_digest+sizeof(boost::uuids::detail::md5::digest_type), std::back_inserter(str_md5));
398-
// return true;
399-
// }
400-
401-
402367
/**
403-
* @brief
368+
* @brief Stub
404369
*
405370
*/
406371
void HashSubmitJson(){}

src/User.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
#include <User.h>
2828

29+
// DEPRECATED ?
30+
2931
/**
3032
* @brief Creates a folder for a new user if it doesn't exist already
3133
*

0 commit comments

Comments
 (0)