Code Monkey home page Code Monkey logo

Comments (2)

SergeyKanzhelev avatar SergeyKanzhelev commented on May 21, 2024

@vitalyf007 - ID is quite random. Can we change sampling algorithm to work fine on small strings?

from applicationinsights-dotnet.

SergeyKanzhelev avatar SergeyKanzhelev commented on May 21, 2024

The decision was to concat the same string to the desired length like this. PR: microsoft/ApplicationInsights-JS#117

getSamplingHashCode: function (input) {
        if (input == "") {
            return 0;
        }

        var desiredResultLength = 8;
        while (input.length < desiredResultLength){
            input = input.concat(input);
            input = input.substr(0, desiredResultLength);
        }

Unit tests:
["ss", 1179811869],
["kxi", 34202699],
["wr", 1281077591],
["ynehgfhyuiltaiqovbpyhpm", 2139623659],
["iaxxtklcw", 1941943012],
["hjwvqjiiwhoxrtsjma", 1824011880],
["rpiauyg", 251412007],
["jekvjvh", 9189387],
["hq", 1807146729],
["kgqxrftjhefkwlufcxibwjcy", 270215819],
["lkfc", 1228617029],
["skrnpybqqu", 223230949],
["px", 70671963],
["dtn", 904623389],
["nqfcxobaequ", 397313566],
["togxlt", 948170633],
["jvvdkhnahkaujxarkd", 1486894898],
["mcloukvkamiaqja", 56804453],
["ornuu", 1588005865],
["otodvlhtvu", 1544494884],
["uhpwhasnvmnykjkitla", 981289895],
["itbnryqnjcgpmfuckghqtg", 1481733713],
["wauetkdnivwlafbfhiedsfx", 2114415420],
["fniwmeidbvd", 508699380],
["vuwdgoxspstvj", 1821547235],
["y", 1406544563],
["pceqcixfb", 1282453766],
["aentke", 255756533],
["ni", 1696510239],
["lbwehevltlnl", 1466602040],
["ymxql", 1974582171],
["mvqbaosfuip", 1560556398],
["urmwofajwmmlornynglm", 701710403],
["buptyvonyacerrt", 1315240646],
["cxsqcnyieliatqnwc", 76148095],
["svvco", 1849105799],
["luwmjhwyt", 553630912],
["lisvmmug", 822987687],
["mmntilfbmxwuyij", 882214597],
["hqmyv", 1510970959],

from applicationinsights-dotnet.

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.