neo4j-rstats / neo4r

A Modern and Flexible Neo4J Driver
https://neo4j-rstats.github.io/user-guide/
Other
106 stars 29 forks source link

[Implementation] Better results parser #38

Closed ColinFay closed 5 years ago

ColinFay commented 5 years ago

The current bottleneck is the result parsing:

library(neo4r)
con <- neo4j_api$new(url = "http://138.197.15.1:7474", user = "all", password = "readonly")
con$ping()

"match (t:Tag) return t.name as name, size((t)--()) as deg limit 1000;" %>%
    call_api(con)
  # Calling the API take 500 ms
  bench::mark({ 
    res <- POST(url = glue("{con$url}/db/data/transaction/commit?includeStats=true"),
                add_headers(.headers = c("Content-Type"="application/json",
                                         "accept"="application/json",
                                         #"X-Stream" = "true",
                                         "Authorization"= paste0("Basic ", con$auth))),
                body = body)
  })
# A tibble: 1 x 14
  expression   min  mean median   max `itr/sec`
  <chr>      <bch> <bch> <bch:> <bch>     <dbl>
1 {...       561ms 561ms  561ms 561ms      1.78

# while parsing the results around 2.5 seconds
    bench::mark({ 
      parse_api_results(res = res, type = type, format = format, include_stats = include_stats, meta = meta)
    })
# A tibble: 1 x 14
  expression   min  mean median   max `itr/sec` mem_alloc
  <chr>      <bch> <bch> <bch:> <bch>     <dbl> <bch:byt>
1 {...       2.29s 2.29s  2.29s 2.29s     0.437    10.1MB