Giter Site home page Giter Site logo

ddia's Introduction

Random Design Data Intensive Applications inspired stuff

ci results

Contains a few different random bits and bobs that I wanted to try out whilst reading DDIA (still currently reading).

HashStore

A data store based on a simple single threaded append only log paired with an in-memory index. There are currently two implementations:

  • npm run hash:mem: An in memory version which just uses a simple string to store the log
  • npm run hash:file: A file based version that writes to the file systems in a series of size bounded segment files

The file based version is a bit of a work in progress as I still want to add log compaction to it and rebuilding the index.

Trie

I can't quite remember why now but I wrote something that allowed streaming a load of words into a trie data store:

cat src/trie/sampleWords.txt | ts-node --esm src/trie/trie.ts

It also prints it out in a Radix Tree format

Test

Bit of yak shaving when working on the in memory store but wrote a very simple test framework to support it.

ts-node --esm src/test/runner.ts

Tests are modules that end with .test.ts:

let store: Store;

// Optional function run before each test
export function beforeEach() {
  store = new Store();
}

// Exported function start with the word test
export function testCorrectCountWhenWordIsNotInIndex() {
  const word = "aaaa";
  checkExactEquals(store.getCount(word), 0);
}

There is a module containing some simple assertions though any error thrown by a test should be caught and reported correctly.

Successful results looks like:

Picture of successful results

Unsuccessful results look like:

Picture of failed results

Failed tests will set the unix return code correctly, but this can be disabled by setting an env var: REPORT_ERROR_STATUS=false.

Tests will print out some colour output, to disable set the env var: DISABLE_ANSI_COLOURS=true

To watch tests:

REPORT_ERROR_STATUS=false nodemon --watch src -e ts,js --exec 'ts-node --esm src/test/runner.ts'

ddia's People

Contributors

andrewrlee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.