Socket
Socket
Sign inDemoInstall

lento

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lento - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

19

lib/client.js

@@ -13,2 +13,3 @@ 'use strict'

const once = require('once')
const catering = require('catering')
const EventEmitter = require('events').EventEmitter

@@ -287,5 +288,9 @@ const QueryStream = require('./query-stream')

callback = catering.fromCallback(callback)
// TODO: maybe decouple the fetching of pages from the stream,
// so that we don't need a stream for the callback variant.
concatArray(this.createRowStream(sql, opts), callback)
return callback.promise
}

@@ -299,2 +304,4 @@

callback = catering.fromCallback(callback)
this.query('show session', opts, (err, rows) => {

@@ -326,2 +333,4 @@ if (err) return callback(err)

})
return callback.promise
}

@@ -337,2 +346,3 @@

assertValidSessionKey(key)
callback = catering.fromCallback(callback)

@@ -366,2 +376,4 @@ if (typeof value === 'string') {

})
return callback.promise
}

@@ -376,2 +388,3 @@

assertValidSessionKey(key)
callback = catering.fromCallback(callback)

@@ -390,2 +403,4 @@ this.query(`RESET SESSION ${key}`, opts, (err, rows) => {

})
return callback.promise
}

@@ -409,7 +424,7 @@

this.set('query_max_run_time', msOrDuration, opts, callback)
return this.set('query_max_run_time', msOrDuration, opts, callback)
}
resetTimeout (opts, callback) {
this.reset('query_max_run_time', opts, callback)
return this.reset('query_max_run_time', opts, callback)
}

@@ -416,0 +431,0 @@ }

