<?xml version="1.0" encoding="UTF-8"?>
<rss version='2.0' xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Larry Maccherone</title>
    <description>Analysis and Visualization running on Node.js, DocumentDB, and Earl Grey Tea</description>
    <link>https://lmaccherone.silvrback.com/feed</link>
    <atom:link href="https://lmaccherone.silvrback.com/feed" rel="self" type="application/rss+xml"/>
    <category domain="lmaccherone.silvrback.com">Content Management/Blog</category>
    <language>en-us</language>
      <pubDate>Wed, 09 Dec 2015 07:07:58 +0200</pubDate>
    <managingEditor>larry@maccherone.com (Larry Maccherone)</managingEditor>
      <item>
        <guid>http://blog.lumenize.com/major-upgrades-to-documentdb-utils#20367</guid>
          <pubDate>Wed, 09 Dec 2015 07:07:58 +0200</pubDate>
        <link>http://blog.lumenize.com/major-upgrades-to-documentdb-utils</link>
        <title>Major upgrades to documentdb-utils</title>
        <description>Also, C# .NET examples for documentdb-lumenize aggregations</description>
        <content:encoded><![CDATA[<p>I&#39;ve just now finished pushing a major upgrade to <a href="https://www.npmjs.com/package/documentdb-utils">documentdb-utils</a> and adding C# .NET examples to <a href="https://www.npmjs.com/package/documentdb-lumenize">documentdb-lumenize</a> docs.</p>

<p>With support for upserts, id-based links, and maxItemCount -1, a lot of the API design decisions that I made when I originally created documentdb-utils have been overcome by events... a testament to the rapid development the Azure team is doing. So, I decided to go back to square one and rather than expose my own API, I thought I&#39;d just wrap DocumentClient to upgrade it. Essentially every line of code in the package is new. The WrappedClient class takes a raw DocumentClient and upgrades the methods to have 429 error delay/retry support as well as work with higher-order async functions. It&#39;ll even send the same query to multiple collections and aggregate the results as well as aggregate the results of executing the same sproc on multiple collections.</p>

<p>Also, I realized that I had started to create a bunch of other helpful utilities that provide a lot of value and decided to share them in documentdb-utils including:</p>

<ul>
<li>The ability to <code>require()</code> other packages when writing server-side scripts</li>
<li>The ability to load all sprocs or UDFs in a directory to all collections in a list. This is incredibly useful when working with multiple partitions.</li>
<li>Mixins for async.js and underscore.js so you can use those JavaScript utility libraries in your sprocs</li>
<li>functions to generate id-based links and arrays of links (incidentally, you can pass in an array of links to many of the WrappedClient methods)</li>
<li>A few other niceties</li>
</ul>

<p>Also, I knew it was possible but I never bothered before to use documentdb-lumenize (aggregations) from a C# .NET project. I&#39;ve done so now and included that documentation and examples.</p>

<p>Anyway, I thought I&#39;d share with this group in case any of you want to check out the upgrades. </p>
]]></content:encoded>
      </item>
      <item>
        <guid>http://blog.lumenize.com/announcing-documentdb-lumenize#16165</guid>
          <pubDate>Fri, 10 Jul 2015 04:19:21 +0300</pubDate>
        <link>http://blog.lumenize.com/announcing-documentdb-lumenize</link>
        <title>Announcing documentdb-lumenize</title>
        <description>An aggregation framework for Microsoft&#39;s Azure DocumentDB NoSQL database</description>
        <content:encoded><![CDATA[<p><strong>The bad news</strong>: DocumentDB does not include aggregation capability.</p>

<p><strong>The good news</strong>: DocumentDB includes stored procedures and documentdb-lumenize uses this to add aggregation capability that far exceeds that which you are used to with SQL.</p>

<p>As <a href="https://en.wikipedia.org/wiki/Michael_Stonebraker">Michael Stonbraker</a>, genius creator of not one but three wildly successful databases (Postgres, Vertica, and VoltDB) said, &quot;It&#39;s better to move the code to the data than the other way around.&quot; VoltDB was designed to execute Java-language ACID transactional stored procedures running in the same memory space as the data with huge performance and consistency benefits. Well, Microsoft Azure&#39;s DocumentDB takes a similar approach except that it&#39;s a NoSQL data store using JSON and you write your stored-procedures in JavaScript (or CoffeeScript in my case).</p>

<p>Using this power, I&#39;ve ported the aggregation engine of the Lumenize library, which I created while working on my PhD at Carnegie Mellon over to run inside of DocumentDB. This instantly upgrades DocumentDB with more powerful declarative aggregation (including full OLAP cube) capability than even the most advanced databases.</p>

<h2 id="a-simple-groupby-example">A simple groupBy example</h2>

<p>Let&#39;s assume this is the only data in your collection.</p>
<div class="highlight"><pre><span></span><span class="p">[</span>
  <span class="p">{</span><span class="nx">id</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="mi">10</span><span class="p">}</span>
  <span class="p">{</span><span class="nx">id</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="mi">100</span><span class="p">}</span>
  <span class="p">{</span><span class="nx">id</span><span class="o">:</span> <span class="mi">2</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="mi">20</span><span class="p">}</span>
  <span class="p">{</span><span class="nx">id</span><span class="o">:</span> <span class="mi">3</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="mi">30</span><span class="p">}</span>
<span class="p">]</span>
</pre></div>
<p>Now, let&#39;s call the cube with the following:</p>
<div class="highlight"><pre><span></span><span class="p">{</span><span class="nx">cubeConfig</span><span class="o">:</span> <span class="p">{</span><span class="nx">groupBy</span><span class="o">:</span> <span class="s1">&#39;id&#39;</span><span class="p">,</span> <span class="nx">field</span><span class="o">:</span> <span class="s2">&quot;value&quot;</span><span class="p">,</span> <span class="nx">f</span><span class="o">:</span> <span class="s2">&quot;sum&quot;</span><span class="p">}}</span>
</pre></div>
<p>After you call the cube stored procedure, you should expect this to be in the  <code>savedCube.cellsAsCSVStyleArray</code> parameter of the response. Note, the _count metric is always calculated even when not specified.</p>
<div class="highlight"><pre><span></span><span class="p">[</span>
  <span class="p">[</span> <span class="err">&#39;id&#39;</span><span class="p">,</span> <span class="err">&#39;_count&#39;</span><span class="p">,</span> <span class="err">&#39;value_sum&#39;</span> <span class="p">],</span>
  <span class="p">[</span>   <span class="mi">1</span><span class="p">,</span>         <span class="mi">2</span><span class="p">,</span>         <span class="mi">110</span> <span class="p">],</span>
  <span class="p">[</span>   <span class="mi">2</span><span class="p">,</span>         <span class="mi">1</span><span class="p">,</span>          <span class="mi">20</span> <span class="p">],</span>
  <span class="p">[</span>   <span class="mi">3</span><span class="p">,</span>         <span class="mi">1</span><span class="p">,</span>          <span class="mi">30</span> <span class="p">]</span>
<span class="p">]</span>
</pre></div>
<h2 id="full-olap-cube-capability">Full OLAP cube capability</h2>

<p>A groupBy is just a one-dimensional OLAP cube and the example above just uses a bit of syntactic sugar to quickly configure this one-dimensional OLAP cube. However, the underlying engine is a fast, light, flexible, declaratively-configured OLAP Cube with powerful hierarchical rollup support. It can be used from node.js projects as well as .NET projects or any other platform using DocumentDB&#39;s REST API.</p>

<p>You can read all about this capability as well as all the details on how to use it on the <a href="https://github.com/lmaccherone/documentdb-lumenize">GitHub page for documentdb-lumenize</a>.</p>

<p>This is still a work in progress, so please give me your feedback.</p>
]]></content:encoded>
      </item>
      <item>
        <guid>http://blog.lumenize.com/announcing-documentdb-mock#15888</guid>
          <pubDate>Mon, 29 Jun 2015 23:37:52 +0300</pubDate>
        <link>http://blog.lumenize.com/announcing-documentdb-mock</link>
        <title>Announcing documentdb-mock</title>
        <description>Mock for testing Stored Procedures in Microsoft Azure&#39;s DocumentDB</description>
        <content:encoded><![CDATA[<p>Microsoft Azure&#39;s DocumentDB is a great PaaS NoSQL database. The killer feature is that you can write stored procedures in JavaScript (CoffeeScript in my case) AND the operations performed in a single run of the stored procedure is contained in an ACID-compliant transaction -- even if the transaction effects more than one document. This means that either all operations are completed or none are and that none of the operations of an incomplete transaction are seen by any other database interaction. Also, to quote VoltDB (similar in design to DoucumentDB except stored procedures are written in Java), &quot;Code is smaller than data. Move the code to the data.&quot; In DocumentDB, the JavaScript is run in the same memory space as the database which provide performance advantages. I will publish my performance findings confirming this shortly.</p>

<p>I use the Node.js client on occasion for inspection or testing, but, knowing the advantages of using stored procedures, I have adopted a pattern of doing all database operations for production code inside of stored procedures.</p>

<p>However, the infrastructure around DocumentDB is not yet mature. A particularly painful aspect of this is that it&#39;s missing a good way to test and debug your stored procedures. Sure, you can attach execution state to the &quot;body&quot; that is returned from the run to see what&#39;s going on, but it would be much easier if you could use your local debugger and write automated tests to confirm the functionality before you pushed your stored procedure to the server.</p>

<p>Luckily, stored procedures are just JavaScript so we can use Node.js to test and debug them. This documentdb-mock package implements a thin mock to enable this testing and debugging.</p>

<p>So, you can find it on npm at <a href="https://www.npmjs.com/package/documentdb-mock">https://www.npmjs.com/package/documentdb-mock</a> or GitHub at <a href="https://github.com/lmaccherone/documentdb-mock">https://github.com/lmaccherone/documentdb-mock</a>. </p>

<p>As always I appreciate input and pull requests.</p>
]]></content:encoded>
      </item>
  </channel>
</rss>