New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sstable

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sstable

Sorted String Table

  • 0.3.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-16.67%
Maintainers
1
Weekly downloads
 
Created
Source

SSTable

This used to be a library for creating Sorted String Tables, as the needs of todb have changed so has the nature of this library. It's still kind of a SSTable but it's evolved.

An SSTable traditionally stores strings in sorted order something like this: key,value|key,value|key,value...

This library stores serialised JSON objects sorted by their key so:

{ key : 'a' , value : 'foo' },{ key : 'b' , value : 'bah'}, etc.

It's actually a little more complicated than that, it goes: 0029{key : 'a' , value : 'foo' }0x1e0029{key : 'a' , value : 'foo' }0x1e

Where 0029 is the byte length of the proceeding string and 0x1e is the row deliminator ascii record. Aditionally the first 12 bytes are reserved, the first two annotate the version of the SSTable, the next 10 the position in the table where the content stops. After all the records is a serialized JSON lookup table that I call the contents, this stores the byte offset for every section of keys, currently that is done based on the first letter but eventually it will be based on every x% of the table, or x rows, or x bytes, etc.

So if I want to look for a record starting with the letter x SSTable will first look at the contents and see where the byte offset for all the x records are and look from there rather than the start of the file.

Example:


new SSTable( "test.sst" , { id : 'email'  } , ( err , sstable ) => {
	sstable.create( [ { email : 'nikki@place.com' , age : '37' , name : 'Nikki' } ] , ( err ) => {
		sstable.seek( 'nikki@place.com' , ( err , value ) => {
		console.log(  value );
		} );
	} );
} );

FAQs

Package last updated on 30 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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