Coder Social home page Coder Social logo

Comments (7)

santhosh-tekuri avatar santhosh-tekuri commented on June 5, 2024 1

marshalling array item is the approach taken by the library you have mentioned. I have following concerns with that approach:

  • lots of memory allocations
  • handling numbers (especially larger numbers) is error prone

the best approach is use Hashmap. I have used this approach in boon (it is port of this library in Rust)

unfortunately Golang map does not allow slices as keys, because slices has no equality defined.

I plan to use somewhat map like approach for this;

from jsonschema.

santhosh-tekuri avatar santhosh-tekuri commented on June 5, 2024

fixed with caf0c40

@NitinRamesh25 can you verify with this fix

from jsonschema.

santhosh-tekuri avatar santhosh-tekuri commented on June 5, 2024

@NitinRamesh25 it seems you have json array with large number of items.

the above fix improves performance only in cases where large array contains duplicate items.

from jsonschema.

NitinRamesh25 avatar NitinRamesh25 commented on June 5, 2024

@santhosh-tekuri I have verified with the new change and it works fast when duplicate items are close by in the array.
In case where the first and last element of the large array are duplicates, then it still takes a lot of time.
I would prefer if it runs fast even when no duplicate items are found.

Wouldn't this be faster if we marshal the element to []byte, convert it to a string and store it as the key of a map ?
Since the array elements would be keys of the map, lookups for duplicate data would be faster.

from jsonschema.

santhosh-tekuri avatar santhosh-tekuri commented on June 5, 2024

fixed with d0f75c8

@NitinRamesh25 now we use map to check uniqueness, when array is large enough (>20)

I tested locally by temporarily setting size threshold to zero, and all tests passed;

please verify at your end

from jsonschema.

NitinRamesh25 avatar NitinRamesh25 commented on June 5, 2024

Much thanks. It's faster now.

from jsonschema.

santhosh-tekuri avatar santhosh-tekuri commented on June 5, 2024

@NitinRamesh25 just published v5.3.1 with this fix

from jsonschema.

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.