# flumeview-hashtable

> flumeview key index as a memory hashtable (very fast)

Latest version **1.1.1** (published 2019-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install flumeview-hashtable
pnpm add flumeview-hashtable
yarn add flumeview-hashtable
bun add flumeview-hashtable
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2019-05-20 |
| First published | 2017-08-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 15.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | 'Dominic Tarr' |
| Maintainers | arj03, christianbundy, dominictarr, regular |

## Links

- npm: https://www.npmjs.com/package/flumeview-hashtable
- Repository: https://github.com/dominictarr/flumeview-hashtable
- Issues: https://github.com/dominictarr/flumeview-hashtable/issues
- npm.io page: https://npm.io/package/flumeview-hashtable

## Dependencies (4)

- [obv](https://npm.io/package/obv.md) 0.0.1
- [atomic-file](https://npm.io/package/atomic-file.md) ^1.1.3
- [pull-stream](https://npm.io/package/pull-stream.md) ^3.6.0
- [async-single](https://npm.io/package/async-single.md) ^1.0.5

## Recent versions

- 1.1.1 (latest) — 2019-05-20
- 1.1.0 — 2019-05-14
- 1.0.4 — 2018-07-04
- 1.0.3 — 2017-11-07
- 1.0.2 — 2017-10-29
- 1.0.1 — 2017-10-29
- 1.0.0 — 2017-10-25
- 0.1.4 — 2017-09-25
- 0.1.3 — 2017-08-12
- 0.1.2 — 2017-08-12
- 0.1.1 — 2017-08-12
- 0.1.0 — 2017-08-12
- 0.0.0 — 2017-08-03

## README

# flumeview-hashtable

A in-memory hashtable based flumeview.

Creates an unordered key:value mapping over a flumedb.
the key for each indexed record must be unique, and
the value will be the record stored in the log.
Since flumedb uses integer keys for the log implementation,
the hashtable is just a sparse array of integers, implemented
on a buffer. This means that a relatively small buffer (say 1mb)
can hold hundreds of thousands of references, and since buffers
are not traversed by the garbage collector, this is not a burden
on your app. Also, there is no disk-io while building the index
so if the only disk access is very slow (i.e. browser) this is great.

## example

``` js
//you need to provide a hash function.
//it doesn't actually need to be cryptographic

function hash (v) {
  return crypto.createHash('sha256')
    .update(v.toString())
    .digest().readUInt32BE(0)
}

//default getKey function
function getKey (data) {
  return data.key
}

var db =  Flume(
  Log(
    '/tmp/test-flumeview-hashtable'+Date.now(),
    {blockSize: 1024, codec: require('flumecodec/json')}
  ))
.use('index', require('../')(1, hash, getKey))

db.append({key: 'foo', value: ...}, function (err) {
  if(err) throw err
  db.index.get('foo', function (err, value) {

  })
})
```

## append-only resize

this implements a simple resize strategy, when the hashtable starts to become saturated,
a second hashtable twice the size is allocated. when querying, look in the largest
hashtable first. 

## TODO

* migrate records accessed into the large table, and throw out
the smaller ones when possible.
* maybe implement multiple records? for not quite unique values?
* support different key sizes.

## License

MIT

---
_Source: https://npm.io/package/flumeview-hashtable · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