{
"name": "lento",
"version": "2.3.0",
"version": "2.4.0",
"description": "Streaming client for Presto HTTP protocol v1",

@@ -23,2 +23,3 @@ "license": "MIT",

"backo": "^1.1.0",
"catering": "^2.0.0",
"debug": "^4.1.0",

@@ -40,2 +41,5 @@ "dset": "^2.0.1",

},
"hallmark": {
"validateLinks": false
},
"keywords": [

@@ -42,0 +46,0 @@ "database",

49

readme.md

@@ -29,2 +29,3 @@ # lento <sup id="a1">[1](#f1)</sup>

- Get rows as objects or arrays
- Supports both callbacks & promises
- Uses [Presto HTTP protocol v1](https://github.com/prestosql/presto/wiki/HTTP-Protocol)

@@ -67,4 +68,4 @@ - Keep-alive HTTP connections

- [`createPageStream(sql[, options])`](#createpagestreamsql-options)
- [Cancelation](#cancelation)
- [Events](#events)
- [Cancelation](#cancelation)
- [Events](#events)
- [`createRowStream(sql[, options])`](#createrowstreamsql-options)

@@ -105,2 +106,3 @@ - [`query(sql[, options], callback)`](#querysql-options-callback)

<a name="createpagestream"></a>
### `createPageStream(sql[, options])`

@@ -133,5 +135,5 @@

The `pageSize` specifies the maximum number of rows per page. Presto may return less per page. If Presto returns more rows than `pageSize`, the surplus is buffered and the stream will not make another HTTP request to Presto until fully drained. Note that if the (remainder of) rows fit in Presto's buffers, Presto will not block (until another HTTP request is made) but instead go into the `FINISHED` state after which you have 15 minutes (by default) to fetch the remaining results. If `pageSize` is <= 0 the stream emits pages as returned by Presto, without slicing them up.
The `pageSize` specifies the maximum number of rows per page. Presto may return less per page. If Presto returns more rows than `pageSize`, the surplus is buffered and the stream will not make another HTTP request to Presto until fully drained. Note that if the (remainder of) rows fit in Presto's buffers, Presto will not block (until another HTTP request is made) but instead go into the `FINISHED` state after which you have 15 minutes (by default) to fetch the remaining results. If `pageSize` is &lt;= 0 the stream emits pages as returned by Presto, without slicing them up.
The `highWaterMark` specifies how many pages to fetch preemptively. The maximum numbers of rows held in memory is approximately `(highWaterMark || 1) * pageSize`, plus any surplus from the last HTTP request. Because Presto can return thousands of rows per request, the default `highWaterMark` is 0 so that we *don't* preemptively fetch and only hold the number of rows contained in the last HTTP request.
The `highWaterMark` specifies how many pages to fetch preemptively. The maximum numbers of rows held in memory is approximately `(highWaterMark || 1) * pageSize`, plus any surplus from the last HTTP request. Because Presto can return thousands of rows per request, the default `highWaterMark` is 0 so that we _don't_ preemptively fetch and only hold the number of rows contained in the last HTTP request.

@@ -160,2 +162,3 @@ If you care more about throughput, you can opt to increase `highWaterMark`. Additionally you can increase `pageSize` if processing time is minimal or if you don't mind blocking the rest of your app while processing a page.

<a name="createrowstream"></a>
### `createRowStream(sql[, options])`

@@ -171,6 +174,7 @@

<a name="query"></a>
### `query(sql[, options], callback)`
Same as above but non-streaming, meant for simple queries. The `callback` function will receive an error if any and an array of rows.
### `query(sql[, options][, callback])`
Same as above but non-streaming, meant for simple queries. The `callback` function will receive an error if any and an array of rows. If no callback is provided, a promise is returned.
```js

@@ -182,7 +186,12 @@ client.query('DESCRIBE events', (err, rows) => {

I'll take a PR for Promise support.
With async/await:
```js
const rows = await client.query('DESCRIBE events')
```
<a name="set-timeout"></a>
### `setTimeout(duration[, options], callback)`
### `setTimeout(duration[, options][, callback])`
Set `query_max_run_time` for subsequent queries. If those take longer than `duration`, Presto will return an error with code `EXCEEDED_TIME_LIMIT` (see [errors](#errors)). The `duration` can be a number (in milliseconds) or a string parsed by Presto with the format `<value><unit>` - for example `5d` or `100ms`. Options are passed to [`query()`](#query) via [`set()`](#set), as this method is a shortcut for:

@@ -194,12 +203,16 @@

If no callback is provided, a promise is returned.
<a name="reset-timeout"></a>
### `resetTimeout([options, ]callback)`
Reset `query_max_run_time` to Presto's default. Options are passed to [`query()`](#query) via [`reset()`](#reset).
### `resetTimeout([options][, callback])`
Reset `query_max_run_time` to Presto's default. Options are passed to [`query()`](#query) via [`reset()`](#reset). If no callback is provided, a promise is returned.
<a name="set"></a>
### `set(key, value[, options], callback)`
Set a session property. Executes `SET SESSION ..` to prevalidate input, then sets `X-Presto-Session` header on subsequent queries. Value can be a boolean, number or string. Options are passed to [`query()`](#query).
### `set(key, value[, options][, callback])`
Set a session property. Executes `SET SESSION ..` to prevalidate input, then sets `X-Presto-Session` header on subsequent queries. Value can be a boolean, number or string. Options are passed to [`query()`](#query). If no callback is provided, a promise is returned.
```js

@@ -214,6 +227,7 @@ client.set('redistribute_writes', false, (err) => {

<a name="reset"></a>
### `reset(key[, options], callback)`
Reset a session property to its default value. Options are passed to [`query()`](#query).
### `reset(key[, options][, callback])`
Reset a session property to its default value. Options are passed to [`query()`](#query). If no callback is provided, a promise is returned.
```js

@@ -228,6 +242,9 @@ client.reset('redistribute_writes', (err) => {

<a name="show-session"></a>
### `session([options, ]callback)`
Converts the result of `SHOW SESSION` into a tree, coerces boolean and integer values to JSON types. Options are passed to [`query()`](#query). Callback signature is `(err, session)`. Partial example of a `session`:
### `session([options, ][callback])`
Converts the result of `SHOW SESSION` into a tree, coerces boolean and integer values to JSON types. Options are passed to [`query()`](#query). Callback signature is `(err, session)`. If no callback is provided, a promise is returned.
Partial example of a `session`:
```json

@@ -234,0 +251,0 @@ {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc