Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tickets/dm 8405 #3

Merged
merged 6 commits into from Feb 3, 2017
Merged

Tickets/dm 8405 #3

merged 6 commits into from Feb 3, 2017

Conversation

iagaponenko
Copy link
Contributor

No description provided.

  sph-layout: spherical partitions explorer
  sph-duplicate2: an advanced version of the chunk duplicator

Added dependedcies on package 'sphgeom' for generating HTM ID
for levels higher than 13. This was needed by the new duplicator.
Copy link

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly OK, there are few things that can be improved:

  • throw new needs to be replaced with throw
  • curly brace initializers are out of favor, I think it's better to replace with parentheses
  • boost::lexical_cast<std::string> could be replaced with std::to_string where possible
    There are other minor comments you can llok at.

"required": ["boost_system", "boost_filesystem", "boost_thread", "boost_program_options"],
"buildRequired": ["boost_test"],
"required": ["boost_system", "boost_filesystem", "boost_thread", "boost_program_options", "sphgeom"],
"buildRequired": ["boost_test", "sphgeom"],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think buildRequired is an addition to required for build time, if you have dependency in required there no need to also put it into buildRequired.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github shows that newline is missing after last character

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing newline after last character

@@ -0,0 +1,225 @@
/*
* LSST Data Management System
* Copyright 2013 LSST Corporation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2017

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

#include <utility>
#include <vector>
#include <map>
#include <cmath>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

includes should be sorted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

std::set<uint64_t> objIdOutOfBox;

/// Duplicate the next row of the chunk's Object table
size_t duplicateObjectRow (std::string & line,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?


int idx = 0;
for (const std::string token : tokens) {
if (coldefObject.idxDeepSourceId == idx) { deepSourceId = boost::lexical_cast<uint64_t>(token); }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not it easier to write

uint64_t deepSourceId = boost::lexical_cast<uint64_t>(tokens[coldefObject.idxDeepSourceId]);

without looping over whole thing?

// Then update the row and store the updated row as well.

if (opt.storeInput) {
tokens[coldefObject.idxDeepSourceId] = boost::lexical_cast<std::string> (newInputDeepSourceId);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::to_string() is probably better for to-string conversion than boost::lexical_cast<std::string>, at least it is shorter

size_t numProcessed = 0,
numRecorded = 0;

std::ifstream infile { inFileName, std::ifstream::in };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::ifstream::in is default, no need to mention it explicitely

tokens[colnum++] = token;
}
if (colnum != tokens.size())
throw new std::range_error("too few tokens in a row of the input Object file");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need to split a line into tokens then Boost has a string algorithm library which is probably much more efficient that doing it via stringstream: http://www.boost.org/doc/libs/1_60_0/doc/html/string_algo/usage.html#idm45555128601440

Copy link
Contributor Author

@iagaponenko iagaponenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed all concerns.

@@ -0,0 +1,225 @@
/*
* LSST Data Management System
* Copyright 2013 LSST Corporation.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

#include <utility>
#include <vector>
#include <map>
#include <cmath>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

#include "boost/shared_ptr.hpp"

#include "lsst/partition/Chunker.h"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed


Chunk2WorkerMap result;

std::ifstream infile {filename, std::ifstream::in};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

int32_t chunk;
std::string node;
is >> chunk;
is >> node;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed


("chunk2worker", po::value<std::string>(), "Chunk-to-worker map.")

("chunk", po::value<std::vector<int32_t>>(), "Chunk identifier.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

vm.count("chunk") ? vm["chunk"].as<std::vector<int32_t>>() : std::vector<int32_t>();

if (chunks.empty())
for (int32_t chunkId = 0 ; chunkId < 20000; ++chunkId)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-implemented by adding two command line parameters to specify a range of chunk IDs in case if no specific IDs were passed to the application.

std::cout << " chunk2worker size: " << chunk2worker.size() << "\n";
}

part::Chunker chunker{overlap, numStripes, numSubStripesPerStripe};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

"required": ["boost_system", "boost_filesystem", "boost_thread", "boost_program_options"],
"buildRequired": ["boost_test"],
"required": ["boost_system", "boost_filesystem", "boost_thread", "boost_program_options", "sphgeom"],
"buildRequired": ["boost_test", "sphgeom"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@iagaponenko
Copy link
Contributor Author

The only request which I chose to refuse is regarding boost::lexical_caststd::string with std::to_string. The later truncates DOUBLE values to just a few digits after dot. This is not acceptable for this application because it's supposed to preserve the original precision of the duplicated contents.

Copy link

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve :)

@iagaponenko iagaponenko merged commit 721d0e5 into master Feb 3, 2017
@ktlim ktlim deleted the tickets/DM-8405 branch August 25, 2018 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants