Git Product home page Git Product logo

Comments (6)

landawn avatar landawn commented on June 30, 2024

I agree that all the methods in DataSet should be compatible and work fine with empty DataSet.
The root cause for above issue mostly is in N.newEmptyDataSet(columnNames), not in DataSet
The implementation for newEmptyDataSet looks like:

new RowDataSet(new ArrayList<>(columnNames), new ArrayList<List<Object>>());

This is wrong. it should be:

final List<List<Object>> columnList = new ArrayList<>(columnNames.size());

for (int i = 0, size = columnNames.size(); i < size; i++) {
    columnList.add(new ArrayList<>(0));
}

return new RowDataSet(new ArrayList<String>(columnNames), columnList);

I will fix this issue in next release and add validation in DataSet to make sure sizes of column name list and column list are same.

I tested the join with empty DataSet not created by N.newEmptyDataSet. it works fine.

final DataSet dataSet1 = N.newDataSet(N.asLinkedHashMap("ACCT_ID", N.asList("1", "2"), "ACCT_NM", N.asList(11, 12)));

final DataSet dataSet2 = N.newDataSet(N.asList("ACCT_ID_1", "ACCT_NM_1"), N.asList(N.asList("id1", "nm1")));
dataSet2.println();

dataSet2.clear();

dataSet2.println();

dataSet2.updateColumn("ACCT_ID_1", Fn.<String, Long> f(Long::valueOf));

dataSet1.innerJoin(dataSet2, N.asMap("ACCT_ID", "ACCT_ID_1")).println();
dataSet1.fullJoin(dataSet2, N.asMap("ACCT_ID", "ACCT_ID_1")).println();

please let me know if you have different use case/test scenarios for this issue.

from abacusutil.

infinite-sahil avatar infinite-sahil commented on June 30, 2024

Yah, you are right, this issue is occurring in case of creating dataSet using N.newEmptyDataSet.
else things works fine. will wait for the new release :)

Happy coding 👍

can you please brief list of few useful classes/interfaces in abacus -> like i saw you used Fn that too has some good functions.

from abacusutil.

infinite-sahil avatar infinite-sahil commented on June 30, 2024

@landawn when I can get version 1.7.8 on maven ?

from abacusutil.

landawn avatar landawn commented on June 30, 2024

@infinite-sahil It's available now.

And as you may or will know, There are couple of alternatives for (Try.Function<String, Object, RuntimeException>) Long::valueOf, :

  • cast by com.landawn.abacus.util.function.Function: (Function<String, Object>) Long::valueOf

  • use: (String val) -> Long.valueOf(val)

  • Fn.<String, Long> f(Long::valueOf)

  • use or add new utility method. for example: Fn.parseLong(), which just added in 1.7.8 release.

from abacusutil.

landawn avatar landawn commented on June 30, 2024

By the way, if you're interested in Functional Programming, you could have a look at the section Functional Programming in this project main page

from abacusutil.

infinite-sahil avatar infinite-sahil commented on June 30, 2024

Thank you @landawn .
I verified it and its working perfectly fine.

from abacusutil.

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.