Skip to content

Instantly share code, notes, and snippets.

@seancribbs
Created June 10, 2013 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seancribbs/1020fb807e65dfda8d97 to your computer and use it in GitHub Desktop.
Save seancribbs/1020fb807e65dfda8d97 to your computer and use it in GitHub Desktop.
-- ======== SETTING DATA =========
-- Almost pythonic, with statement
WITH 'bucket' : 'key' AS MAP
INCREMENT gold_cnt BY 500
DECREMENT wood_cnt BY 100
ADD base64('SOMEBLOB') TO buildings_set;
-- A little more SQL-like
UPDATE MAP('bucket', 'key')
SET reg_lww TO 'Values!'
REMOVE 5 FROM int_set;
-- Modifying a bare counter
INCREMENT COUNTER('bucket','key') BY 10;
DECREMENT COUNTER('bucket','key') BY 5;
-- Modifying a bare set
ADD 'foo' TO SET('bucket', 'key');
REMOVE 'bar' FROM SET('bucket', 'key');
-- Modifying a register
SET REGISTER('bucket', 'key') TO base64('BYTES!');
-- ======== GETTING DATA =========
-- Get the whole map
VALUE OF MAP('bucket', 'key');
-- Extracting fields from a map
EXTRACT gold_cnt, wood_cnt FROM MAP('bucket', 'key');
-- Get the counter value
VALUE OF COUNTER('bucket', 'key');
-- Check the counter value
IS COUNTER('bucket', 'key') < 0;
-- Get the entire set
VALUE OF SET('bucket', 'key');
-- Check membership in a set
IS 10 MEMBER OF SET('bucket', 'key');
-- ======== OPEN QUESTIONS =========
-- 1) Should we require the language to specify the type as part of
-- the identifier (in the map) or as a "function"?
-- 2) Should we infer the underlying type from the operation? (e.g.
-- example, ADD/REMOVE for sets, INCREMENT/DECREMENT for counters)
-- 3) Does having query operations expose too many potential semantic
-- problems? (e.g. expectation of consistency and atomicity)
-- 4) Should we allow conditional updates? (e.g. if-then constructs)
@seancribbs
Copy link
Author

Notes from Ryan:

  • Prefers "WITH ... AS [type]" syntax over "TYPE(B,K)" syntax
  • Keep verb/subject order consistent
  • Question: can queries go inline with updates?

@seancribbs
Copy link
Author

Notes from discussion Russell:

  • Need way to fetch keys, remove keys from map
  • Hungarian notation, does it matter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment