Browse Source

Travis run for pre-CRAN flight check

tags/v0.6.0
boB Rudis 6 years ago
parent
commit
018aca4eb1
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 5
      DESCRIPTION
  2. 8
      NEWS.md
  3. 12
      R/RcppExports.R
  4. 6
      R/ndjson.R
  5. 18
      README.Rmd
  6. 170
      README.md
  7. 12
      cran-comments.md
  8. 30
      src/RcppExports.cpp
  9. 24733
      src/json.h
  10. 6
      src/ndjson.cpp
  11. 9
      tests/testthat/test-ndjson.R

5
DESCRIPTION

@ -2,7 +2,7 @@ Package: ndjson
Type: Package
Title: Wicked-Fast Streaming 'JSON' ('ndjson') Reader
Version: 0.5.0
Date: 2017-06-28
Date: 2018-03-04
Author: Bob Rudis (bob@rud.is), Niels Lohmann (C++ json parser),
Deepak Bandyopadhyay (C++ gzstream), Lutz Kettner (C++ gzstream)
Maintainer: Bob Rudis <bob@rud.is>
@ -18,6 +18,7 @@ BugReports: https://gitlab.com/hrbrmstr/ndjson/issues
SystemRequirements: zlib, C++11
NeedsCompilation: yes
License: AGPL
Encoding: UTF-8
Suggests:
testthat
Depends:
@ -28,4 +29,4 @@ Imports:
dplyr,
dtplyr
LinkingTo: Rcpp
RoxygenNote: 6.0.1
RoxygenNote: 6.0.1.9000

8
NEWS.md

