Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

big-array

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

big-array

When you need an array with a few trillion elements

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Big Array

A resizable array using non-sequential block memory allocation. Growing or shrinking the array does not require reallocation of the entire array. Useful when you need to track a few trillion data points.

Note: For best results a 64-bit system and enough RAM to hold your data is recommended. If your data set grows slowly over time, paging to virtual memory may be acceptable.

	npm install big-array

Usage: bigArray.Char(numberOfInitialElements, sizeOfElementBlocks)

  • numberOfInitialElements: Number of array elements to initially allocate, rounds up to the nearest number divisible by sizeOfElementBlocks. default is 1
  • sizeOfElementBlocks: Number of elements to allocate in each memory block. If this number is too small it will drastically increase the overhead memory usage for large arrays. default is 1048576 (1 MB for char)
	var bigArray = require('big-array'),
		ba, val;

	// Numeric array types
	ba = new bigArray.Char(10, 100);
	ba = new bigArray.UnsignedChar();

	ba = new bigArray.Int();
	ba = new bigArray.UnsignedInt();

	ba = new bigArray.ShortInt();
	ba = new bigArray.ShortUnsignedInt();

	ba = new bigArray.LongInt();
	ba = new bigArray.LongUnsignedInt();

	ba = new bigArray.Float();

	ba = new bigArray.Double();

	var bigArray = require('big-array'),
		trillion = 1000 * 1000 * 1000 * 1000,
		ba, i;

	ba = bigArray.UnsignedChar();
	// Unlike JavaScript, setting or getting a high index will result in 
	// the array allocating all elements before that index
	ba.set(trillion, 5);

Tip: When testing on Linux, use "ulimit -v" to limit the maximum memory consumption.

	# Limit memory usage to 10GB
	ulimit -v 10485760

Common methods

	set(index, value)
	get(index)

	// inc/dec by 1
	inc(index)
	dec(index)

	push(value)
	pop()
	// modify push/pop index
	setIndex(index)
	getIndex()

	// resize array to [size]
	resize(size)

FAQs

Package last updated on 29 Dec 2012

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