Click here to Skip to main content
15,886,038 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: My cat continues to teach me about my computer. Pin
Member 106770245-Jan-21 5:20
professionalMember 106770245-Jan-21 5:20 
GeneralRe: My cat continues to teach me about my computer. Pin
wreckless5-Jan-21 5:56
wreckless5-Jan-21 5:56 
GeneralRe: My cat continues to teach me about my computer. Pin
Dan Sutton5-Jan-21 5:39
Dan Sutton5-Jan-21 5:39 
GeneralWell that was satisfying... Pin
honey the codewitch3-Jan-21 14:41
mvahoney the codewitch3-Jan-21 14:41 
GeneralRe: Well that was satisfying... Pin
Daniel Pfeffer3-Jan-21 21:50
professionalDaniel Pfeffer3-Jan-21 21:50 
GeneralRe: Well that was satisfying... Pin
honey the codewitch4-Jan-21 1:47
mvahoney the codewitch4-Jan-21 1:47 
GeneralRe: Well that was satisfying... Pin
Randor 3-Jan-21 22:21
professional Randor 3-Jan-21 22:21 
GeneralRe: Well that was satisfying... Pin
honey the codewitch4-Jan-21 1:43
mvahoney the codewitch4-Jan-21 1:43 
A) make what claim, specifically? That my project met its goals? I stand by that.

B) I never said it was better than simdjson. I said it was competitive. I stand by that. I did mention algorithimically better ways to process json, but i'm talking about designing better software generally there, not designing a better processor than simdjson, and I think it's clear from the context. But that's the only time i use the word "better" in my post.

C) I haven't said anything here that I haven't said to the simdjson contributors themselves, by way of an #issue, and pull request, and discussion.

D) I am only testing against the ondemand api

C++
void getEpisodeData(ondemand::object& root) {
    auto seasons = root["seasons"].get_array();
    auto sit = seasons.begin();
    while(sit!=seasons.end()) {
        auto season = *sit;
        auto episodes = season["episodes"].get_array();
        auto eit = episodes.begin();
        while(eit!=episodes.end()) {
            auto episode = *eit;
            auto season_number = episode["season_number"].get_int64();
            auto episode_number = episode["episode_number"].get_int64();
            auto name = episode["name"];
            ++eit;
        }
        ++sit;
    }
}


C++
void extractEpisodes(LexSource &fls)
{
    // we don't need nearly this much. see the profile info output
    StaticMemoryPool<256> pool;
    JsonElement seasonNumber;
    JsonElement episodeNumber;
    JsonElement name;
    const char *fields[] = {"season_number", "episode_number", "name"};
    JsonExtractor children[] = {JsonExtractor(&seasonNumber), JsonExtractor(&episodeNumber), JsonExtractor(&name)};
    JsonExtractor extraction(fields, 3, children);
    JsonReader jr(fls);
    unsigned long long maxUsedPool = 0;
    int episodes = 0;
    while (jr.skipToFieldValue("episodes", JsonReader::Forward)) {
        if (!jr.read())
            break;
        while (!jr.hasError() && JsonReader::EndArray != jr.nodeType()) {
            // we keep track of the max pool we use
            if (pool.used() > maxUsedPool)
                maxUsedPool = pool.used();
            // we don't need to keep the pool data between calls here
            pool.freeAll();

            ++episodes;
            if (!jr.extract(pool, extraction)) {
                printf("\t\t%d. (extraction failed!)\r\n",episodes);
                break;
            }
        }
    }
    if (jr.hasError())
    {
        // report the error
        printf("\tError (%d): %s\r\n",(int)jr.error(),jr.value());
        return;
    }
}


The reason mine is competitive is simple. As you say it does not validate, or rather, it can, but the way I'm using it, it is not. But also it uses a lot less instructions per operation, generally, and examines each character less times than simdjson (usually). Currently my code is harder to use, but that will change once I finish building JSONPath on top of my query system.
Real programmers use butterflies


modified 4-Jan-21 8:10am.

PraiseRe: Well that was satisfying... Pin
Randor 4-Jan-21 2:22
professional Randor 4-Jan-21 2:22 
GeneralRe: Well that was satisfying... Pin
honey the codewitch4-Jan-21 2:27
mvahoney the codewitch4-Jan-21 2:27 
GeneralRe: Well that was satisfying... Pin
Randor 4-Jan-21 8:46
professional Randor 4-Jan-21 8:46 
GeneralRe: Well that was satisfying... Pin
honey the codewitch4-Jan-21 11:12
mvahoney the codewitch4-Jan-21 11:12 
GeneralRe: Well that was satisfying... Pin
Randor 4-Jan-21 11:26
professional Randor 4-Jan-21 11:26 
GeneralRe: Well that was satisfying... Pin
honey the codewitch4-Jan-21 11:30
mvahoney the codewitch4-Jan-21 11:30 
GeneralRe: Well that was satisfying... Pin
Randor 4-Jan-21 11:44
professional Randor 4-Jan-21 11:44 
GeneralRe: Well that was satisfying... Pin
honey the codewitch4-Jan-21 11:48
mvahoney the codewitch4-Jan-21 11:48 
GeneralAre hardware questions allowed here? Pin
CodeWraith3-Jan-21 11:35
CodeWraith3-Jan-21 11:35 
GeneralRe: Are hardware questions allowed here? Pin
Mike Hankey3-Jan-21 13:31
mveMike Hankey3-Jan-21 13:31 
GeneralRe: Are hardware questions allowed here? Pin
CodeWraith3-Jan-21 14:28
CodeWraith3-Jan-21 14:28 
GeneralRe: Are hardware questions allowed here? Pin
enhzflep3-Jan-21 16:08
enhzflep3-Jan-21 16:08 
GeneralRe: Are hardware questions allowed here? Pin
honey the codewitch3-Jan-21 17:14
mvahoney the codewitch3-Jan-21 17:14 
GeneralRe: Are hardware questions allowed here? Pin
enhzflep3-Jan-21 19:43
enhzflep3-Jan-21 19:43 
GeneralRe: Are hardware questions allowed here? Pin
honey the codewitch3-Jan-21 19:49
mvahoney the codewitch3-Jan-21 19:49 
GeneralRe: Are hardware questions allowed here? Pin
enhzflep3-Jan-21 20:09
enhzflep3-Jan-21 20:09 
GeneralRe: Are hardware questions allowed here? Pin
honey the codewitch3-Jan-21 21:04
mvahoney the codewitch3-Jan-21 21:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.