{"id":4872,"date":"2023-02-07T14:59:26","date_gmt":"2023-02-07T13:59:26","guid":{"rendered":"https:\/\/launix.de\/launix\/?p=4872"},"modified":"2023-03-02T10:26:44","modified_gmt":"2023-03-02T09:26:44","slug":"accessing-memcp-via-scheme","status":"publish","type":"post","link":"https:\/\/launix.de\/launix\/en\/accessing-memcp-via-scheme\/","title":{"rendered":"Accessing MemCP via scheme"},"content":{"rendered":"\n<p>MemCPs native access technology is the scheme scripting language.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>In scheme, you can do functional programming with scheme. This is an example scheme terminal session in MemCP:<\/p>\n\n\n\n<pre><font color=\"#26A269\"><b>carli@launix-MS-7C51<\/b><\/font>:<font color=\"#12488B\"><b>~\/projekte\/memcp<\/b><\/font>$ make &amp;&amp; .\/memcp \ngo build\nmemcp Copyright (C) 2023   Carl-Philip H\u00e4nsch\n    This program comes with ABSOLUTELY NO WARRANTY;\n    This is free software, and you are welcome to redistribute it\n    under certain conditions;\nWelcome to memcp\nHallo World\nMySQL server listening on port 3307 (connect with mysql -P 3307 -u user -p)\nlistening on http:\/\/localhost:4321\n<font color=\"#26A269\">&gt;<\/font> (createdatabase \"test\")\n<font color=\"#C01C28\">=<\/font> \"ok\"\n<font color=\"#26A269\">&gt;<\/font> (createtable \"test\" \"foo\" '('(\"bar\" \"int\" '() \"\")))\n<font color=\"#C01C28\">=<\/font> \"ok\"\n<font color=\"#26A269\">&gt;<\/font> (insert \"test\" \"foo\" '(\"bar\" 12))\n<font color=\"#C01C28\">=<\/font> \"ok\"\n<font color=\"#26A269\">&gt;<\/font> (scan \"test\" \"foo\" (lambda () true) (lambda (bar) (print \"bar=\" bar)))\nbar=12\n<font color=\"#C01C28\">=<\/font> \"47.631\u00b5s\"\n<font color=\"#26A269\">&gt;<\/font>  \n<\/pre>\n\n\n\n<p>As you can see, MemCP has some functions like <code>createdatabase<\/code>, <code>createtable<\/code>, <code>insert<\/code> and <code>scan<\/code>. Whereof which the first three are straight forward while <code>scan<\/code> is the interesting part:<\/p>\n\n\n\n<p>The interface of <code>scan<\/code> is the following:<\/p>\n\n\n\n<p><code>(scan schema table filterfn mapfn [reducefn [default]])<\/code><\/p>\n\n\n\n<p>The interesting part is <code>filterfn<\/code>. In the filter function, you specify the condition that must apply on a dataset in order to be scanned. An example for a filter function might be <code>(lambda (ID) (equal? ID 34))<\/code>. This would only scan entries that have an <code>ID<\/code> equal to <code>34<\/code>. <\/p>\n\n\n\n<p>The arguments of the filter function represent the columns of the table. <em>This means, in a columnar storage, in order to find out the items whose conditions fit the scan condition, only the specified columns have to be opened.<\/em><\/p>\n\n\n\n<p>The same applies for the map function. Inside the map function, you can compute whatever you want to take away from the scanned row. This might be a single value, this might be stitching together a JOIN dataset &#8230; whatever you want.<\/p>\n\n\n\n<p>Map and reduce are made to be completely parallelizable, so you cannot rely on their execution order &#8211; which does not matter because our scheme dialect is pure functional.<\/p>\n\n\n\n<p>Finally, the reducefn will do aggregation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MemCPs native access technology is the scheme scripting language.<\/p>","protected":false},"author":2,"featured_media":4873,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":1,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","_uag_custom_page_level_css":"","footnotes":""},"categories":[129,128],"tags":[],"class_list":["post-4872","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-memcp","category-programming","single-item"],"featured_image_urls_v2":{"full":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920.jpg",1920,1277,false],"thumbnail":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920-150x150.jpg",150,150,true],"medium":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920-300x200.jpg",300,200,true],"medium_large":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920-768x511.jpg",751,500,true],"large":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920-1024x681.jpg",751,499,true],"1536x1536":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920-1536x1022.jpg",1536,1022,true],"2048x2048":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920.jpg",1920,1277,false],"trp-custom-language-flag":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920.jpg",18,12,false],"xs-thumb":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920-64x64.jpg",64,64,true],"appku-shop-single":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920.jpg",620,412,false]},"post_excerpt_stackable_v2":"<p>MemCPs native access technology is the scheme scripting language. In scheme, you can do functional programming with scheme. This is an example scheme terminal session in MemCP: carli@launix-MS-7C51:~\/projekte\/memcp$ make &amp;&amp; .\/memcp go build memcp Copyright (C) 2023 Carl-Philip H\u00e4nsch This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions; Welcome to memcp Hallo World MySQL server listening on port 3307 (connect with mysql -P 3307 -u user -p) listening on http:\/\/localhost:4321 &gt; (createdatabase &#8220;test&#8221;) = &#8220;ok&#8221; &gt; (createtable &#8220;test&#8221; &#8220;foo&#8221; &#8216;(&#8216;(&#8220;bar&#8221; &#8220;int&#8221; &#8216;() &#8220;&#8221;))) = &#8220;ok&#8221; &gt; (insert &#8220;test&#8221;&hellip;<\/p>\n","category_list_v2":"<a href=\"https:\/\/launix.de\/launix\/en\/category\/memcp\/\" rel=\"category tag\">MemCP<\/a>, <a href=\"https:\/\/launix.de\/launix\/en\/category\/programming\/\" rel=\"category tag\">Programming<\/a>","author_info_v2":{"name":"Carl-Philip H\u00e4nsch","url":"https:\/\/launix.de\/launix\/en\/author\/carli\/"},"comments_num_v2":"0 comments","uagb_featured_image_src":{"full":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920.jpg",1920,1277,false],"thumbnail":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920-150x150.jpg",150,150,true],"medium":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920-300x200.jpg",300,200,true],"medium_large":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920-768x511.jpg",751,500,true],"large":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920-1024x681.jpg",751,499,true],"1536x1536":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920-1536x1022.jpg",1536,1022,true],"2048x2048":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920.jpg",1920,1277,false],"trp-custom-language-flag":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920.jpg",18,12,false],"xs-thumb":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920-64x64.jpg",64,64,true],"appku-shop-single":["https:\/\/launix.de\/launix\/wp-content\/uploads\/2023\/02\/storage-warehouse-1553550_1920.jpg",620,412,false]},"uagb_author_info":{"display_name":"Carl-Philip H\u00e4nsch","author_link":"https:\/\/launix.de\/launix\/en\/author\/carli\/"},"uagb_comment_info":0,"uagb_excerpt":"MemCPs native access technology is the scheme scripting language.","_links":{"self":[{"href":"https:\/\/launix.de\/launix\/en\/wp-json\/wp\/v2\/posts\/4872","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/launix.de\/launix\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/launix.de\/launix\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/launix.de\/launix\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/launix.de\/launix\/en\/wp-json\/wp\/v2\/comments?post=4872"}],"version-history":[{"count":3,"href":"https:\/\/launix.de\/launix\/en\/wp-json\/wp\/v2\/posts\/4872\/revisions"}],"predecessor-version":[{"id":4885,"href":"https:\/\/launix.de\/launix\/en\/wp-json\/wp\/v2\/posts\/4872\/revisions\/4885"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/launix.de\/launix\/en\/wp-json\/wp\/v2\/media\/4873"}],"wp:attachment":[{"href":"https:\/\/launix.de\/launix\/en\/wp-json\/wp\/v2\/media?parent=4872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/launix.de\/launix\/en\/wp-json\/wp\/v2\/categories?post=4872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/launix.de\/launix\/en\/wp-json\/wp\/v2\/tags?post=4872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}