Giter VIP home page Giter VIP logo

Comments (8)

bdice avatar bdice commented on May 30, 2024

@shriramch You can use an owning object like a std::deque<expression> or std::list<expression> where references are stable (std::vector can reallocate and invalidate references). The lifetime of the AST expressions would then be tied to the lifetime of that container, and you can return it or pass it around.

from cudf.

bdice avatar bdice commented on May 30, 2024

For an example of constructing an expression tree, see this benchmark:

// Note that a std::list is required here because of its guarantees against reference invalidation
// when items are added or removed. References to items in a std::vector are not safe if the
// vector must re-allocate.
auto expressions = std::list<cudf::ast::operation>();
// Construct tree that chains additions like (((a + b) + c) + d)
auto const op = cudf::ast::ast_operator::ADD;
if (reuse_columns) {
expressions.push_back(cudf::ast::operation(op, column_refs.at(0), column_refs.at(0)));
for (cudf::size_type i = 0; i < tree_levels - 1; i++) {
expressions.push_back(cudf::ast::operation(op, expressions.back(), column_refs.at(0)));
}
} else {
expressions.push_back(cudf::ast::operation(op, column_refs.at(0), column_refs.at(1)));
std::transform(std::next(column_refs.cbegin(), 2),
column_refs.cend(),
std::back_inserter(expressions),
[&](auto const& column_ref) {
return cudf::ast::operation(op, expressions.back(), column_ref);
});
}
auto const& expression_tree_root = expressions.back();

from cudf.

vyasr avatar vyasr commented on May 30, 2024

FWIW we'd also be OK with changing the current model, see #10744. If you would like to make that change, a PR is welcome!

from cudf.

shriramch avatar shriramch commented on May 30, 2024

@bdice Thank you, this approach worked.

from cudf.

shriramch avatar shriramch commented on May 30, 2024

@vyasr Sure, I'd like to try this.

from cudf.

vyasr avatar vyasr commented on May 30, 2024

@shriramch OK great! Feel free to post here if you need help in getting a development environment set up for cudf!

from cudf.

shriramch avatar shriramch commented on May 30, 2024

@vyasr Is it possible to get a remote development environment? Unfortunately I can't do this on my current PC.

from cudf.

vyasr avatar vyasr commented on May 30, 2024

Would you be able to spin up an EC2 or GCP instance for this? I think getting access on one of the cloud services would be the easiest. Paperspace is another good option.

from cudf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.