Coder Social home page Coder Social logo

StackOverflowException about dawgsharp HOT 5 CLOSED

bzaar avatar bzaar commented on May 30, 2024
StackOverflowException

from dawgsharp.

Comments (5)

bzaar avatar bzaar commented on May 30, 2024

My project's first bug. How exciting!

Too bad I couldn't recreate it. I've added this test: 50908ca. @DrDigit, could you run it up and see if you get the exception?

from dawgsharp.

 avatar commented on May 30, 2024

I got the exception again because the file I used was malformed. At the end of it there were a lot of extra bytes and one of the parsed lines was really long. Therefore the exception was more than expected.

I added the following method as a quick workaround to make the code a bit safer.

public bool InsertWithLimit(string key, TPayload value)
{
    if (key == null || key.Length > 2048)
        return false;
    var node = root;
    foreach (char c in key)
        node = node.GetOrAddEdge(c);
    node.Payload = value;
    return true;
}

InsertWithLimit will let me know that it "refused" to insert the chemical name of the titin protein (180K+ characters) without throwing an exception.
IEnumerable characters for a key are replaced with a string because of the performance of Count method.
The 2048 limit is random and safe; it could be 4096 but not 16384.

from dawgsharp.

bzaar avatar bzaar commented on May 30, 2024

Ah! So the problem is long strings, not long lists. It's fixed now. Pushed version 1.0.6 to NuGet.

from dawgsharp.

bzaar avatar bzaar commented on May 30, 2024

Mind you, it will not break now, but performance may suffer. 200K strings is not really what DAWG was designed for. It will handle them, but they will take 3x more disk than a UTF-16 text file. Unless there are many of such chemical names and they share long common prefixes or suffixes in which case you might benefit from using DAWG.

from dawgsharp.

 avatar commented on May 30, 2024

The fix worth a lot of stars. Kudos.

from dawgsharp.

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.