@ -1,3 +1,11 @@
0.6.0
=====================
* Updated to nlohmann/json.hpp v3.1.1 (Ref:
<https://github.com/nlohmann/json/blob/develop/ChangeLog.md>)
* Removed nlohmann/json.hpp #pragma's causing CRAN issues vis-a-vis the new
"Clutter up the console with unnecessary warnings" policy.
# Slightly modified tests
0.5.0
=====================
* Updated core ndjson file to take care of some buffer overflow vulns

12
R/RcppExports.R

@ -1,15 +1,15 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
internal_flatten <- function(lines) {
.Call(ndjson_internal_flatten, lines)
flatten_int <- function(lines) {
.Call(`_ndjson_flatten_int`, lines)
}
internal_stream_in <- function(path) {
.Call(ndjson_internal_stream_in, path)
stream_in_int <- function(path) {
.Call(`_ndjson_stream_in_int`, path)
}
internal_validate <- function(path, verbose) {
.Call(ndjson_internal_validate, path, verbose)
validate_int <- function(path, verbose) {
.Call(`_ndjson_validate_int`, path, verbose)
}

6
R/ndjson.R

@ -19,7 +19,7 @@
#' nrow(stream_in(gzf))
stream_in <- function(path, cls = c("dt", "tbl")) {
cls <- match.arg(cls, c("dt", "tbl"))
tmp <- .Call('ndjson_internal_stream_in', path.expand(path), PACKAGE='ndjson')
tmp <- stream_in_int(path.expand(path))
tmp <- dtplyr::tbl_dt(data.table::rbindlist(tmp, fill=TRUE))
if (cls == "tbl") dplyr::tbl_df(tmp) else tmp
}
@ -43,7 +43,7 @@ stream_in <- function(path, cls = c("dt", "tbl")) {
#' gzf <- system.file("extdata", "testgz.json.gz", package="ndjson")
#' validate(gzf)
validate <- function(path, verbose=FALSE) {
.Call('ndjson_internal_validate', path.expand(path), verbose, PACKAGE='ndjson')
validate_int(path.expand(path), verbose)
}
#' Flatten a character vector of individual JSON lines into a \code{tbl_dt}
@ -59,7 +59,7 @@ validate <- function(path, verbose=FALSE) {
#' flatten('{"top":{"next":{"final":1,"end":true},"another":"yes"},"more":"no"}')
flatten <- function(x, cls = c("dt", "tbl")) {
cls <- match.arg(cls, c("dt", "tbl"))
tmp <- .Call('ndjson_internal_flatten', x, PACKAGE='ndjson')
tmp <- flatten_int(x)
tmp <- dtplyr::tbl_dt(data.table::rbindlist(tmp, fill=TRUE))
if (cls == "tbl") dplyr::tbl_df(tmp) else tmp
}

18
README.Rmd

@ -5,7 +5,11 @@ output: rmarkdown::github_document
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/ndjson)](https://cran.r-project.org/package=ndjson) ![downloads](http://cranlogs.r-pkg.org/badges/grand-total/ndjson)
`ndjson` : Wicked-fast Streaming JSON ('ndjson') Reader
# `ndjson`
Wicked-fast Streaming JSON ('ndjson') Reader
## Description
Rcpp/C++11 wrapper for <https://github.com/nlohmann/json>
@ -26,7 +30,7 @@ The least painful way to do this is to install gcc >= 4.9 (and you should instal
FC=ccache gfortran
F77=ccache gfortran
### Why `ndjson` + Examples
## Why `ndjson` + Examples
An example of such files are the output from Rapid7 internet-wide scans, such as their [HTTPS study](https://scans.io/study/sonar.https). A gzip'd extract of 100,000 of one of those scans weighs in abt about 171MB. The records sometimes contain heavily nested JSON elements depending on how comprehensive the certificate data and other fields were. A typical record will look like this:
@ -93,6 +97,8 @@ All of the certificate sub-field data elents have been expanded and we have a hi
However, if you do end up trying to work with that scan data, it's highly recommended that you use `jq` to filter out the fields or records you want into a more compact ndjson file.
## What's inside the tin?
The following functions are implemented:
- `stream_in`: Stream in ndjson from a file (handles `.gz` files)
@ -101,7 +107,7 @@ The following functions are implemented:
There are no current plans for a `stream_out()` function since `jsonlite::stream_out()` does a great job tossing `data.frame`-like structures out to an ndjson file.
### Installation
## Installation
```{r eval=FALSE}
devtools::install_git("https://gitlab.com/hrbrmstr/ndjson.git")
@ -111,7 +117,7 @@ devtools::install_git("https://gitlab.com/hrbrmstr/ndjson.git")
options(width=120)
```
### Usage
## Usage
```{r message=FALSE}
library(ndjson)
@ -143,7 +149,7 @@ microbenchmark(
```
### Test Results
## Test Results
```{r message=FALSE}
library(ndjson)
@ -154,4 +160,6 @@ date()
test_dir("tests/")
```
## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.

170
README.md

@ -1,17 +1,29 @@
[![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/ndjson.svg)](https://travis-ci.org/hrbrmstr/ndjson) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/ndjson)](https://cran.r-project.org/package=ndjson) ![downloads](http://cranlogs.r-pkg.org/badges/grand-total/ndjson)
[![Travis-CI Build
Status](https://travis-ci.org/hrbrmstr/ndjson.svg)](https://travis-ci.org/hrbrmstr/ndjson)
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/ndjson)](https://cran.r-project.org/package=ndjson)
![downloads](http://cranlogs.r-pkg.org/badges/grand-total/ndjson)
`ndjson` : Wicked-fast Streaming JSON ('ndjson') Reader
# `ndjson`
Wicked-fast Streaming JSON (‘ndjson’) Reader
## Description
Rcpp/C++11 wrapper for <https://github.com/nlohmann/json>
The goal is to create a completely "flat" `data.frame`-like structure from ndjson records in plain text ndjson files or gzip'd ndjson files.
The goal is to create a completely “flat” `data.frame`-like structure
from ndjson records in plain text ndjson files or gzip’d ndjson files.
### Installation guidance for Linux/BSD-ish systems
CRAN has binaries for Windows and macOS. To build this on UNIX-like systems, you need at least g++4.9 or clang++. This is a forced requirement by the ndjson library.
CRAN has binaries for Windows and macOS. To build this on UNIX-like
systems, you need at least g++4.9 or clang++. This is a forced
requirement by the ndjson library.
The least painful way to do this is to install gcc &gt;= 4.9 (and you should install ccache while you're at it) and mmodfiy `~/.R/Makevars` thusly:
The least painful way to do this is to install gcc \>= 4.9 (and you
should install ccache while you’re at it) and mmodfiy `~/.R/Makevars`
thusly:
# Use whatever version of (g++ >=4.9 or clang++) that you downloaded
VER=-4.9
@ -21,9 +33,14 @@ The least painful way to do this is to install gcc &gt;= 4.9 (and you should ins
FC=ccache gfortran
F77=ccache gfortran
### Why `ndjson` + Examples
## Why `ndjson` + Examples
An example of such files are the output from Rapid7 internet-wide scans, such as their [HTTPS study](https://scans.io/study/sonar.https). A gzip'd extract of 100,000 of one of those scans weighs in abt about 171MB. The records sometimes contain heavily nested JSON elements depending on how comprehensive the certificate data and other fields were. A typical record will look like this:
An example of such files are the output from Rapid7 internet-wide scans,
such as their [HTTPS study](https://scans.io/study/sonar.https). A
gzip’d extract of 100,000 of one of those scans weighs in abt about
171MB. The records sometimes contain heavily nested JSON elements
depending on how comprehensive the certificate data and other fields
were. A typical record will look like this:
{
"vhost": "teamchat.buzzpoints.com",
@ -38,10 +55,13 @@ An example of such files are the output from Rapid7 internet-wide scans, such as
A `system.time(df <- stream_in("https-extract.json.gz"))` results in:
user system elapsed
14.822 0.224 15.189
```
user system elapsed
14.822 0.224 15.189
```
on a 13" MacBook Pro and produces:
on a 13" MacBook Pro and
produces:
Classes ‘tbl_dt’, ‘tbl’, ‘data.table’ and 'data.frame': 100000 obs. of 36 variables:
$ certsubject.CN : chr "*.tio.ch" "*.starwoodhotels.com" "a.ssl.fastly.net" "a.ssl.fastly.net" ...
@ -82,27 +102,40 @@ on a 13" MacBook Pro and produces:
$ certsubject.Mail : chr NA NA NA NA ...
- attr(*, ".internal.selfref")=<externalptr>
All of the certificate sub-field data elents have been expanded and we have a highly performant `tbl_dt` to work with now either in `dplyr` syntax or `data.table` heiroglyphic syntax. Just go see what you have to do in `jsonlite` to get a similar output (and how long it will take).
All of the certificate sub-field data elents have been expanded and we
have a highly performant `tbl_dt` to work with now either in `dplyr`
syntax or `data.table` heiroglyphic syntax. Just go see what you have to
do in `jsonlite` to get a similar output (and how long it will take).
`pryr::object_size(df)` for that shows it's consuming `394 MB`, which means we can read in many more extracts comfortably on a reasonably configured system and most (if not all) of it on a well-configured AWS box.
`pryr::object_size(df)` for that shows it’s consuming `394 MB`, which
means we can read in many more extracts comfortably on a reasonably
configured system and most (if not all) of it on a well-configured AWS
box.
However, if you do end up trying to work with that scan data, it's highly recommended that you use `jq` to filter out the fields or records you want into a more compact ndjson file.
However, if you do end up trying to work with that scan data, it’s
highly recommended that you use `jq` to filter out the fields or records
you want into a more compact ndjson file.
## What’s inside the tin?
The following functions are implemented:
- `stream_in`: Stream in ndjson from a file (handles `.gz` files)
- `validate`: Validate JSON records in an ndjson file (handles `.gz` files)
- `flatten`: Flatten a character vector of individual JSON lines
- `stream_in`: Stream in ndjson from a file (handles `.gz` files)
- `validate`: Validate JSON records in an ndjson file (handles `.gz`
files)
- `flatten`: Flatten a character vector of individual JSON lines
There are no current plans for a `stream_out()` function since `jsonlite::stream_out()` does a great job tossing `data.frame`-like structures out to an ndjson file.
There are no current plans for a `stream_out()` function since
`jsonlite::stream_out()` does a great job tossing `data.frame`-like
structures out to an ndjson file.
### Installation
## Installation
``` r
devtools::install_git("https://gitlab.com/hrbrmstr/ndjson.git")
```
### Usage
## Usage
``` r
library(ndjson)
@ -112,7 +145,7 @@ library(microbenchmark)
packageVersion("ndjson")
```
## [1] '0.3.0.0'
## [1] '0.5.1'
``` r
flatten('{"top":{"next":{"final":1,"end":true},"another":"yes"},"more":"no"}')
@ -120,7 +153,7 @@ flatten('{"top":{"next":{"final":1,"end":true},"another":"yes"},"more":"no"}')
## Source: local data table [1 x 4]
##
## # tbl_dt [1 × 4]
## # A tibble: 1 x 4
## more top.another top.next.end top.next.final
## <chr> <chr> <lgl> <dbl>
## 1 no yes TRUE 1
@ -134,14 +167,14 @@ dplyr::glimpse(ndjson::stream_in(f))
## Observations: 100
## Variables: 8
## $ args <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ headers.Accept <chr> "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*",...
## $ headers.Accept-Encoding <chr> "identity", "identity", "identity", "identity", "identity", "identity", "identity",...
## $ headers.Host <chr> "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpbin...
## $ headers.User-Agent <chr> "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)",...
## $ id <dbl> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 2...
## $ origin <chr> "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.22"...
## $ url <chr> "http://httpbin.org/stream/100", "http://httpbin.org/stream/100", "http://httpbin.o...
## $ args <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ headers.Accept <chr> "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*...
## $ `headers.Accept-Encoding` <chr> "identity", "identity", "identity", "identity", "identity", "identity", "identity...
## $ headers.Host <chr> "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpb...
## $ `headers.User-Agent` <chr> "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)...
## $ id <dbl> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,...
## $ origin <chr> "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.2...
## $ url <chr> "http://httpbin.org/stream/100", "http://httpbin.org/stream/100", "http://httpbin...
``` r
dplyr::glimpse(ndjson::stream_in(gzf))
@ -149,14 +182,14 @@ dplyr::glimpse(ndjson::stream_in(gzf))
## Observations: 100
## Variables: 8
## $ args <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ headers.Accept <chr> "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*",...
## $ headers.Accept-Encoding <chr> "identity", "identity", "identity", "identity", "identity", "identity", "identity",...
## $ headers.Host <chr> "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpbin...
## $ headers.User-Agent <chr> "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)",...
## $ id <dbl> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 2...
## $ origin <chr> "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.22"...
## $ url <chr> "http://httpbin.org/stream/100", "http://httpbin.org/stream/100", "http://httpbin.o...
## $ args <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ headers.Accept <chr> "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*...
## $ `headers.Accept-Encoding` <chr> "identity", "identity", "identity", "identity", "identity", "identity", "identity...
## $ headers.Host <chr> "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpb...
## $ `headers.User-Agent` <chr> "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)...
## $ id <dbl> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,...
## $ origin <chr> "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.2...
## $ url <chr> "http://httpbin.org/stream/100", "http://httpbin.org/stream/100", "http://httpbin...
``` r
dplyr::glimpse(jsonlite::stream_in(file(f), flatten=TRUE, verbose=FALSE))
@ -164,13 +197,13 @@ dplyr::glimpse(jsonlite::stream_in(file(f), flatten=TRUE, verbose=FALSE))
## Observations: 100
## Variables: 7
## $ url <chr> "http://httpbin.org/stream/100", "http://httpbin.org/stream/100", "http://httpbin.o...
## $ id <int> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 2...
## $ origin <chr> "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.22"...
## $ headers.Host <chr> "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpbin...
## $ headers.Accept-Encoding <chr> "identity", "identity", "identity", "identity", "identity", "identity", "identity",...
## $ headers.Accept <chr> "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*",...
## $ headers.User-Agent <chr> "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)",...
## $ url <chr> "http://httpbin.org/stream/100", "http://httpbin.org/stream/100", "http://httpbin...
## $ id <int> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,...
## $ origin <chr> "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.2...
## $ headers.Host <chr> "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpb...
## $ `headers.Accept-Encoding` <chr> "identity", "identity", "identity", "identity", "identity", "identity", "identity...
## $ headers.Accept <chr> "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*...
## $ `headers.User-Agent` <chr> "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)...
``` r
dplyr::glimpse(jsonlite::stream_in(gzfile(gzf), flatten=TRUE, verbose=FALSE))
@ -178,13 +211,13 @@ dplyr::glimpse(jsonlite::stream_in(gzfile(gzf), flatten=TRUE, verbose=FALSE))
## Observations: 100
## Variables: 7
## $ url <chr> "http://httpbin.org/stream/100", "http://httpbin.org/stream/100", "http://httpbin.o...
## $ id <int> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 2...
## $ origin <chr> "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.22"...
## $ headers.Host <chr> "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpbin...
## $ headers.Accept-Encoding <chr> "identity", "identity", "identity", "identity", "identity", "identity", "identity",...
## $ headers.Accept <chr> "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*",...
## $ headers.User-Agent <chr> "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)",...
## $ url <chr> "http://httpbin.org/stream/100", "http://httpbin.org/stream/100", "http://httpbin...
## $ id <int> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,...
## $ origin <chr> "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.22", "50.252.233.2...
## $ headers.Host <chr> "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpbin.org", "httpb...
## $ `headers.Accept-Encoding` <chr> "identity", "identity", "identity", "identity", "identity", "identity", "identity...
## $ headers.Accept <chr> "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*", "*/*...
## $ `headers.User-Agent` <chr> "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)", "Wget/1.18 (darwin15.5.0)...
``` r
microbenchmark(
@ -194,9 +227,9 @@ microbenchmark(
```
## Unit: milliseconds
## expr min lq mean median uq max neval cld
## ndjson 2.694575 2.883204 3.000030 2.956595 3.033864 4.319816 100 a
## jsonlite 8.487524 9.011873 9.411114 9.151305 9.334732 12.523081 100 b
## expr min lq mean median uq max neval cld
## ndjson 1.785639 1.877190 1.970529 1.937276 2.057145 2.317575 100 a
## jsonlite 3.924401 4.087739 4.378292 4.233847 4.445059 6.395232 100 b
``` r
microbenchmark(
@ -206,11 +239,11 @@ microbenchmark(
```
## Unit: milliseconds
## expr min lq mean median uq max neval cld
## ndjson 2.856464 2.957216 3.030433 3.005832 3.069114 3.436334 100 a
## jsonlite 8.302337 8.631042 9.021032 8.795794 9.031557 12.158147 100 b
## expr min lq mean median uq max neval cld
## ndjson 1.966033 2.056828 2.176153 2.141381 2.277848 2.853242 100 a
## jsonlite 3.173205 3.386831 3.736111 3.545374 3.951642 6.565099 100 b
### Test Results
## Test Results
``` r
library(ndjson)
@ -219,15 +252,26 @@ library(testthat)
date()
```
## [1] "Tue Sep 27 11:08:18 2016"
## [1] "Sun Mar 4 21:37:48 2018"
``` r
test_dir("tests/")
```
## testthat results ========================================================================================================
## OK: 4 SKIPPED: 0 FAILED: 0
## ✔ | OK F W S | Context
## ══ testthat results ══════════════════════════════════════════════════════════
## OK: 8 SKIPPED: 0 FAILED: 0
##
## ══ Results ════════════════════════════════════════════════════════════════════
## Duration: 0.3 s
##
## DONE ===================================================================================================================
## OK: 0
## Failed: 0
## Warnings: 0
## Skipped: 0
## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.
Please note that this project is released with a [Contributor Code of
Conduct](CONDUCT.md). By participating in this project you agree to
abide by its terms.

12
cran-comments.md

@ -1,7 +1,8 @@
## Test environments
* local OS X install, R 3.4.0 (clang)
* local ubuntu 16.04, R 3.4.0 (g++-7)
* win-builder (devel and release) https://win-builder.r-project.org/P5u60xh8LPrA/
* local OS X install, R 3.4.3 (clang)
* local ubuntu 16.04, R 3.4.3 (g++-7)
* Travis-CI (linux) https://travis-ci.org/hrbrmstr/ndjson
* win-builder (devel and release)
## R CMD check results
@ -15,5 +16,6 @@ None
## General notes
- Fixed CRAN gcc 7 toolchain issues (linux)
- Update core C++ library the pkg uses
- Removed included-json library #pragmas causing CRAN issues due to new
"show all warnings" policy
- Update core C++ library the pkg uses to 3.1.1

30
src/RcppExports.cpp

@ -5,45 +5,45 @@
using namespace Rcpp;
// internal_flatten
List internal_flatten(CharacterVector lines);
RcppExport SEXP ndjson_internal_flatten(SEXP linesSEXP) {
// flatten_int
List flatten_int(CharacterVector lines);
RcppExport SEXP _ndjson_flatten_int(SEXP linesSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< CharacterVector >::type lines(linesSEXP);
rcpp_result_gen = Rcpp::wrap(internal_flatten(lines));
rcpp_result_gen = Rcpp::wrap(flatten_int(lines));
return rcpp_result_gen;
END_RCPP
}
// internal_stream_in
List internal_stream_in(const std::string& path);
RcppExport SEXP ndjson_internal_stream_in(SEXP pathSEXP) {
// stream_in_int
List stream_in_int(const std::string& path);
RcppExport SEXP _ndjson_stream_in_int(SEXP pathSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const std::string& >::type path(pathSEXP);
rcpp_result_gen = Rcpp::wrap(internal_stream_in(path));
rcpp_result_gen = Rcpp::wrap(stream_in_int(path));
return rcpp_result_gen;
END_RCPP
}
// internal_validate
bool internal_validate(std::string path, bool verbose);
RcppExport SEXP ndjson_internal_validate(SEXP pathSEXP, SEXP verboseSEXP) {
// validate_int
bool validate_int(std::string path, bool verbose);
RcppExport SEXP _ndjson_validate_int(SEXP pathSEXP, SEXP verboseSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type path(pathSEXP);
Rcpp::traits::input_parameter< bool >::type verbose(verboseSEXP);
rcpp_result_gen = Rcpp::wrap(internal_validate(path, verbose));
rcpp_result_gen = Rcpp::wrap(validate_int(path, verbose));
return rcpp_result_gen;
END_RCPP
}
static const R_CallMethodDef CallEntries[] = {
{"ndjson_internal_flatten", (DL_FUNC) &ndjson_internal_flatten, 1},
{"ndjson_internal_stream_in", (DL_FUNC) &ndjson_internal_stream_in, 1},
{"ndjson_internal_validate", (DL_FUNC) &ndjson_internal_validate, 2},
{"_ndjson_flatten_int", (DL_FUNC) &_ndjson_flatten_int, 1},
{"_ndjson_stream_in_int", (DL_FUNC) &_ndjson_stream_in_int, 1},
{"_ndjson_validate_int", (DL_FUNC) &_ndjson_validate_int, 2},
{NULL, NULL, 0}
};

24733
src/json.h

File diff suppressed because it is too large

6
src/ndjson.cpp

@ -94,7 +94,7 @@ List gz_stream_in(const std::string &path) {
}
// [[Rcpp::export]]
List internal_flatten(CharacterVector lines) {
List flatten_int(CharacterVector lines) {
R_xlen_t num_lines = lines.size();
List container(num_lines);
@ -230,7 +230,7 @@ List j_stream_in(const std::string &path) {
}
// [[Rcpp::export]]
List internal_stream_in(const std::string &path) {
List stream_in_int(const std::string &path) {
if (ends_with(path, ".gz")) {
return(gz_stream_in(path));
@ -241,7 +241,7 @@ List internal_stream_in(const std::string &path) {
}
// [[Rcpp::export]]
bool internal_validate(std::string path, bool verbose) {
bool validate_int(std::string path, bool verbose) {
bool ok = true;
std::string line;

9
tests/testthat/test-ndjson.R

@ -1,5 +1,5 @@
context("basic functionality")
test_that("we can do something", {
context("uncompressed files (validation and streaming)")
test_that("validation and streaming works in uncompressed files (validation and streaming)", {
f <- system.file("extdata", "test.json", package="ndjson")
expect_that(validate(f), equals(TRUE))
@ -7,6 +7,11 @@ test_that("we can do something", {
expect_that(stream_in(f), is_a("tbl_dt"))
expect_that(stream_in(f, "tbl"), is_a("tbl_df"))
})
context("compressed files (validation and streaming)")
test_that("validation and streaming works in compressed files", {
gzf <- system.file("extdata", "testgz.json.gz", package="ndjson")
expect_that(validate(gzf), equals(TRUE))
expect_that(nrow(stream_in(gzf)), equals(100))

Loading…
Cancel
Save