UNPKG

13.7 kBHTMLView Raw
1<!DOCTYPE html> <html> <head> <title>LoggableToWrite.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="ByteIterable.html"> ByteIterable.coffee </a> <a class="source" href="ByteIterator.html"> ByteIterator.coffee </a> <a class="source" href="ArrayByteIterable.html"> ArrayByteIterable.coffee </a> <a class="source" href="ByteIterableBase.html"> ByteIterableBase.coffee </a> <a class="source" href="ByteIterableUtil.html"> ByteIterableUtil.coffee </a> <a class="source" href="LightOutputStream.html"> LightOutputStream.coffee </a> <a class="source" href="StoreConfiguration.html"> StoreConfiguration.coffee </a> <a class="source" href="Reader.html"> Reader.coffee </a> <a class="source" href="Writer.html"> Writer.coffee </a> <a class="source" href="List.html"> List.coffee </a> <a class="source" href="ListNode.html"> ListNode.coffee </a> <a class="source" href="Cursor.html"> Cursor.coffee </a> <a class="source" href="DatabaseRoot.html"> DatabaseRoot.coffee </a> <a class="source" href="Environment.html"> Environment.coffee </a> <a class="source" href="EnvironmentConfig.html"> EnvironmentConfig.coffee </a> <a class="source" href="Store.html"> Store.coffee </a> <a class="source" href="Transaction.html"> Transaction.coffee </a> <a class="source" href="Addr64.html"> Addr64.coffee </a> <a class="source" href="DataIterator.html"> DataIterator.coffee </a> <a class="source" href="Log.html"> Log.coffee </a> <a class="source" href="LogCache.html"> LogCache.coffee </a> <a class="source" href="LogConfig.html"> LogConfig.coffee </a> <a class="source" href="LogUtil.html"> LogUtil.coffee </a> <a class="source" href="Loggable.html"> Loggable.coffee </a> <a class="source" href="LoggableFactory.html"> LoggableFactory.coffee </a> <a class="source" href="LoggableIterator.html"> LoggableIterator.coffee </a> <a class="source" href="LoggableToWrite.html"> LoggableToWrite.coffee </a> <a class="source" href="NullLoggable.html"> NullLoggable.coffee </a> <a class="source" href="RandomAccessByteIterable.html"> RandomAccessByteIterable.coffee </a> <a class="source" href="RandomAccessLoggable.html"> RandomAccessLoggable.coffee </a> <a class="source" href="RandomAccessLoggableIterator.html"> RandomAccessLoggableIterator.coffee </a> <a class="source" href="StackList.html"> StackList.coffee </a> <a class="source" href="CompoundByteIterable.html"> CompoundByteIterable.coffee </a> <a class="source" href="CompoundByteIteratorBase.html"> CompoundByteIteratorBase.coffee </a> <a class="source" href="CompressedUnsignedLongByteIterable.html"> CompressedUnsignedLongByteIterable.coffee </a> <a class="source" href="FixedLengthByteIterable.html"> FixedLengthByteIterable.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> LoggableToWrite.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="nv">fs = </span><span class="nx">require</span> <span class="s1">&#39;fs&#39;</span>
2<span class="nv">Loggable = </span><span class="p">(</span><span class="nx">require</span> <span class="s1">&#39;./Loggable.coffee&#39;</span><span class="p">).</span><span class="nx">Loggable</span>
3<span class="nv">CompressedUnsignedLongByteIterable =</span>
4 <span class="p">(</span><span class="nx">require</span> <span class="s1">&#39;./iterate/CompressedUnsignedLongByteIterable.coffee&#39;</span><span class="p">).</span>
5 <span class="nx">CompressedUnsignedLongByteIterable</span>
6<span class="nv">UnsupportedOperationError =</span>
7 <span class="p">(</span><span class="nx">require</span> <span class="s1">&#39;../errors/UnsupportedOperationError.coffee&#39;</span><span class="p">).</span>
8 <span class="nx">UnsupportedOperationError</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>This class allows to create blocks of data - logables - and write them to log,
9using WriteIterator.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">class</span> <span class="nx">LoggableToWrite</span> <span class="k">extends</span> <span class="nx">Loggable</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>@private</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">type: </span><span class="kc">undefined</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>@private</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">data: </span><span class="kc">undefined</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>@private</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">structureId: </span><span class="kc">undefined</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Constructor.</p>
10
11<p>@param type the type of loggable.
12@param data the ByteIterable with data.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">@create$int</span><span class="nv">$ByteIterable: </span><span class="nf">(type, data, o) -&gt;</span>
13 <span class="k">return</span> <span class="nx">LoggableToWrite</span><span class="p">.</span><span class="nx">create$int$ByteIterable$int</span> <span class="nx">type</span><span class="p">,</span> <span class="nx">data</span><span class="p">,</span>
14 <span class="nx">Loggable</span><span class="p">.</span><span class="nx">NO_STRUCTURE_ID</span><span class="p">,</span> <span class="nx">o</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Constructor.</p>
15
16<p>@param type the type of loggable.
17@param data the ByteIterable with data.
18@param structureId.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">@create$int$ByteIterable</span><span class="nv">$int: </span><span class="nf">(type, data, structureId, o) -&gt;</span>
19 <span class="k">if</span> <span class="o">!</span><span class="nx">o</span><span class="o">?</span> <span class="k">then</span> <span class="nv">o = </span><span class="k">new</span> <span class="nx">LoggableToWrite</span>
20 <span class="nv">o.type = </span><span class="nx">type</span>
21 <span class="nv">o.data = </span><span class="nx">data</span>
22 <span class="nv">o.structureId = </span><span class="nx">structureId</span>
23 <span class="k">return</span> <span class="nx">o</span>
24
25 <span class="nv">getAddress: </span><span class="nf">() -&gt;</span>
26 <span class="k">throw</span> <span class="k">new</span> <span class="nx">UnsupportedOperationError</span><span class="p">(</span><span class="s2">&quot;Loggable for writing has&quot;</span> <span class="o">+</span>
27 <span class="s2">&quot; no address until it is written to log&quot;</span><span class="p">);</span>
28
29 <span class="nv">getType: </span><span class="p">()</span> <span class="o">=&gt;</span>
30 <span class="k">return</span> <span class="nx">@type</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Get length.</p>
31
32<p>@return the length of the whole loggable, including header and data.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">length: </span><span class="p">()</span> <span class="o">=&gt;</span>
33 <span class="k">return</span> <span class="nx">@data</span><span class="p">.</span><span class="nx">length</span> <span class="o">+</span>
34 <span class="nx">CompressedUnsignedLongByteIterable</span><span class="p">.</span><span class="nx">getCompressedSize$int</span><span class="p">(</span><span class="nx">@type</span><span class="p">)</span> <span class="o">+</span>
35 <span class="nx">CompressedUnsignedLongByteIterable</span><span class="p">.</span><span class="nx">getCompressedSize$int</span><span class="p">(</span><span class="nx">@structureId</span><span class="p">)</span> <span class="o">+</span>
36 <span class="nx">CompressedUnsignedLongByteIterable</span><span class="p">.</span><span class="nx">getCompressedSize$int</span><span class="p">(</span><span class="nx">@data</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span>
37
38 <span class="nv">getData: </span><span class="nf">() -&gt;</span>
39 <span class="k">return</span> <span class="nx">@data</span>
40
41 <span class="nv">getDataLength: </span><span class="nf">() -&gt;</span>
42 <span class="k">return</span> <span class="nx">@data</span><span class="p">.</span><span class="nx">length</span>
43
44 <span class="nv">getStructureId: </span><span class="nf">() -&gt;</span>
45 <span class="k">return</span> <span class="nx">@structureId</span>
46
47<span class="nv">exports.LoggableToWrite = </span><span class="nx">LoggableToWrite</span>
48
49</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
\No newline at end of file