<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="weebly" -->
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" >

<channel><title><![CDATA[Distributed Information System (DIS) - The blog]]></title><link><![CDATA[http://www.disnetwork.info/the-blog.html]]></link><description><![CDATA[The blog]]></description><pubDate>Sat, 12 May 2012 03:29:16 -0800</pubDate><generator>Weebly</generator><item><title><![CDATA[IDR encoding compared to Go language encoding]]></title><link><![CDATA[http://www.disnetwork.info/1/post/2012/05/idr-encoding-compared-to-go-language-encoding.html]]></link><comments><![CDATA[http://www.disnetwork.info/1/post/2012/05/idr-encoding-compared-to-go-language-encoding.html#comments]]></comments><pubDate>Sat, 12 May 2012 03:05:56 -0800</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.disnetwork.info/1/post/2012/05/idr-encoding-compared-to-go-language-encoding.html</guid><description><![CDATA[As the author of the IDR encoding (yet unpublished), I was very curious do see how it compares to the data encoding proposed in the Go language designed by the Google team (gobs of data). There are two fundamental difference between the two. Value encoding  [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style='text-align:left;'>As the author of the IDR encoding (yet unpublished), I was very curious do see how it compares to the data encoding proposed in the Go language designed by the Google team (<a title="" href="http://blog.golang.org/2011/03/gobs-of-data.html">gobs of data</a>). <br /><br /><span>There are two fundamental difference between the two. </span><br /><span></span><br /><span style="font-weight: bold; text-decoration: underline;">Value encoding</span> <br /><span></span><br /><span>Gobs encodes value by a tag byte followed by a compact byte encoding of the value. </span>The tag identifies the type of the value and its encoded byte length. The byte encoding drops trailing 0 bytes of the value.<br /><br /><span>IDR uses the most common computer internal representation </span>of data as encoding and has thus no marshaling work. <br /><br /><span style="font-weight: bold;">Advantages</span> <br /> <br /><span></span><span>Gobs has two major benefits. The first benefit is that the type of data is provided with the value which allows anyone to decode the values of a message without prior knowledge of its content. </span>The second benefit of such encoding is that data can be split in blocs anywhere since decoding is processed byte after byte. <br /><br /><span></span>IDR has the advantage of fast and trivial marshaling as in RPC and IIOP. <br /><br /><span style="font-weight: bold;">Disadventages</span><br /><br /><span></span>The price to pay with Gobs is the additional tag byte and the marshaling work. <span>With IDR, it is the code complexity to ensure the atomicity of the base values </span>if a data stream needs to be split and the absence of base value type information with the data. <br /><span></span><br /><span></span><span style="font-weight: bold; text-decoration: underline;">Type encoding</span> <br /><br /><span>Gobs provides the maximum type information with the message so that it is self describing. This makes the encoding more complex since conciseness competes with expressiveness. </span><br /><br /><span>RPC, IIOP and ICE rely on the context to determine the type of encoded data. </span>The encoding targeting mainly use in communication, this optimization make sense to some extend.<br /><br /><span>IDR precedes any message with a type reference. The type reference is a key to a distributed database similar to the DNS from which a description of the data contained in the message may be obtained. It is possible to obtain a concise form to efficiently parse the data by a program </span>or a detailed expressive form with comments to be used by humans. <br /><br /><span>The IDR data type description strategy seems the most efficient because the data type description is written once. But the decoupling of the type description from the data </span>expose to the risk of loosing access to the data description if it gets deleted. <br /><br /><span style="font-weight: bold; text-decoration: underline;">Conclusion</span><br /><span></span><br /><span>There are some good and bad points on both sides and there is no easy way to merge the good points into a new optimal encoding. </span><br /><br /><span></span><span>My experience is that the IDR encoding, while simple and efficient on some aspects, was quite complex to develop. </span><br /><br /><span></span><span>Today I still favor IDR's choice because of the marshaling efficiency.</span><span> <span style="font-weight: bold;">Olivier Pisano</span> managed to translate the C++ IDR library to the D language in a very short time. So maybe it is just the conception and validation of IDR that took so much time. </span><span></span><br /><span></span><br /><span>I like very much the smart encoding </span>of the base values in Go, but not so much to force all floating point values to be encoded into a double precision float (64bit). I hope they'll change that. <br /><br />There are other differences between IDR and Gob which have not been detailed here. What they have in common is that both may use their encoding to support persistence. IDR may use it with its distributed database. <br /><br /><br /><span></span><br /><span></span> </div>]]></content:encoded></item><item><title><![CDATA[Numbering schema yielding identical lexical and numerical ordering]]></title><link><![CDATA[http://www.disnetwork.info/1/post/2012/02/numbering-schema-yielding-identical-lexical-and-numerical-ordering.html]]></link><comments><![CDATA[http://www.disnetwork.info/1/post/2012/02/numbering-schema-yielding-identical-lexical-and-numerical-ordering.html#comments]]></comments><pubDate>Sat, 04 Feb 2012 02:57:53 -0800</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.disnetwork.info/1/post/2012/02/numbering-schema-yielding-identical-lexical-and-numerical-ordering.html</guid><description><![CDATA[  [...] ]]></description><content:encoded><![CDATA[<span class='imgPusher' style='float:left;height:0px'></span><span style=' float: left; z-index: 10; position: relative; ;clear:left;margin-top:0px;*margin-top:0px'><a><img src="http://www.disnetwork.info/uploads/3/8/0/1/38014/4815516.jpg" style="margin-top: 5px; margin-bottom: 10px; margin-left: 0px; margin-right: 10px; border-width:1px;padding:3px;" alt="Picture" class="galleryImageBorder" /></a><div style="display: block; font-size: 90%; margin-top: -10px; margin-bottom: 10px; text-align: center;"></div></span> <div  class="paragraph editable-text" style=" text-align: left; display: block; ">It may be desirable in some situation to be able to assign a numerical reference (integer) to a resource with the particular property that  the string&nbsp; representation of the reference preserves the numerical ordering. This blog post presents a numbering  method that has this property. <span></span>The proposed numbering schema achieves this goal and avoids adding zero's or spaces in front of the numbers, thus keeping the strings short. The price to pay is that there will  be gaps between the numbering sequence. The numbers in these gaps are  invalid numbers in this numbering schema and may be easily recognized and used for error detection. <br /><br /><span style="font-weight: bold;">The problem</span>: You probably experienced that sorting a list of strings representing the  integer sequence "1", "2", "3", ..., "10", "11", ... "20", "21", ...  yields the weird result "1", "10", "11", ... "2", "20", "21", ... "3",  ... This shows up, for instance, when naming files by numbers. We get this result because strings are sorted in lexicographical order which means they  are ordered by digit value, one by one from left to right. So in a lexicographical  order, "10" is smaller than "2" which is the opposite of the numerical  order. <br /><br />In the situations where this is an unacceptable nuisance we have a set of solutions we could pick one from. <br /><br />Use  a specially crafted sorting algorithm able to detect that it deals with  numbers in ASCII representation instead of text strings. In some context, changing the sorting algorithm is not possible (i.e. file names).&nbsp; <br /><br />  Another possibility is to add some zero's or spaces in front of the number in its  ASCII representation. The problem with this method is to know how many  zero's or spaces should be added. There should be at least as many as the number of digits in the biggest number we need to represent. In some context it is not possible to know the biggest number we will have to dealt with and this introduces a highest value constrain which is preferable to avoid if possible. <br /><br /><span style="font-weight: bold;">The solution</span>:  The proposed solution is to use a numbering schema where we simply add in front the number a digits in the number. For instance the number 234 has 3 digits. This number would then be coded as "<span style="font-weight: bold;">3</span>123" in the proposed schema where the 3 (shown in bold) is added in front of the number.<br /><br /><span>The number is valid if the string contains only digits and the first digit is length minus one. </span>The value 0 is represented as 0. For negative numbers, if you need them, the number of digits must be inserted between the minus sign (-) and the number. <br /><br />There is also an upper limit in the maximum number of digits the number can have. The biggest number that may be represented with this numbering schema is 10 billion minus one.&nbsp; <br /><br /> With this numbering schema, the sequence "1", "2", "3", ..., "10", "11", ... "20", "21" becomes "11", "12", "13", ..., "210", "211", ... "220", "221" with the added digit in front shown in bold. The lexicographical sorting of this number sequence will preserve this order. <br /><br />The  price to pay is that the numbering sequence is not compact. It has gaps containing invalid numbers (i.e. 23, 123,... ). This may be  considered an inconvenient but has also the benefit to make it possible  to detect errors and invalid values. <br /><br /><span></span>Generating such number sequence is trivial as well as checking their validity. <br /><br /><span style="font-weight: bold;">Application example</span>: I "invented" this coding schema when looking for an optimal way to numerically reference resources assigned incrementally for  a web service (i.e. userId, documentId, imageId, ....). The numbering provides a direct mapping with a numerical  table index value as well as a compact string representation. The size of  the reference would grow smoothly as needed with the number of  references. <br /><br /><span>Another application is as document id in NoSQL databases like CouchDB, MongoDB, etc. Keep the id compact and sorted. </span><br /><br /><span style="font-weight: bold;">Using a Base64 like encoding</span><br /><br /><span></span><span>A</span><span> more compact coding would use a base64 like encoding</span>. Conversion between the ASCII and binary encoding would not be as straightforward, but identifiers would be much more compact and still preserve the sorting of ASCII and binary representation. <br /><br />To generate such encoding, split the binary representation in groups of 6 bits, starting from the less significant bit (right most) toward the most significant bit. Then replace all the left most chunks that have all bits to zero with a single chunk coding the number of 6bits chunks left. For instance&nbsp; ...00000|110010|010011 becomes 000010|110010|010011 because there are only two significant chunks in the number and 2 is encoded with 6 bits as 000010. The last step is to replace each 6 bit chunks in the resulting chunk sequence with the ASCII codes provided in the following table. <span></span><br /></div> <hr  style=" clear: both; visibility: hidden; width: 100%; "></hr>  <div ><div class="wsite-image wsite-image-border-thin " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.disnetwork.info/uploads/3/8/0/1/38014/1141398_orig.png" alt="Picture" style="width:100%;max-width:578px" /> </a> <div style="display:block;font-size:90%">Mapping between chunk's 6 bit binary integer value and ASCII letters used for encoding</div> </div></div>  <div  class="paragraph editable-text" style=" text-align: left; ">The resulting encoding is very similar to Base64 encoding but has the particular properties to preserve the sorting order of the chunk integer value and the associated ASCII value as well as using ASCII codes that may be used in URLs or filenames. Except for the value 0, the ASCII representation will never start with a '-'.&nbsp; <br /><br /><span>Conversion between the ASCII representation and the binary representation is more complicated, especially when it has to be done by humans. </span>Though a benefit of this coding is that its ASCII representation will be short for small numbers. The ASCII coding will have n+1 letters for numbers with n significant chunks. For up to 24 bit numbers (over 16 millions values), the longest ASCII encoding will be 5 letters. <span></span><br /><span></span></div>  ]]></content:encoded></item><item><title><![CDATA[Distributed Version Constrol System (DVCS) usage model]]></title><link><![CDATA[http://www.disnetwork.info/1/post/2010/03/development-model-using-distributed-version-constrol-system-dvcs.html]]></link><comments><![CDATA[http://www.disnetwork.info/1/post/2010/03/development-model-using-distributed-version-constrol-system-dvcs.html#comments]]></comments><pubDate>Sun, 28 Mar 2010 04:00:07 -0800</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.disnetwork.info/1/post/2010/03/development-model-using-distributed-version-constrol-system-dvcs.html</guid><description><![CDATA[Subversion has been my software version c [...] ]]></description><content:encoded><![CDATA[<span  style=" position: relative; float: left; z-index: 10; "><a><img src="http://www.disnetwork.info/uploads/3/8/0/1/38014/7510252.jpg" style="margin-top: 5px; margin-bottom: 10px; margin-left: 0px; margin-right: 10px; border-width:1px;padding:3px;" alt="Picture" class="galleryImageBorder" /></a><div style="display: block; font-size: 90%; margin-top: -10px; margin-bottom: 10px; text-align: center;"></div></span><div  class="paragraph" style=" text-align: left; display: block; ">Subversion has been my software version control system for years now. It is simple and straightforward but is inappropriate for some usage patterns that required sharing intermediate development code between developer or combining an official release version track with one or more development tracks. <br /><br />Distributed Version Control Systems with <a href="http://git-scm.com/">Git</a>, <a href="http://mercurial.selenic.com/">Mercurial </a>or <a href="http://bazaar.canonical.com/en/">Bazaar</a> solves these problems. The best way to understand this is by reading Vincent Driessen's blog post titled "<a href="http://nvie.com/git-model">A successful Git branching model</a>". It presents a usage model for Distributed Version Control System (DVCS) using git, but it work as well with Mercurial or Bazaar. <br /><br />The <a href="http://hginit.com/">Mercurial tutorial</a> provided by Joel Spolsky provides a very good introduction which explains why DVCS are better than the centralized version control systems like subversion. <br /><br />I still have to chose between the three. For now my preference is Git for technical reasons. The ergonomic aspect is important too, but fore this I usually rely on desktop integrated tools like <a href="http://code.google.com/p/tortoisegit/">turtoiseGit</a>. I'm currently a very happy user of <a href="http://rabbitvcs.org/">RabitVCS </a>which currently supports only Subversion. I hope they will support Git or Mercurial soon.<br /></div><hr  style=" visibility: hidden; width: 100%; clear: both; "></hr>]]></content:encoded></item><item><title><![CDATA[Log structured database]]></title><link><![CDATA[http://www.disnetwork.info/1/post/2010/03/log-structured-database.html]]></link><comments><![CDATA[http://www.disnetwork.info/1/post/2010/03/log-structured-database.html#comments]]></comments><pubDate>Mon, 01 Mar 2010 04:29:31 -0800</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.disnetwork.info/1/post/2010/03/log-structured-database.html</guid><description><![CDATA[The distributed information system (DIS) n [...] ]]></description><content:encoded><![CDATA[<span  style=" float: left; z-index: 10; position: relative; "><a><img src="http://www.disnetwork.info/uploads/3/8/0/1/38014/695970.jpg" style="margin-top: 5px; margin-bottom: 10px; margin-left: 0px; margin-right: 10px; border-width:1px;padding:3px;" alt="Picture" class="galleryImageBorder" /></a><div style="display: block; font-size: 90%; margin-top: -10px; margin-bottom: 10px; text-align: center;"></div></span><div  class="paragraph" style=" text-align: left; display: block; ">The distributed information system (DIS) needs a database to store its  information and a simple key value database would do the job. Today, <a href="http://1978th.net/tokyocabinet/">Tokyo Cabinet</a> seems the best  choice for such type of database.<br /><br /><span style="font-weight: bold;">Why a log structured database ?</span><br />  <br />My attention was recently caught by the blog post <a title="Links  active once published" href="http://blog.notdot.net/2009/12/Damn-Cool-Algorithms-Log-structured-storage">Damn  cool Algorithms: log structured storage</a>. The white paper presenting  <a href="http://www.rethinkdb.com/papers/whitepaper.pdf">RethinkDB</a>  provides a more exhaustive view of the benefits of this data structure  and some disadvantages too. The LWN.net article <a title="Links active  once published" href="http://lwn.net/Articles/353411/">Log-structured  file systems: There's one in every SSD</a> covers the use of log  structure in SSD file systems.<br /></div><hr  style=" width: 100%; visibility: hidden; clear: both; "></hr><div  class="paragraph" style=" text-align: left; ">While surfing the web to get more informations on log structured database, I found the following blog note presenting the experimental <a href="http://www.lshift.net/blog/2009/08/21/yet-another-key-value-database">YDB</a> log structured database with some interesting benchmark showing that YDB is roughly 5.6 time faster than Tokyo Cabinet and 8 time faster than Berkeley DB with random writes. These numbers justify some deeper investigation.<br /><br />The performance benefit is mainly due to constraining write operations to the end of the file because read access can benefit from memory caches, writes not. With random location writes, the disk writing head needs to move into position (seek) and this has a huge latency compared to transistor state changes or data transmission speed.<br /><br />Reducing disk head movements may thus yield a significant performance increase. Note that this won't be true with SSD disks anymore, but other constrains come in play too where a log structured database may still be attractive (evenly distributed and grouped writes).&nbsp; <br /><br /><span style="font-weight: bold;">The Record Index</span><br /><br />As you may guess writing data to the end of the file implies that modified records are copied. The record offset is then modified which implies an update of the index too. If the index, generally tree structured, is also stored in the log database, it result in cascade of changes which increases the amount of data to write to disk. <br /><br />This makes log structured database less attractive, especially if the index is a BTree of record keys. A BTree key index is not very compact and not trivial to manipulate, especially if keys are of varying length.<br /><br />I finally found a better solution derived from reading the white paper presenting the <a href="http://www.primebase.org/download/pbxt_white_paper.pdf">The PrimeBase XT Transactional Engine</a> describing a log structured table with <a href="http://en.wikipedia.org/wiki/ACID">ACID</a> property for an RDMS table, and more recently the article <a href="http://research.swtch.com/2008/03/using-uninitialized-memory-for-fun-and.html">Using Uninitialized Memory for Fun and Profit</a> describing a simple data structure to use an uninitialized array. <br /><br />The idea is to use an intermediate <span style="font-style: italic;">record index</span> which is basically a table of record offset and size. The entry index in the table is the record identifier and is used as key to locate the record in the file. The record identifier is associated to a record for its life time and may be reused for a new record after the record has been deleted. <br /><br /><span style="font-weight: bold;">Benefits of the record index</span><br /><br />The record index is stored as a tree index where non lead nodes hold the  offset to the lower level nodes of the tree. Changing an offset in a  leaf node will still imply a change in all the nodes up to the root of  the tree, but the index is much more compact than a conventional BTree  associating the record key with its offset and size. The record  identifier doesn't need to be stored in the index because it is its  relative position in it.&nbsp; <br /><br />Another benefit of this intermediate record index is that the record key index will now refer to the record identifier and this doesn't change when the record is modified. It is then possible to have multiple index to the records or to use the record identifier inside the user data to support record reference graphs (i.e. linked lists, etc.).<br /><br />By storing the record identifier along with the record data, the garbage collector or the crash recovery process can easily determine if a record is valid or. It simply has to compare the record offset and size with the one found in the record index. If it is the same, the record is the latest valid version. <br /><br /><span style="font-weight: bold;">Snapshots and recovery points</span><br /><br />The dirty pages of the record index need only to be saved at snapshot time. In case of process or system crash, the database should be restored to the last saved snapshot. A snapshot correspond to a coherent state of the database. A snapshot is saved any time the user closes the database. Restoring the database to some snapshot saved state boils down to truncate the file after the last valid record of the file. <br /><br />If snapshots saving is very frequent and crash recovery very rare, it is possible to use lightweight snapshots. For such snapshot only a small record is appended to the record stream which tags the point in the file where the snapshot occurred. When the database is recovered at some saved snapshot point, the recovery process can continue the recovery process beyond that recovery point by replaying all the changes until the last valid lightweight snapshot. The state of the database can then be restored to the latest lightweight snapshot, but with a slightly bigger effort than a saved snapshot recovery. <br /><br /><span style="font-weight: bold;">Garbage collector</span><br /><br />For the garbage collector (GC) the classical method may be applied which consist in opening a secondary log file and progressively copy valid records into it in background while it is used. A database backup is as simple as copying the file. <br /><br />When the lifetime duration of records varies a lot, it might be better to use generational log files, an algorithm used with memory garbage collector. The idea is to avoid copying constant records due to some other records short lifetime of frequent change generated garbage. The idea is to group records according to their change frequency into separated log structured database.&nbsp; <br /><br />A first log structured database contains all new or changed records. The garbage collector progress then at the same speed as records are written to the end of the file. Every valid data it finds is then copied in a second generation record log file. These records have lasted a GC cycle without a change. Additional generation database may be added for even slower changing records. <br /><br />The use of multiple log files will induce some disk writing head movements, but it will be balanced by saving the effort to repeatedly copy constant records. <br /><br /><span style="font-weight: bold;">Conclusion</span> <br /><br />It is not my intent to implement this shortly. I just wanted to document  the method which seems to be the canonical way to handle the record index  problem and for which I couldn't find a description on the web.<br /> </div>]]></content:encoded></item><item><title><![CDATA[The 8 fallacies of distributed computing]]></title><link><![CDATA[http://www.disnetwork.info/1/post/2009/10/the-8-fallacies-of-distributed-computing.html]]></link><comments><![CDATA[http://www.disnetwork.info/1/post/2009/10/the-8-fallacies-of-distributed-computing.html#comments]]></comments><pubDate>Sat, 17 Oct 2009 09:54:35 -0800</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.disnetwork.info/1/post/2009/10/the-8-fallacies-of-distributed-computing.html</guid><description><![CDATA[The following two paragraphs are the introductory paragraphs of the document Fallacies of distributed computing (pdf) by Arnon Rotem-Gal-Oz that presents the 8 fallacies of distributed computed. "Distributed systems already exist for a long tThe software industry has been writing distributed systems for several decades. Two examples incl [...] ]]></description><content:encoded><![CDATA[<div  class="paragraph" style=" text-align: left; ">The following two paragraphs are the introductory paragraphs of the document <a href="http://www.rgoarchitects.com/Files/fallacies.pdf">Fallacies of distributed computing (pdf)</a> by Arnon Rotem-Gal-Oz that presents the 8 fallacies of distributed computed. <br /><br /><span style="font-style: italic;">"Distributed systems already exist for a long tThe software industry has been writing distributed systems for several decades. Two examples include The US Department of Defense ARPANET (which eventually evolved into the Internet) which was established back in 1969 and the SWIFT protocol (used for money transfers) was also established in the same time frame [Britton2001]. </span><br /> <br /><span style="font-style: italic;"> Nevertheless, In 1994, Peter Deutsch, a sun fellow at the time, drafted 7 assumptions architects and designers of distributed systems are likely to make, which prove wrong in the long run - resulting in all sorts of troubles and pains for the solution and architects who made the assumptions. In 1997 James Gosling added another such fallacy [JDJ2004]. The assumptions are now collectively known as the "The 8 fallacies of distributed computing" [Gosling]:</span><br /><ol style="font-style: italic;"><li>The network is reliable</li><li>Latency is zero</li><li>Bandwidth is infinite</li><li>The network is secure</li><li>Topology doesn't change</li><li>There is one administrator</li><li>Transport cost is zero</li><li>The network is homogeneous</li></ol><span style="font-style: italic;">..."</span><br /><br />While in the process of designing a new distributed information system, it a good idea to check how it position itself regarding these 8 fallacies.<br /><br /><span style="font-weight: bold;">The network is reliable</span><br /><br />DIS uses TCP which was designed to be reliable and robust. Reliable means that data is transmitted uncorrupted to the other end and robust means that it may resist to a certain amount of errors. There is however a limit to the robustness of a TCP connection, and in some conditions connection to a remote service may even not be possible. <br /><br />DITP, the communication protocol of DIS, is of course designed to handle connection failures. Higher level and distributed services will have to take it in account too. <br /><br />Making a distribute information system robust implies to anticipate connection failures at any stage of the communication. For instance, a flock of servers designed to synchronize with each other may suddenly be partitioned in two or more unconnected flocks because of a network failure, and be connected back together later. <br /><br /><span style="font-weight: bold;">The latency is zero</span><br /><br />Latency was a major focus in the design of the DITP protocol because DIS is intended to be used for World Area Network (WAN) applications. DITP reduces latency impact by supporting asynchronous requests. These requests are batched and processes sequentially by the server in the order of emission. If a request in the batch is aborted by an exception, subsequent requests of the batch are ignored. This provides a fundamental functionality to support transactional applications. <br /><br />In addition to this, DIS may also support the ability to send code to be executed by a remote service. This provides the same functionality as JavaScript code embedded in web pages and executed by browsers, allowing to implement powerful and impressive web 2.0 applications. <br /><br />With DIS, remote code execution is taken care by services made available by the server manager if he wants to support them. The services may then process different types of pseudo-codes: JavaScript, Haxe, JVM, Python, ... Many different pseudo-codes services may then coexist and evolve independently of DIS. Such functionality is of course also exposed to security issues. See the secure network fallacy for an insight on how DIS addresses it. <br /><br /><span style="font-weight: bold;">Bandwidth is infinite</span><br /><br />This fallacy is the rational of the Information Data Representation (IDR) design. It uses binary and native data representation. In addition to be very fast and easy to Marshall, it is also very compact. <br /><br />DITP supports also user defined processing of transmitted data so that compression algorithms may be applied to them. DITP is also multiplexing concurrent communication channels in the same connections, allowing to apply different transmitted data processing to each channel. By choosing the channel the user may decide to compress transmitted data or not.&nbsp; <br /><br /><span style="font-weight: bold;">The network is secure</span><br /><br />A distributed system designed for a world wide usage must obviously take security in account. This means securing the transmitted data by mean of authentication and cyphering, as well as authenticating communicating parties and enforce access or action restriction rules. <br /><br />Communication security is provided by the DITP protocol by mean of the user specified transmitted data processing. As data compression, these can also handle data authentication and cyphering. Different authentication and cyphering methods and algorithms can coexist in DIS and may evolve independently of the DITP protocol. <br /><br />Authentication and access control may use conventional passwords methods as well as user identification certificates. But instead of using x509 certificates, DIS uses IDR encoded certificates corresponding to instances of certificate classes. Users may then derive their own certificates with class inheritance. They may extend the information carried in the certificate or combine different certificate types together. <br /><br />An authentication based on password checking or user identity certificate matching doesn't scale well for a world wide distributed system because they need to access a reference database. With distributed services, accessing a remote database introduces latencies and replicating it (i.e. caches) weakens its security by multiplying the number breach points. <br /><br />The authentication mechanism favored in DIS uses member certificates. These certificates are like club or company member access cards. When trying to access a service, the user present the corresponding certificate and the service needs simply to check the certificate validity. <br /><br />With such authentication mechanism, the service can be scattered all over the Internet and remain lightweight as is required for embedded applications (i.e. smart phones, car computers, ...). The authentication domain can also handle billions of members as well and easily as a few ones. Member certificates may be extended to carry specific informations and connection parameters. <br /><br /><span style="font-weight: bold;">Topology doesn't change</span><br /><br />The ability to handle network topology changes initiated the conception of DIS in 1992. It is thus designed from the start to address this issue in a simple, robust and efficient way. It is not a coincidence that the DIS acronym resembles the one of DNS. DIS is a distributed information system as the DNS is a distributed naming system. DIS uses the proven architecture of the DNS and applies it to generic information with additional functionalities like allowing to remotely manage the information. The DNS is known to be a corner stone of the network topology change solution, as will be DIS. <br /><br /><span style="font-weight: bold;">There is one administrator</span><br /><br />As the DNS, DIS supports a distributed administration. Information domain administrator have full liberty and authority in the way they organize and manage their information domain as long as the interface to DIS respects some standard rules. As for the DNS, there will be a central administration that defines the operational rules and control their application. If DIS becomes a broadly adopted system, the central administration will be composed of members elected democratically and coordinated with the Internet governance administration if such structures happens to be created. <br /><br /><span style="font-weight: bold;">Transport cost is zero</span><br /><br />The transport cost is indeed not zero but most of it is distributed and shared by the users. There remains however a residual cost for the central services and administration for which a revenue has to be identified. The DIS system will allow to obtain such a revenue and there is a rational reason why it ought to. <br /><br />Imposing a financial cost to some domains or features of DIS which are limited or artificially limited resources provides a mean to apply a perceptible pressure on its misbehaving users (i.e. spam). <br /><br /><span style="font-weight: bold;">The network is homogeneous</span><br /><br />DITP is designed to support different types of underlying transport connections. The information published in DIS is treated like an opaque byte block and may be of any type as well as its description language. It may be XML with its DTD description, binary with C like description syntax, python pickles or anything else. Of course it will also contain IDR encoded information with its Information Type Description. <br /><br /><span style="font-weight: bold;">Conclusion</span><br /><br />The conclusion is that DIS, DITP and IDR have been designed without falling on any of the common fallacies. This is partly due to the long maturation process of its conception. While this may be considered as a shortcoming, it may also be its strength since it allowed to examine all aspects wisely with time.<br /></div>]]></content:encoded></item><item><title><![CDATA[A Distributed Information System ? Nice, but what for ? ]]></title><link><![CDATA[http://www.disnetwork.info/1/post/2009/09/recommended-reading-snakes-on-the-web.html]]></link><comments><![CDATA[http://www.disnetwork.info/1/post/2009/09/recommended-reading-snakes-on-the-web.html#comments]]></comments><pubDate>Sat, 05 Sep 2009 05:16:06 -0800</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.disnetwork.info/1/post/2009/09/recommended-reading-snakes-on-the-web.html</guid><description><![CDATA[Here is a (long) blog note I would recommend reading : "Snakes on the web" written by Jackob Kaplan-Moss                                           (September 4, 2009). It is a talk given at PyCon Argentina and PyCon Brazil,&nbsp;2009.It presents an analysis on the current situation of web edition and desirable future system properties. My impression, and this i [...] ]]></description><content:encoded><![CDATA[<div  class="paragraph" style=" text-align: left; ">Here is a (long) blog note I would recommend reading : <a href="http://jacobian.org/writing/snakes-on-the-web/">"Snakes on the web</a>" written by Jackob Kaplan-Moss                                           (September 4, 2009). It is a talk given at PyCon Argentina and PyCon Brazil,&nbsp;2009.<br /><br />It presents an analysis on the current situation of web edition and desirable future system properties. <br /><br />My impression, and this is not a coincidence, is that DIS matches most of these requirements since it was designed to address the short comings of the actual systems.<br /></div>]]></content:encoded></item><item><title><![CDATA[DITP and The black triangle]]></title><link><![CDATA[http://www.disnetwork.info/1/post/2009/07/ditp-and-the-black-triangle.html]]></link><comments><![CDATA[http://www.disnetwork.info/1/post/2009/07/ditp-and-the-black-triangle.html#comments]]></comments><pubDate>Sat, 11 Jul 2009 01:39:34 -0800</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.disnetwork.info/1/post/2009/07/ditp-and-the-black-triangle.html</guid><description><![CDATA[A hacker news submission references the "The black triangle" blog note. I can only backup the author since I have experienced this many time. For short, with some programs the visible part of it is merely just a black triangle while the invisible part may be complex or required a lot of efforts to achieve. The black triangle is then gen [...] ]]></description><content:encoded><![CDATA[<p  style=" text-align: left; ">A <a href="http://news.ycombinator.com/news">hacker news</a> submission references the "<a href="http://rampantgames.com/blog/2004/10/black-triangle.html">The black triangle</a>" blog note. I can only backup the author since I have experienced this many time. <br /><br />For short, with some programs the visible part of it is merely just a black triangle while the invisible part may be complex or required a lot of efforts to achieve. The black triangle is then generally just a simple visual example to prove that the underlying system works. <br /><br />That is the state of progress of DITP. I'm working to get the black triangle to become visible. In doing so I'm also writing the protocol specification so that the protocol may be reviewed and implemented by third parties in other languages or libraries.<br /><br />The black triangle is like the first fruits of a fruiterer tree that may, sometime, took a long time to grow up to the point to be able to produce fruits.<br /><br /></p>]]></content:encoded></item><item><title><![CDATA["A note on distributed computing" (1994)]]></title><link><![CDATA[http://www.disnetwork.info/1/post/2009/07/a-note-on-distributed-computing-1994.html]]></link><comments><![CDATA[http://www.disnetwork.info/1/post/2009/07/a-note-on-distributed-computing-1994.html#comments]]></comments><pubDate>Tue, 07 Jul 2009 13:40:15 -0800</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.disnetwork.info/1/post/2009/07/a-note-on-distributed-computing-1994.html</guid><description><![CDATA["A note on distributed computing"Jim Waldo, Geoff Wyant, Ann Wollrath, Sam Kendall. Nov 1994.Abstract:We argue that objects that interact in a distributed system need to be dealt with in ways that are intrinsically differe [...] ]]></description><content:encoded><![CDATA[<p  style=" text-align: left; "><a href="http://research.sun.com/techrep/1994/smli_tr-94-29.pdf"><br />"A note on distributed computing"</a><br /><br />Jim Waldo, Geoff Wyant, Ann Wollrath, Sam Kendall. Nov 1994.<br /><br /><span style="font-style: italic; font-weight: bold;">Abstract:</span><span style="font-style: italic;"><br /><br />We argue that objects that interact in a distributed system need to be dealt with in ways that are</span> <span style="font-style: italic;">intrinsically different from objects that interact in a single address space. These differences are </span><span style="font-style: italic;">required because distributed systems require that the programmer be aware of latency, have a different </span><span style="font-style: italic;">model of memory access, and take into account issues of concurrency and partial failure.<br /><br /><span style="font-style: italic;">We look at a number of distributed systems that have attempted to paper over the distinction</span> <span style="font-style: italic;">between local and remote objects, and show that such systems fail to support basic requirements </span><span style="font-style: italic;">of robustness and reliability. These failures have been masked in the past by the small size of the </span><span style="font-style: italic;">distributed systems that have been built. In the enterprise-wide distributed systems foreseen in the </span><span style="font-style: italic;">near future, however, such a masking will be impossible.<br /><br /><span style="font-style: italic;">We conclude by discussing what is required of both systems-level and application-level programmers</span> <span style="font-style: italic;">and designers if one is to take distribution seriously.</span><br /><br /></span></span></p>]]></content:encoded></item><item><title><![CDATA[What is wrong with HTTP ?]]></title><link><![CDATA[http://www.disnetwork.info/1/post/2009/06/what-is-wrong-with-http.html]]></link><comments><![CDATA[http://www.disnetwork.info/1/post/2009/06/what-is-wrong-with-http.html#comments]]></comments><pubDate>Thu, 25 Jun 2009 01:43:05 -0800</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.disnetwork.info/1/post/2009/06/what-is-wrong-with-http.html</guid><description><![CDATA[Here is a document presenting a review on what is good an bad with HTTP. It provides some light on the choices I made for DIS. I couldn't identify the author's name in the text. Sorry.&nbsp; What is wrong with HTTP ?In this essay, the first of a pair on browser  [...] ]]></description><content:encoded><![CDATA[<p  style=" text-align: left; ">Here is a document presenting a review on what is good an bad with HTTP. It provides some light on the choices I made for DIS. I couldn't identify the author's name in the text. Sorry.&nbsp; <br /><a href="http://lists.canonical.org/pipermail/kragen-tol/2006-November/000841.html"><br /><span style="font-weight: bold; font-style: italic;">What is wrong with HTTP ?</span></a><br /><br /><span style="font-style: italic;">In this essay, the first of a pair on browser apps, I explore how</span><span style="font-style: italic;"> they are better than traditional desktop apps in some ways, but</span><span style="font-style: italic;"> worse in others.  Some of the disadvantages of browser apps are</span><span style="font-style: italic;"> deeply rooted in the use of HTTP URLs for naming.  In the second</span><span style="font-style: italic;"> essay, I will present a design sketch for a new platform, a</span><span style="font-style: italic;">re placement for HTTP combining both styles' advantages.</span><span style="font-style: italic;">Right now, we're seeing a massive shift to browser apps, largely</span><span style="font-style: italic;"> server-side browser apps.  As I warned in "People, places, things,</span><span style="font-style: italic;">and ideas," [18] this move to server-side browser apps imperils</span><span style="font-style: italic;"> our software freedom; I outlined how to solve this problem in "The </span><span style="font-style: italic;">equivalent of free software for online services."  [19] This pair </span><span style="font-style: italic;">of essays represents more detail on this problem and proposed </span><span style="font-style: italic;">solution.</span><br /><br /><a href="http://lists.canonical.org/pipermail/kragen-tol/2006-November/000841.html">read more ...</a><br /><br /></p>]]></content:encoded></item><item><title><![CDATA[Median value selection algorithm]]></title><link><![CDATA[http://www.disnetwork.info/1/post/2009/06/median-value-selection-algorithm.html]]></link><comments><![CDATA[http://www.disnetwork.info/1/post/2009/06/median-value-selection-algorithm.html#comments]]></comments><pubDate>Tue, 09 Jun 2009 13:11:15 -0800</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.disnetwork.info/1/post/2009/06/median-value-selection-algorithm.html</guid><description><![CDATA[At work I'm currently working on tomographic reconstruction algorithms. I have to implement a Bayesian iterative algorithm that requires to select the median value in a set of the 27 float values from a cube of 3x3x3 voxels. This operation must be performed for each voxel and for each iteration. We have to expect 256 million voxels to process for each iteration, but "only" 60 to 100 iterations. Trying to find the most efficient algorithm I came up with [...] ]]></description><content:encoded><![CDATA[<p  style=" text-align: left; ">At work I'm currently working on tomographic reconstruction algorithms. I have to implement a Bayesian iterative algorithm that requires to select the median value in a set of the 27 float values from a cube of 3x3x3 voxels. This operation must be performed for each voxel and for each iteration. We have to expect 256 million voxels to process for each iteration, but "only" 60 to 100 iterations. <br /><br />Trying to find the most efficient algorithm I came up with a new algorithm considering the one described on the <a href="http://en.wikipedia.org/wiki/Selection_algorithm.">select algorithm page of wikipedia</a>. I then submitted a question on <a href="http://stackoverflow.com/questions/810657/fastest-code-c-c-to-select-the-median-in-a-set-of-27-floating-point-values">StackOverflow</a> to get some feedback. And I did get valuable feedback. I was first pointed to the C++ nth_element function I didn't know at the time. It was also suggest to optimize by sharing intermediate information which is indeed a smart thing to do to get a better initial guess on the median value. <br /><br />After multiple tests and changes to the code I finally reached what seem to be a very efficient algorithm. The ratio is so good that I'm still unsure about it, but I checked everything. It could be due to memory cache or particularly favorable parallelization opportunities with sse instructions. I don't know. <br /><br />Here is the outline of the algorithm. We have 27 values and have to find the value that split the set in two with 13 values smaller or equal to it and 13 values bigger or equal to it. This value is called the median value. <br /><br />The fundamental idea of the algorithm is to use a heap data structure which has its smallest or biggest value at the top. Such data structure is very efficient for adding an element or to extract its top most element. It can also be very easily mapped into an array. <br /><br />The algorithm uses two heaps initially empty, with a common top value which is the median value. Each heap has a capacity of at most 14 elements, where one is common to the two heaps, their top value and also the median value.<br />The algorithm proceed in two phases. In the first phase, the algorithm picks a value as initial median value guess. Subsequent values are then compare with this median value and added to the corresponding heap until one heap becomes full and contains 14 elements. <br /><br />At this point the median value is a value in the full heap or in the remaining set of values to process. The second phase of the algorithm then starts where the remaining values are processed. Values that would not be inserted in the full heap are ignored. The other values are inserted in the full heap after deleting its top most value. The heap then gets a new top most value and thus also a new median value. When all the remaining elements have been processed, the median of the 27 value set is the top most value of the full heap. <br /><br />Here are some benchmark results. See <a href="http://stackoverflow.com/questions/810657/fastest-code-c-c-to-select-the-median-in-a-set-of-27-floating-point-values">StackOverflow</a> for more detailed information.<br /><br /><span>HeapSort</span><span> &nbsp; &nbsp;&nbsp; &nbsp; </span><span>:</span><span>2.287</span><span>&nbsp; <br /></span><span>QuickSort</span><span> &nbsp; &nbsp;&nbsp;&nbsp; </span><span>:</span><span>2.297</span><span>&nbsp; </span><span><br />QuickMedian1 </span><span>:</span><span>0.967&nbsp; </span><span><br />HeapMedian1 &nbsp;</span><span>:</span><span>0.858</span><span>&nbsp; <br /></span><span>NthElement</span><span> &nbsp;&nbsp;&nbsp; </span><span>:</span><span>0.616</span><span>&nbsp; </span><span><br />QuickMedian2 </span><span>:</span><span>1.178</span><span>&nbsp; </span><span><br />HeapMedian2 &nbsp;</span><span>:</span><span>0.597</span><span>&nbsp; </span><span><br />HeapMedian3 &nbsp;</span><span>:</span><span>0.015</span><span>&nbsp; </span><span>&lt;--</span><span> best</span><br /><br />It thus seem that HeapMedian3 is 33 times faster than NthElement. I used a 3GHz Intel E8400 processor and the Intel C++ compiler with options -03 and -xS for benchmarking. <br /><br />Here is the code :<br /><br /><span>// return the median value in a vector of 27 floats pointed to by a</span><span><br />float</span><span> heapMedian3</span><span>( </span><span>float</span><span>*</span><span>a </span><span>)<br /></span><span>{</span><span><br />&nbsp; &nbsp;</span><span>float</span><span> left</span><span>[</span><span>14</span><span>],</span><span> right</span><span>[</span><span>14</span><span>],</span><span> median</span><span>,</span><span>*</span><span>p</span><span>;</span><span><br />&nbsp; &nbsp;</span><span>unsigned</span><span> char</span><span> nLeft</span><span>,</span><span> nRight</span><span>;</span><span><br /><br />&nbsp; &nbsp;</span><span>// pick first value as median candidate</span><span><br />&nbsp; &nbsp;p </span><span>=</span><span> a</span><span>;</span><span><br />&nbsp; &nbsp;median </span><span>=</span><span> *</span><span>p</span><span>++;</span><span><br />&nbsp; &nbsp;nLeft </span><span>=</span><span> nRight </span><span>=</span><span>1</span><span>;</span><span><br /><br />&nbsp; &nbsp;</span><span>for</span><span>(;;)</span><span><br />&nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp;</span><span>// get next value</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp;</span><span>float</span><span> val </span><span>= </span><span>*</span><span>p</span><span>++;</span><span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp;</span><span>// if value is smaller than median, append to left heap</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp;</span><span>if</span><span>(</span><span> val </span><span>&lt;</span><span> median </span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>// move biggest value to the heap top</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>unsigned</span><span> char</span><span> child </span><span>=</span><span> nLeft</span><span>++,</span><span> parent </span><span>= </span><span>(</span><span>child </span><span>-</span><span>1</span><span>)</span><span>/</span><span>2</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>while</span><span>(</span><span> parent </span><span>&amp;&amp;</span><span> val </span><span>&gt;</span><span> left</span><span>[</span><span>parent</span><span>]</span><span> )</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;left</span><span>[</span><span>child</span><span>]</span><span> =</span><span> left</span><span>[</span><span>parent</span><span>];</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;child </span><span>=</span><span> parent</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;parent </span><span>=</span><span>(</span><span>parent </span><span>-</span><span>1</span><span>)</span><span>/</span><span>2</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;left</span><span>[</span><span>child</span><span>]</span><span> =</span><span> val</span><span>;</span><span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>// if left heap is full</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>if</span><span>(</span><span> nLeft </span><span>== </span><span>14</span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>// for each remaining value</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>for</span><span>(</span><span> unsigned</span><span> char</span><span> nVal </span><span>=</span><span> 27</span><span>-</span><span>(</span><span>p </span><span>-</span><span> a</span><span>);</span><span> nVal</span><span>;</span><span> --</span><span>nVal </span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>// get next value</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;val </span><span>=</span><span> *</span><span>p</span><span>++;</span><span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>// if value is to be inserted in the left heap</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>if</span><span>(</span><span> val </span><span>&lt;</span><span> median </span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;child </span><span>=</span><span> left</span><span>[</span><span>2</span><span>] </span><span>&gt;</span><span> left</span><span>[</span><span>1</span><span>] </span><span>? </span><span>2 </span><span>: </span><span>1</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>if</span><span>(</span><span> val </span><span>&gt;=</span><span> left</span><span>[</span><span>child</span><span>]</span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;median </span><span>=</span><span> val</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>else</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;median </span><span>=</span><span> left</span><span>[</span><span>child</span><span>];</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;parent </span><span>=</span><span> child</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;child </span><span>=</span><span> parent</span><span>*</span><span>2</span><span> + </span><span>1</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>while</span><span>(</span><span> child </span><span>&lt;</span><span>14</span><span> )</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>if</span><span>(</span><span> child </span><span>&lt;</span><span> 13 </span><span>&amp;&amp;</span><span> left</span><span>[</span><span>child</span><span>+</span><span>1</span><span>]</span><span> &gt;</span><span> left</span><span>[</span><span>child</span><span>] </span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>++</span><span>child</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>if</span><span>(</span><span> val </span><span>&gt;=</span><span> left</span><span>[</span><span>child</span><span>] </span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>break</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;left</span><span>[</span><span>parent</span><span>]</span><span> =</span><span> left</span><span>[</span><span>child</span><span>];</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;parent </span><span>=</span><span> child</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;child </span><span>=</span><span> parent</span><span>*</span><span>2</span><span> + </span><span>1</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;left</span><span>[</span><span>parent</span><span>]</span><span> =</span><span> val</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>return</span><span> median</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp;</span><span>// else append to right heap</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp;</span><span>else</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>// move smallest value to the heap top</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>unsigned</span><span> char</span><span> child </span><span>=</span><span> nRight</span><span>++,</span><span> parent </span><span>=</span><span> (</span><span>child </span><span>-</span><span>1</span><span>)</span><span>/</span><span>2</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>while</span><span>(</span><span> parent </span><span>&amp;&amp;</span><span> val </span><span>&lt;</span><span> right</span><span>[</span><span>parent</span><span>]</span><span> )</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;right</span><span>[</span><span>child</span><span>] </span><span>=</span><span> right</span><span>[</span><span>parent</span><span>];</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;child </span><span>=</span><span> parent</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;parent </span><span>=</span><span> (</span><span>parent </span><span>-</span><span>1</span><span>)</span><span>/</span><span>2</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;right</span><span>[</span><span>child</span><span>]</span><span> =</span><span> val</span><span>;</span><span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>// if right heap is full</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>if</span><span>(</span><span> nRight </span><span>==</span><span> 14 </span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>// for each remaining value</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>for</span><span>(</span><span> unsigned</span><span> char</span><span> nVal </span><span>=</span><span> 27</span><span>-</span><span>(</span><span>p </span><span>-</span><span> a</span><span>);</span><span> nVal</span><span>;</span><span> --</span><span>nVal </span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>// get next value</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;val </span><span>= </span><span>*</span><span>p</span><span>++;</span><span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>// if value is to be inserted in the right heap</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>if</span><span>(</span><span> val </span><span>&gt;</span><span> median </span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;child </span><span>=</span><span> right</span><span>[</span><span>2</span><span>]</span><span> &lt;</span><span> right</span><span>[</span><span>1</span><span>]</span><span> ?</span><span> 2</span><span> :</span><span> 1</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>if</span><span>(</span><span> val </span><span>&lt;=</span><span> right</span><span>[</span><span>child</span><span>] </span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;median </span><span>=</span><span> val</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>else</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;median </span><span>=</span><span> right</span><span>[</span><span>child</span><span>];</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;parent </span><span>=</span><span> child</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;child </span><span>=</span><span> parent</span><span>*</span><span>2</span><span> +</span><span> 1</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>while</span><span>(</span><span> child </span><span>&lt;</span><span>14 </span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>{</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>if</span><span>(</span><span> child </span><span>&lt;</span><span> 13</span><span> &amp;&amp;</span><span> right</span><span>[</span><span>child</span><span>+</span><span>1</span><span>] </span><span>&lt;</span><span> right</span><span>[</span><span>child</span><span>] </span><span>)</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>++</span><span>child</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>if</span><span>(</span><span> val </span><span>&lt;=</span><span> right</span><span>[</span><span>child</span><span>]</span><span> )</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>break</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;right</span><span>[</span><span>parent</span><span>]</span><span> =</span><span> right</span><span>[</span><span>child</span><span>];</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;parent </span><span>=</span><span> child</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;child </span><span>=</span><span> parent</span><span>*</span><span>2 </span><span>+ </span><span>1</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;right</span><span>[</span><span>parent</span><span>]</span><span> =</span><span> val</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>return</span><span> median</span><span>;</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp; &nbsp; &nbsp;</span><span>}</span><span><br />&nbsp; &nbsp;</span><span>}<br /></span><span>}</span><br /><br /></p>]]></content:encoded></item></channel></rss>

