<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>TechNotes</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/technotes/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/technotes/feed.xml</link>
    <description>My detailed notes that describe the path I took to learn a particular technology.</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:27:30 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Using Python to implement a queue publisher and subscriber with a polling back-off delay algorithm.</title>
      <link>https://docs.microsoft.com/archive/blogs/technotes/using-python-to-implement-a-queue-publisher-and-subscriber-with-a-polling-back-off-delay-algorithm</link>
      <pubDate>Sat, 21 Mar 2015 14:29:00 GMT</pubDate>
      <dc:creator><![CDATA[CraigGu]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/technotes/2015/03/21/using-python-to-implement-a-queue-publisher-and-subscriber-with-a-polling-back-off-delay-algorithm/</guid>
      <description><![CDATA[I recently come across Python. It's a wonderful language with many packages for statistics,...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: verdana,geneva; font-size: small;">I recently come </span><span style="font-family: verdana,geneva; font-size: small;">across Python. It's a wonderful language with many packages for statistics, </span><span style="font-family: verdana,geneva; font-size: small;">HDInsight, natural language toolkit, etc.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">After using Azure </span><span style="font-family: verdana,geneva; font-size: small;">queue and table store separately with Python I implemented a best practice to </span><span style="font-family: verdana,geneva; font-size: small;">handle large messages using table store and the queue together. The flowchart on this page shows the </span><span style="font-family: verdana,geneva; font-size: small;"><a href="https://msdn.microsoft.com/en-US/library/azure/hh697709.aspx">logic commonly used when implementing a </a></span><span style="font-family: verdana,geneva; font-size: small;"><a href="https://msdn.microsoft.com/en-US/library/azure/hh697709.aspx">queue listener with a polling mechanism</a>.&nbsp;This flowchart was implemented below.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">A single queue </span><span style="font-family: verdana,geneva; font-size: small;">message can be up to 64KB. However, what if you have larger messages or files </span><span style="font-family: verdana,geneva; font-size: small;">that you'd like to manage via a queue? You could put the large message in table </span><span style="font-family: verdana,geneva; font-size: small;">store or file in blob store. Next, add an entry to the queue that can be used </span><span style="font-family: verdana,geneva; font-size: small;">to uniquely identify that particular table store row or blob.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;"><strong><span style="text-decoration: underline;">Note</span></strong>: Python 2.7.9 was used for the code below. </span><span style="font-family: verdana,geneva; font-size: small;">All code below is unsupported and is for illustrative purposes only. Also, see the </span><span style="font-family: verdana,geneva; font-size: small;">unhandled exceptions section below.</span></p>
<p><strong></strong>&nbsp;</p>
<p><strong><span style="font-family: verdana,geneva; font-size: small;">Publisher</span></strong></p>
<p><span style="font-family: verdana,geneva; font-size: small;">Below I implemented </span><span style="font-family: verdana,geneva; font-size: small;">a publisher that adds an artificially "long" message to table store </span><span style="font-family: verdana,geneva; font-size: small;">(when you see this message below just play along and <em>pretend</em> it's long&hellip;). Next, the unique partition key and </span><span style="font-family: verdana,geneva; font-size: small;">row key for that message is added to a queue message.</span></p>
<p>&nbsp;</p>
<p><strong><span style="font-family: verdana,geneva; font-size: small;">Subscriber</span></strong></p>
<p><span style="font-family: verdana,geneva; font-size: small;">I implemented a </span><span style="font-family: verdana,geneva; font-size: small;">subscriber to process the queue and table store entry added by the publisher </span><span style="font-family: verdana,geneva; font-size: small;">above. The subscriber checks the queue for a message. If a message exists it is </span><span style="font-family: verdana,geneva; font-size: small;">retrieved then the unique partition and row key is parsed. Next, it uses </span><span style="font-family: verdana,geneva; font-size: small;">that partition and row key to retrieve the message from table store. </span><span style="font-family: verdana,geneva; font-size: small;">Lastly, it deletes the message from the queue and the table store entry.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">Also, rather than </span><span style="font-family: verdana,geneva; font-size: small;">check the queue repeatedly (which can be costly), I used a back-off delay </span><span style="font-family: verdana,geneva; font-size: small;">algorithm. After checking the queue if nothing exists it backs off at an ever </span><span style="font-family: verdana,geneva; font-size: small;">increasing duration until a maximum duration is reached. For example, the code </span><span style="font-family: verdana,geneva; font-size: small;">below sleeps for 2, 4, 8, 16, 32 and 64 seconds. Between each sleep duration </span><span style="font-family: verdana,geneva; font-size: small;">it checks the queue. If there is something in the queue it is retrieved per </span><span style="font-family: verdana,geneva; font-size: small;">above then starts sleeping again at 2 seconds.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">The publisher and </span><span style="font-family: verdana,geneva; font-size: small;">subscriber below can be run in separate command windows so you can see them </span><span style="font-family: verdana,geneva; font-size: small;">exchanging messages.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">Also, if the queue </span><span style="font-family: verdana,geneva; font-size: small;">and table store become empty just run the publisher again in a separate command </span><span style="font-family: verdana,geneva; font-size: small;">prompts. You'll see the subscriber pick up the message and back-off accordingly.</span></p>
<p><strong></strong>&nbsp;</p>
<p><strong><span style="font-family: verdana,geneva; font-size: small;">Publisher.py</span></strong></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">import string</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">import unicodedata</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">import base64</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">from azure.storage </span><span style="font-family: verdana,geneva; font-size: small;">import TableService, Entity, QueueService</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">from operator import </span><span style="font-family: verdana,geneva; font-size: small;">itemgetter</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;"># This generates </span><span style="font-family: verdana,geneva; font-size: small;">random words so the messages in table store look kinda interesting</span><span style="font-family: verdana,geneva; font-size: small;">.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">def </span><span style="font-family: verdana,geneva; font-size: small;">generate_random_word(wordLen):</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp; word = ''</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp; for i in range(wordLen):</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; word += </span><span style="font-family: verdana,geneva; font-size: small;">random.choice(string.ascii_letters + string.digits)</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp; return word</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">def main():</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; # Add your account name and key below</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; Acct_name = 'add here'</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; Acct_key = 'add here'</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; # Name of the table store table and queue.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; Task_table = 'tasktable'</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; Partition_key = 'Tasks'</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; Task_queue = 'taskqueue'</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; # Number of messages to add to table store </span><span style="font-family: verdana,geneva; font-size: small;">and thus the queue.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; Max_messages = 3</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; # Create a table if it doesn't </span><span style="font-family: verdana,geneva; font-size: small;">exist.&nbsp;</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; table_service = </span><span style="font-family: verdana,geneva; font-size: small;">TableService(account_name=Acct_name, account_key=Acct_key)</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; table_service.create_table(Task_table)</span></p>
<p>&nbsp;&nbsp;&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; # Create a queue if it doesn't </span><span style="font-family: verdana,geneva; font-size: small;">exist.&nbsp;</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; queue_service = </span><span style="font-family: verdana,geneva; font-size: small;">QueueService(account_name=Acct_name, account_key=Acct_key)</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; queue_service.create_queue(Task_queue)</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; # Add a few entries to table store.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; for rowCnt in range(1, Max_messages):</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print '----------'</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'Publisher'</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print ' '</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Generate a random word between x </span><span style="font-family: verdana,geneva; font-size: small;">and y chars long to put into the description.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wordLen = random.randint(10,25)</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; randWord = 'Pretend this is a really </span><span style="font-family: verdana,geneva; font-size: small;">long description... '</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; randWord += </span><span style="font-family: verdana,geneva; font-size: small;">generate_random_word(wordLen)</span></p>
<p>&nbsp;<span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'Random description is:', </span><span style="font-family: verdana,geneva; font-size: small;">randWord</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Add data to the table below. </span><span style="font-family: verdana,geneva; font-size: small;">Priority field in the message is just extra data and is not used for anything.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; task = {'PartitionKey': </span><span style="font-family: verdana,geneva; font-size: small;">Partition_key, 'RowKey': str(rowCnt), 'description' : randWord, 'priority' : </span><span style="font-family: verdana,geneva; font-size: small;">200}</span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-family: verdana,geneva; font-size: small;">table_service.insert_entity(Task_table, task)</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # For the data we just added to table </span><span style="font-family: verdana,geneva; font-size: small;">store, add the unique partition and row key to the queue.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # The partition key and row key in </span><span style="font-family: verdana,geneva; font-size: small;">the queue message will look like PartitionKey-RowKey</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PR_Key = Partition_key</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PR_Key += '-'</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PR_Key += str(rowCnt)</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'Partition and row key is ', </span><span style="font-family: verdana,geneva; font-size: small;">PR_Key</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; queue_service.put_message(Task_queue, </span><span style="font-family: verdana,geneva; font-size: small;">base64.b64encode(PR_Key))</span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Show the length of the queue.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; queue_metadata = </span><span style="font-family: verdana,geneva; font-size: small;">queue_service.get_queue_metadata(Task_queue)</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'Messages in the queue:', </span><span style="font-family: verdana,geneva; font-size: small;">queue_metadata['x-ms-approximate-messages-count']</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print '----------'</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">main()</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">-----</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">After the publisher </span><span style="font-family: verdana,geneva; font-size: small;">runs, you'll see something like the following in table storage and the queue. I used Azure </span><span style="font-family: verdana,geneva; font-size: small;">Storage Explorer to view this data.</span></p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/70/4152.Publisher.PNG" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-68-70/4152.Publisher.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/70/4152.Publisher.PNG" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-68-70/4152.Publisher.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/70/6204.Publisher_Table.PNG" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-68-70/6204.Publisher_5F00_Table.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/70/6204.Publisher_Table.PNG" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-68-70/6204.Publisher_5F00_Table.PNG" alt="" border="0" /></a></p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/70/0116.Publisher_Queue.PNG" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-68-70/0116.Publisher_5F00_Queue.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/70/0116.Publisher_Queue.PNG" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-68-70/0116.Publisher_5F00_Queue.PNG" alt="" width="289" height="139" border="0" /></a></p>
<p>-----&nbsp;</p>
<p>&nbsp;</p>
<p><strong><span style="font-family: verdana,geneva; font-size: small;">Subscriber.py</span></strong></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">import base64</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">import time</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">from azure.storage </span><span style="font-family: verdana,geneva; font-size: small;">import TableService, Entity, QueueService</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;"># Add your account </span><span style="font-family: verdana,geneva; font-size: small;">name and key here</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">Acct_name = 'add </span><span style="font-family: verdana,geneva; font-size: small;">here'</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">Acct_key = 'add </span><span style="font-family: verdana,geneva; font-size: small;">here'</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;"># Name your table </span><span style="font-family: verdana,geneva; font-size: small;">store table and queue</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">Task_table = </span><span style="font-family: verdana,geneva; font-size: small;">'tasktable'</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">Task_queue = </span><span style="font-family: verdana,geneva; font-size: small;">'taskqueue'</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;"># Params used to check the queue and </span><span style="font-family: verdana,geneva; font-size: small;">slowly back-off if it is empty. Start with a </span><span style="font-family: verdana,geneva; font-size: small;">minimum/fastest rate and back-off to the maximum/slowest rate to check the queue.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">Min_delay_sec = 2</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">Max_delay_sec = 64</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;"># Create a table if </span><span style="font-family: verdana,geneva; font-size: small;">it doesn't already exist.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">table_service = </span><span style="font-family: verdana,geneva; font-size: small;">TableService(account_name=Acct_name, account_key=Acct_key)</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">table_service.create_table(Task_table)</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;"># Create a queue if </span><span style="font-family: verdana,geneva; font-size: small;">it doesn't already exist.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">queue_service = </span><span style="font-family: verdana,geneva; font-size: small;">QueueService(account_name=Acct_name, account_key=Acct_key)</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">queue_service.create_queue(Task_queue)</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;"># Start an infinite </span><span style="font-family: verdana,geneva; font-size: small;">loop to read from the queue. <strong>Crtl+C to kill it</strong>.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">while 1 == 1:</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp; # A 2 step process to dequeue a message; get </span><span style="font-family: verdana,geneva; font-size: small;">the message then further below it is deleted.</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp; messages = </span><span style="font-family: verdana,geneva; font-size: small;">queue_service.get_messages(Task_queue, numofmessages=1, visibilitytimeout=1)</span></p>
<p>&nbsp;&nbsp;&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp; if messages.queue_messages:</span></p>
<p>&nbsp;<span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Current_delay_sec = Min_delay_sec</span></p>
<p>&nbsp;<span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print '----------'</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'Subscriber'</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print ' '</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for message in messages:</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PR_Key = </span><span style="font-family: verdana,geneva; font-size: small;">base64.b64decode(message.message_text)</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'Message text has partition </span><span style="font-family: verdana,geneva; font-size: small;">and row key:', PR_Key</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Parse out partition key and row </span><span style="font-family: verdana,geneva; font-size: small;">key from PR_Key. The partition key and row key will look like: </span><span style="font-family: verdana,geneva; font-size: small;">PartitionKey-RowKey</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PR_Key = PR_Key.split('-', 2)</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "Partition key:", </span><span style="font-family: verdana,geneva; font-size: small;">PR_Key[0]</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "Row key:", </span><span style="font-family: verdana,geneva; font-size: small;">PR_Key[1]</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Get the table store message using </span><span style="font-family: verdana,geneva; font-size: small;">the unique partition key and a row key</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; task = </span><span style="font-family: verdana,geneva; font-size: small;">table_service.get_entity(Task_table, PR_Key[0], str(PR_Key[1]))&nbsp;&nbsp;</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'Message description:', </span><span style="font-family: verdana,geneva; font-size: small;">task.description</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'Message priority:', </span><span style="font-family: verdana,geneva; font-size: small;">task.priority</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print('----------')&nbsp;</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # I <strong>foolishly assume</strong> everything was retrieved </span><span style="font-family: verdana,geneva; font-size: small;">just fine. Delete the queue entry and delete the table store </span><span style="font-family: verdana,geneva; font-size: small;">entry using the partition and row </span><span style="font-family: verdana,geneva; font-size: small;">key.</span><br /><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; queue_service.delete_message(Task_queue, message.message_id, </span><span style="font-family: verdana,geneva; font-size: small;">message.pop_receipt)</span><br /><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;table_service.delete_entity(Task_table, PR_Key[0], str(PR_Key[1]))</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;# However, if the queue was empty then </span><span style="font-family: verdana,geneva; font-size: small;">back-off per below.&nbsp;&nbsp;&nbsp;</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp; else:</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if Current_delay_sec &lt; </span><span style="font-family: verdana,geneva; font-size: small;">Max_delay_sec:</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Current_delay_sec = </span><span style="font-family: verdana,geneva; font-size: small;">Current_delay_sec * 2</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'The queue is empty. Will check </span><span style="font-family: verdana,geneva; font-size: small;">the queue again in seconds:', Current_delay_sec</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time.sleep(Current_delay_sec)</span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">----------</span></p>
<p><span style="font-family: verdana,geneva; font-size: small;">When the subscriber runs it looks like the following. Note the queue check re-try is backing off up to 64 seconds.</span></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/70/7080.Subscriber.PNG" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-68-70/7080.Subscriber.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/70/7080.Subscriber.PNG" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-68-70/7080.Subscriber.PNG" alt="" border="0" /></a>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><span style="font-family: verdana,geneva; font-size: small;">Unhandled exceptions?! S</span><span style="font-family: verdana,geneva; font-size: small;">ay it isn't so! </span></strong></p>
<p><span style="font-family: verdana,geneva; font-size: small;">Yes, it's true! </span><span style="font-family: verdana,geneva; font-size: small;">I have unhandled exceptions in the code above. </span><span style="font-family: verdana,geneva; font-size: small;">For example if you </span><span style="font-family: verdana,geneva; font-size: small;">run the publisher <em>twice in a row without running the subscriber</em> to delete </span><span style="font-family: verdana,geneva; font-size: small;">entries from table store the publisher will fail since it tried to add yet </span><span style="font-family: verdana,geneva; font-size: small;">another entry to table store with the same row key. You can dream-up ways to </span><span style="font-family: verdana,geneva; font-size: small;">work around this fault.</span></p>
<p>&nbsp;</p>
<p><span style="font-family: verdana,geneva; font-size: small;">Below is some more info in case you'd like </span><span style="font-family: verdana,geneva; font-size: small;">to learn more:</span></p>
<p><a href="http://azure.microsoft.com/en-us/documentation/articles/python-how-to-install/"><span style="font-family: verdana,geneva; font-size: small;">How to install the </span><span style="font-family: verdana,geneva; font-size: small;">Python Azure SDK</span></a></p>
<p><a href="http://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-table-storage/"><span style="font-family: verdana,geneva; font-size: small;">Python and Table </span><span style="font-family: verdana,geneva; font-size: small;">storage</span></a></p>
<p><a href="http://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-queue-storage/"><span style="font-family: verdana,geneva; font-size: small;">Python and Queue </span><span style="font-family: verdana,geneva; font-size: small;">storage</span></a></p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Taking the post a little further: "Generate movie recommendations using Apache Mahout with HDInsight" .</title>
      <link>https://docs.microsoft.com/archive/blogs/technotes/taking-the-tutorial-a-little-further-generate-movie-recommendations-using-apache-mahout-with-hdinsight</link>
      <pubDate>Sun, 08 Feb 2015 16:13:00 GMT</pubDate>
      <dc:creator><![CDATA[CraigGu]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/technotes/2015/02/08/taking-the-tutorial-a-little-further-generate-movie-recommendations-using-apache-mahout-with-hdinsight/</guid>
      <description><![CDATA[The post Generate movie recommendations using Mahout is a good introduction to Mahout. I've seen...]]></description>
      <content:encoded><![CDATA[<span style="font-family: verdana,geneva;font-size: small">The post </span><span style="font-family: verdana,geneva;font-size: small"><a href="http://azure.microsoft.com/en-us/documentation/articles/hdinsight-mahout/">Generate movie recommendations using Mahout</a> i</span><span style="font-family: verdana,geneva;font-size: small">s a good introduction to Mahout. I've seen similar posts on the web and </span><span style="font-family: verdana,geneva;font-size: small">in books about Mahout that also use the same GroupLens Research movie ratings </span><span style="font-family: verdana,geneva;font-size: small">data.</span>

<span style="font-family: verdana,geneva;font-size: small">I won't regurgitate </span><span style="font-family: verdana,geneva;font-size: small">the same info in the tutorial linked above. Rather, let's look at the results a </span><span style="font-family: verdana,geneva;font-size: small">little more deeply.</span>

<span style="font-family: verdana,geneva;font-size: small">The result file </span><span style="font-family: verdana,geneva;font-size: small">part-r-0000 contains the movie recommendation results, something like:</span>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">1   </span><span style="font-family: verdana,geneva;font-size: small">[234:5.0...</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">3   </span><span style="font-family: verdana,geneva;font-size: small">...272:4.649266]</span></p>
<p style="padding-left: 30px"></p>
<span style="font-family: verdana,geneva;font-size: small">These </span><span style="font-family: verdana,geneva;font-size: small">results can be parsed as User ID, Movie ID and recommendation score. The first </span><span style="font-family: verdana,geneva;font-size: small">2 fields are easy enough to understand. The recommendation results can be used</span>
<span style="font-family: verdana,geneva;font-size: small">if you are trying to predict a user's </span><span style="font-family: verdana,geneva;font-size: small">rating for an item but aren't useful in ranking recommendations.</span>

<span style="font-family: verdana,geneva;font-size: small">To </span><span style="font-family: verdana,geneva;font-size: small">provide ranked recommendations SIMILARITY_LOGLIKELIHOOD would work better. In </span><span style="font-family: verdana,geneva;font-size: small">summary, SIMILARITY_LOGLIKELIHOOD doesn't use the users item rating rather it </span><span style="font-family: verdana,geneva;font-size: small">considers overlapping and non-overlapping users and items each user did and did </span><span style="font-family: verdana,geneva;font-size: small">not interact with. To me, log likelihood is kinda like gathering user feedback; </span><span style="font-family: verdana,geneva;font-size: small">focus on what users <strong>do</strong>, not what they <strong>say</strong> they do. Did the user </span><span style="font-family: verdana,geneva;font-size: small">interact/purchase/consume an item? Yes, then that's what log likelihood uses.</span>

<span style="font-family: verdana,geneva;font-size: small">More information on how log likelihood works </span><span style="font-family: verdana,geneva;font-size: small">can be found <a href="http://www.bing.com/search?q=Ted%20Dunning%20%E2%80%9CAccurate%20Methods%20for%20the%20Statistics%20of%20Surprise%20and%20Coincidence.%E2%80%9D&amp;qs=n&amp;form=QBRE&amp;pq=ted%20dunning%20%E2%80%9Caccurate%20methods%20for%20the%20statistics%20of%20surprise%20and%20coincidence">here</a>.</span>

<span style="font-family: verdana,geneva;font-size: small">To use </span><span style="font-family: verdana,geneva;font-size: small">SIMILARITY_LOGLIKELIHOOD you only need a file with User ID and ID of the </span><span style="font-family: verdana,geneva;font-size: small">item/movie/etc. that the user has interacted with. Below we'll use the same </span><span style="font-family: verdana,geneva;font-size: small">data file from the tutorial.</span>

<span style="font-family: verdana,geneva;font-size: small">Once you're setup for the tutorial then there's 2 options </span><span style="font-family: verdana,geneva;font-size: small">to slightly change and re-run it.</span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">A) In the tutorial if </span><span style="font-family: verdana,geneva;font-size: small">you used the PowerShell script in the "Run the job" section just </span><span style="font-family: verdana,geneva;font-size: small">change the jobArguments to "SIMILARITY_LOGLIKELIHOOD". </span>

<span style="font-family: verdana,geneva;font-size: small">View the output file </span><span style="font-family: verdana,geneva;font-size: small">"part-r-00000" per the tutorial.</span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">B) Alternatively, I used the following command line with my local </span><span style="font-family: verdana,geneva;font-size: small"><a href="http://azure.microsoft.com/en-us/documentation/articles/hdinsight-get-started-emulator/">HDInsight Emulator</a>:</span>

<span style="font-family: verdana,geneva;font-size: small">Copy </span><span style="font-family: verdana,geneva;font-size: small">the u.data file from your local file system to HDFS:</span>

&nbsp;
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">hadoop fs -put u.data u.data</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Run it:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">hadoop jar </span><span style="font-family: verdana,geneva;font-size: small">C:\hdp\mahout-0.9.0.2.1.3.0-1981\core\target\mahout-core-0.9.0.2.1.3.0-1981-job.jar </span><span style="font-family: verdana,geneva;font-size: small">org.apache.mahout.cf.taste.hadoop.item.RecommenderJob -s SIMILARITY_LOGLIKELIHOOD </span><span style="font-family: verdana,geneva;font-size: small">--input u.data --output udata_output</span></strong></p>
 <span style="font-family: verdana,geneva;font-size: small"><strong>Note:</strong> you may need to </span><span style="font-family: verdana,geneva;font-size: small">change the mahout version above to match your local machine.</span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Get the </span><span style="font-family: verdana,geneva;font-size: small">output file from HDFS and put it back into your local file system:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">hadoop fs -getmerge udata_output udata_output.txt</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">View the file udata_output.txt</span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">You'll notice that the recommendations are different when compared </span><span style="font-family: verdana,geneva;font-size: small">to the results you received from previously using SIMILARITY_COOCCURRENCE. In udata_output.txt</span>
<span style="font-family: verdana,geneva;font-size: small">you can ignore the recommendation score and focus on the recommended </span><span style="font-family: verdana,geneva;font-size: small">item IDs.</span>

<span style="font-family: verdana,geneva;font-size: small">There's a lot of data to look through but I'll let you determine </span><span style="font-family: verdana,geneva;font-size: small">whether SIMILARITY_COOCCURRENCE, SIMILARITY_LOGLIKELIHOOD or another Mahout similarity metric will best meet </span><span style="font-family: verdana,geneva;font-size: small">your needs.</span>

<span style="font-family: verdana,geneva;font-size: small">I hope </span><span style="font-family: verdana,geneva;font-size: small">this post provided additional insight.</span>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Comments on the post - Manage Hadoop clusters in HDInsight using Azure PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/technotes/comments-on-the-tutorial-manage-hadoop-clusters-in-hdinsight-using-azure-powershell</link>
      <pubDate>Sun, 18 Jan 2015 21:29:00 GMT</pubDate>
      <dc:creator><![CDATA[CraigGu]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/technotes/2015/01/18/comments-on-the-tutorial-manage-hadoop-clusters-in-hdinsight-using-azure-powershell/</guid>
      <description><![CDATA[Overall, the post on managing a Hadoop cluster in HDInsight with Azure PowerShell was great. I...]]></description>
      <content:encoded><![CDATA[<span style="font-family: verdana,geneva;font-size: small">Overall, the </span><span style="font-family: verdana,geneva;font-size: small">post on <a href="http://azure.microsoft.com/en-us/documentation/articles/hdinsight-administer-use-powershell/">managing a Hadoop cluster in HDInsight with Azure PowerShell</a> </span><span style="font-family: verdana,geneva;font-size: small">was great. I altered the parts below for various reasons.</span><span style="font-family: verdana,geneva;font-size: small"> My related posts can be found <a href="http://blogs.msdn.com/b/technotes/">here</a>.</span>

&nbsp;

<span style="text-decoration: underline"><strong><span style="font-family: verdana,geneva;font-size: small">Copying </span><span style="font-family: verdana,geneva;font-size: small">a file to/from blob store</span></strong></span>

<span style="font-family: verdana,geneva;font-size: small">In the post linked above </span><span style="font-family: verdana,geneva;font-size: small">you'll create a new storage container. Rather than rush ahead </span><span style="font-family: verdana,geneva;font-size: small">I wanted another way to verify <em>from </em></span><span style="font-family: verdana,geneva;font-size: small"><em>the command line</em> that the container existed and that it could accept a </span><span style="font-family: verdana,geneva;font-size: small">file.</span>

<span style="font-family: verdana,geneva;font-size: small">From the PowerShell </span><span style="font-family: verdana,geneva;font-size: small">ISE command prompt I ran the following </span><span style="font-family: verdana,geneva;font-size: small">(note that I previously ran "Set-AzureSubscription" since I have more than 1 </span><span style="font-family: verdana,geneva;font-size: small">subscription):</span>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">PS </span><span style="font-family: verdana,geneva;font-size: small">C:\WINDOWS\system32&gt;</span><strong><span style="font-family: verdana,geneva;font-size: small"> get-azurestoragecontainer &lt;your container name </span><span style="font-family: verdana,geneva;font-size: small">here&gt;</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">You'll get results </span><span style="font-family: verdana,geneva;font-size: small">that look similar to the following. In this example, my container name is shown </span><span style="font-family: verdana,geneva;font-size: small">below.</span>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">Blob </span><span style="font-family: verdana,geneva;font-size: small">End Point: https:// &lt;storage account name &gt;.blob.core.windows.net/</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">Name                 </span><span style="font-family: verdana,geneva;font-size: small">PublicAccess      </span><span style="font-family: verdana,geneva;font-size: small">LastModified                                           </span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">----                    </span><span style="font-family: verdana,geneva;font-size: small">------------         </span><span style="font-family: verdana,geneva;font-size: small">------------     </span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">container1           </span><span style="font-family: verdana,geneva;font-size: small">Off                   </span><span style="font-family: verdana,geneva;font-size: small">1/11/2015 12:10:23 AM +00:00                           </span></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Next, I created a local test file and copied it to my container1. You should alter the 2 params underlined below to match your local machine. </span>
<ol>
 	<li value="1"><span style="font-family: verdana,geneva;font-size: small">My test file was in this location </span><span style="font-family: verdana,geneva;font-size: small">“c:\temp\1.txt”.</span></li>
 	<li><span style="font-family: verdana,geneva;font-size: small">From the PowerShell prompt I ran the following to upload the file to blob store:</span></li>
</ol>
<p style="padding-left: 60px"><strong><span style="font-family: verdana,geneva;font-size: small">Set-AzureStorageBlobContent -Blob “TestTempFile” </span><span style="font-family: verdana,geneva;font-size: small">-Container container1 -File “<span style="text-decoration: underline">c:\temp\1.txt</span>” -Force</span></strong></p>

<ol>
 	<li value="3"><span style="font-family: verdana,geneva;font-size: small">You can use <a href="http://azurestorageexplorer.codeplex.com/">Azure Storage Explorer</a> to see the </span><span style="font-family: verdana,geneva;font-size: small">blob named "TestTempFile" or run the following from PowerShell prompt t</span><span style="font-family: verdana,geneva;font-size: small">o get that file and place it in a different location on your local machine - I used c:\hdp. </span><span style="font-family: verdana,geneva;font-size: small">Also, the -Blob param is case sensitive (must be "TestTempFile"</span><span style="font-family: verdana,geneva;font-size: small">):</span></li>
</ol>
<p style="padding-left: 60px"><strong><span style="font-family: verdana,geneva;font-size: small">Get-AzureStorageBlobContent -Blob TestTempFile -Container </span><span style="font-family: verdana,geneva;font-size: small">container1 -Destination <span style="text-decoration: underline">c:\hdp</span> -Verbose</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Also, I ran the following cmdlet to get info about that file (blob) I just uploaded</span><span style="font-family: verdana,geneva;font-size: small">: </span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">Get-AzureStorageBlob </span><span style="font-family: verdana,geneva;font-size: small">-Container container1 -Blob TestTempFile -Verbose</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">I received: </span>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">Container </span><span style="font-family: verdana,geneva;font-size: small">Uri: https://&lt; storage account name</span><span style="font-family: verdana,geneva;font-size: small">&gt;.blob.core.windows.net/container1</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">Name                   BlobType   Length             ContentType           LastModified       SnapshotTime             </span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">----                      --------      ------                -----------              </span><span style="font-family: verdana,geneva;font-size: small">----------            </span><span style="font-family: verdana,geneva;font-size: small">-----------             </span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">TestTempFile      BlockBlob     65                   </span><span style="font-family: verdana,geneva;font-size: small">application/octet-stream  </span><span style="font-family: verdana,geneva;font-size: small">1/11/2015 11:08:35 PM +...</span></p>
&nbsp;

&nbsp;

<span style="text-decoration: underline"><strong><span style="font-family: verdana,geneva;font-size: small">How to handle the error "New-AzureHDInsightCluster : Unable </span><span style="font-family: verdana,geneva;font-size: small">to complete the cluster create operation. Operation failed with code </span><span style="font-family: verdana,geneva;font-size: small">'400'…"</span></strong></span>

<span style="font-family: verdana,geneva;font-size: small">In </span><span style="font-family: verdana,geneva;font-size: small">the tutorial I encountered some issues provisioning an HDInsight </span><span style="font-family: verdana,geneva;font-size: small">cluster from PowerShell. When the "New-AzureHDInsightCluster" cmdlet</span>
<span style="font-family: verdana,geneva;font-size: small">was called the dialog box appeared below: </span>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/70/6825.Azure_NewHDInsight_Dialog.png"><img style="max-height: 800px;max-width: 550px" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/70/6825.Azure_NewHDInsight_Dialog.png" border="0" /></a></span></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">The </span><span style="font-family: verdana,geneva;font-size: small">user name field above has a drop down that had my previously used accounts. Ok, so I </span><span style="font-family: verdana,geneva;font-size: small">chose my Microsoft Account and a different account and in both cases I received </span><span style="font-family: verdana,geneva;font-size: small">the error:</span>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">Error: </span><span style="font-family: verdana,geneva;font-size: small">New-AzureHDInsightCluster </span><span style="font-family: verdana,geneva;font-size: small">: Unable to complete the cluster create operation. Operation failed with code </span><span style="font-family: verdana,geneva;font-size: small">'400'. Cluster left behind state: 'Error'. Message: 'ClusterUserNameInvalid'.</span></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Each </span><span style="font-family: verdana,geneva;font-size: small">time I received this error it left the cluster in a bad state so I ran the following </span><span style="font-family: verdana,geneva;font-size: small">from the PowerShell command prompt to remove it each time:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">Remove-AzureHDInsightCluster -name &lt;add bad cluster name </span><span style="font-family: verdana,geneva;font-size: small">here&gt;</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">I </span><span style="font-family: verdana,geneva;font-size: small">did some research then ran the script from the tutorial a 3rd time. This time </span><span style="font-family: verdana,geneva;font-size: small">when that dialog box prompted me I entered a new username and password <strong>for the HDInsight cluster I was creating</strong>. </span><span style="font-family: verdana,geneva;font-size: small">After it was finished t</span><span style="font-family: verdana,geneva;font-size: small">he PowerShell cmdlet "<strong>Get-AzureHDInsightCluster</strong>" </span><span style="font-family: verdana,geneva;font-size: small">successfully returned my newly created HDInsight cluster.</span>

&nbsp;

<span style="text-decoration: underline"><strong><span style="font-family: verdana,geneva;font-size: small">The </span><span style="font-family: verdana,geneva;font-size: small">file "example/jars/hadoop-examples.jar" not found.</span></strong></span>

<span style="font-family: verdana,geneva;font-size: small">In the tutorial </span><span style="font-family: verdana,geneva;font-size: small">under "Submit MapReduce Jobs" the script may not find </span><span style="font-family: verdana,geneva;font-size: small">the file "example/jars/hadoop-examples.jar" in <span style="text-decoration: underline">your</span> cluster. On my </span><span style="font-family: verdana,geneva;font-size: small">cluster the real file name below is different from the files </span><span style="font-family: verdana,geneva;font-size: small">"example/jars/hadoop-examples.jar" and </span><span style="font-family: verdana,geneva;font-size: small">"hadoop-mapreduce.jar" mentioned in the <span style="font-family: verdana,geneva;font-size: small">tutorial</span>. If the script can't find </span><span style="font-family: verdana,geneva;font-size: small">"hadoop-examples.jar" you'll need find .jar file used by </span><span style="font-family: verdana,geneva;font-size: small">your HDInsight cluster.</span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">The simplest way to find this file is </span><span style="font-family: verdana,geneva;font-size: small">to use <a href="http://azurestorageexplorer.codeplex.com/">Azure Storage Explorer</a>, </span><span style="font-family: verdana,geneva;font-size: small">find the name of the .jar file and update the script.</span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Alternatively:</span>
<ul>
 	<li><span style="font-family: verdana,geneva;font-size: small">You can sign into your cluster </span><span style="font-family: verdana,geneva;font-size: small"><a href="http://azure.microsoft.com/en-us/documentation/articles/hdinsight-administer-use-management-portal/#rdp">using remote desktop </a></span></li>
 	<li><span style="font-family: verdana,geneva;font-size: small">o</span><span style="font-family: verdana,geneva;font-size: small">pen the Hadoop command </span><span style="font-family: verdana,geneva;font-size: small">prompt</span></li>
 	<li><span style="font-family: verdana,geneva;font-size: small">run the following: </span></li>
</ul>
<p style="padding-left: 60px"><span style="font-family: verdana,geneva;font-size: small">C:\apps&gt;<strong>hadoop </strong></span><strong><span style="font-family: verdana,geneva;font-size: small">fs -ls /example/jars</span></strong></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">My <span style="font-family: verdana,geneva;font-size: small">results are shown below:</span></span></p>
<p style="padding-left: 60px"><span style="font-family: verdana,geneva;font-size: small">Found </span><span style="font-family: verdana,geneva;font-size: small">1 items</span></p>
<p style="padding-left: 60px"><span style="font-family: verdana,geneva;font-size: small">-rw-r--r--   1 hdpinternaluser supergroup     270298 2015-01-18 05:56  </span><span style="font-family: verdana,geneva;font-size: small">/example/jars/<strong>hadoop-mapreduce-examples.jar</strong></span></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">I only made 1 </span><span style="font-family: verdana,geneva;font-size: small">alteration in bold to the .jar filename in the script below.</span>

&nbsp;

-----
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">$clusterName = "&lt;your </span><span style="font-family: verdana,geneva;font-size: small">HDInsight cluster name here&gt;"</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small"># Define the MapReduce job</span></p>
<span style="font-family: verdana,geneva;font-size: small">$wordCountJobDefinition = New-AzureHDInsightMapReduceJobDefinition -JarFile "wasb:///example/jars/<strong>hadoop-mapreduce-examples</strong>.jar" -ClassName "wordcount" -Arguments "wasb:///example/data/gutenberg/davinci.txt", "wasb:///example/data/WordCountOutput"</span>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small"># Run the job and show the standard </span><span style="font-family: verdana,geneva;font-size: small">error </span></p>
<span style="font-family: verdana,geneva;font-size: small">$wordCountJobDefinition | Start-AzureHDInsightJob -Cluster $clusterName | Wait-AzureHDInsightJob -WaitTimeoutInSeconds 3600 | %{ Get-AzureHDInsightJobOutput -Cluster </span><span style="font-family: verdana,geneva;font-size: small">$clusterName -JobId $_.JobId -StandardError}</span>

-----

&nbsp;

<span style="text-decoration: underline"><strong><span style="font-family: verdana,geneva;font-size: small">How to </span><span style="font-family: verdana,geneva;font-size: small">handle error "Get-AzureStorageBlobContent : Access to the path </span><span style="font-family: verdana,geneva;font-size: small">'C:\WINDOWS\System32\example\data\WordCountOutput' is denied."</span></strong></span>

<span style="font-family: verdana,geneva;font-size: small">In the post </span><span style="font-family: verdana,geneva;font-size: small">under section "To download the MapReduce job </span><span style="font-family: verdana,geneva;font-size: small">output" the PowerShell script gave me the following error.</span>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">"Get-AzureStorageBlobContent </span><span style="font-family: verdana,geneva;font-size: small">: Access to the path 'C:\WINDOWS\System32\example\data\WordCountOutput' is </span><span style="font-family: verdana,geneva;font-size: small">denied.</span></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">The script assumed I wanted </span><span style="font-family: verdana,geneva;font-size: small">the WordCount output file to be put in C:\WINDOWS\System32\... (we all know about assumptions, right? :)</span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">I saw 2 options to </span><span style="font-family: verdana,geneva;font-size: small">get this working for me:</span>

<strong><span style="font-family: verdana,geneva;font-size: small">Option A:</span></strong>

<span style="font-family: verdana,geneva;font-size: small">From the PowerShell command line I manually ran the 2 </span><span style="font-family: verdana,geneva;font-size: small">commands below. I added the "</span><span style="font-family: verdana,geneva;font-size: small">-Destination" switch to specify the root where I wanted the file named</span>
<span style="font-family: verdana,geneva;font-size: small">"part-r-00000" to be placed. In this case this cmdlet creates subdirs </span><span style="font-family: verdana,geneva;font-size: small">under this root and places the file there. For example, I specified </span><span style="font-family: verdana,geneva;font-size: small">"c:\hdp" as my root so it'll put the file in </span><span style="font-family: verdana,geneva;font-size: small">"c:\hdp\examples\data\WordCountOutput". You should change the underlined root below to a location on your machine. </span>

&nbsp;
<ol>
 	<li value="1"><strong><span style="font-family: verdana,geneva;font-size: small">Get-AzureStorageBlobContent </span><span style="font-family: verdana,geneva;font-size: small">-Blob example/data/WordCountOutput/part-r-00000 -Container container1 </span><span style="font-family: verdana,geneva;font-size: small">-Destination <span style="text-decoration: underline">c:\hdp</span> -Force -Verbose</span></strong></li>
</ol>
&nbsp;
<ol>
 	<li value="2"><strong><span style="font-family: verdana,geneva;font-size: small">cat </span><span style="font-family: verdana,geneva;font-size: small"><span style="text-decoration: underline">C:\hdp</span>\example\data\WordCountOutput\part-r-00000 | findstr </span><span style="font-family: verdana,geneva;font-size: small">"there"</span></strong></li>
</ol>
&nbsp;

<strong><span style="font-family: verdana,geneva;font-size: small">Option B:</span></strong>

<span style="font-family: verdana,geneva;font-size: small">I made 3 small </span><span style="font-family: verdana,geneva;font-size: small">changes to the script provided in the tutorial. I marked my changes in the </span><span style="font-family: verdana,geneva;font-size: small">comments below as </span>

<span style="font-family: verdana,geneva;font-size: small">##</span>

-----
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">$storageAccountName </span><span style="font-family: verdana,geneva;font-size: small">= "&lt;your storage account name &gt; "</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">$containerName </span><span style="font-family: verdana,geneva;font-size: small">= "&lt;your container name&gt;"</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">## </span><span style="font-family: verdana,geneva;font-size: small">I added the 2 variables below. Add your root destination subdir below.</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">$Rootdestination </span><span style="font-family: verdana,geneva;font-size: small">= "&lt;your root subdir here&gt;"</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">$FileIsHere </span><span style="font-family: verdana,geneva;font-size: small">= "$Rootdestination\example\data\WordCountOutput\part-r-00000"</span></p>
<p style="padding-left: 30px"> <span style="font-family: verdana,geneva;font-size: small"># </span><span style="font-family: verdana,geneva;font-size: small">Create the storage account context object</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">$storageAccountKey </span><span style="font-family: verdana,geneva;font-size: small">= Get-AzureStorageKey $storageAccountName | %{ $_.Primary }</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">$storageContext </span><span style="font-family: verdana,geneva;font-size: small">= New-AzureStorageContext -StorageAccountName $storageAccountName </span><span style="font-family: verdana,geneva;font-size: small">-StorageAccountKey $storageAccountKey </span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small"># </span><span style="font-family: verdana,geneva;font-size: small">Download the output to local computer.</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">## </span><span style="font-family: verdana,geneva;font-size: small">I added the -Destination switch below to specify where I want the file. I also </span><span style="font-family: verdana,geneva;font-size: small">like -Verbose too :-)</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">Get-AzureStorageBlobContent </span><span style="font-family: verdana,geneva;font-size: small">-Container $ContainerName -Blob example/data/WordCountOutput/part-r-00000 </span><span style="font-family: verdana,geneva;font-size: small">-Context $storageContext -Destination $Rootdestination -Force -Verbose</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">## </span><span style="font-family: verdana,geneva;font-size: small">Display the output. I included the full path where the file is located.</span></p>
<p style="padding-left: 30px"><span style="font-family: verdana,geneva;font-size: small">cat </span><span style="font-family: verdana,geneva;font-size: small">$FileIsHere | findstr "there"</span></p>
-----

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">I hope this extra info was helpful for you. </span>

<span style="font-family: verdana,geneva;font-size: small">Good luck!</span>

&nbsp;

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Getting familiar with Apache HBase.</title>
      <link>https://docs.microsoft.com/archive/blogs/technotes/getting-familiar-with-apache-hbase</link>
      <pubDate>Fri, 09 Jan 2015 22:27:00 GMT</pubDate>
      <dc:creator><![CDATA[CraigGu]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/technotes/2015/01/09/getting-familiar-with-apache-hbase/</guid>
      <description><![CDATA[This post is a first step to understanding Apache HBase. Consider this a knowledge nugget chock full...]]></description>
      <content:encoded><![CDATA[<span style="font-family: verdana,geneva;font-size: small">This post is a first step to understanding Apache HBase. Consider this a knowledge nugget chock full O' goodness! </span><span style="font-family: verdana,geneva;font-size: small">Specifically, I am using HDInsight which is the Microsoft Azure Hadoop distribution. My prior posts can be found <a href="http://blogs.msdn.com/b/technotes/">here</a>.</span>

&nbsp;

<strong><span style="font-family: verdana,geneva;font-size: small">What is HBase and why would you use it? </span></strong>

<span style="font-family: verdana,geneva;font-size: small">HBase is one example </span><span style="font-family: verdana,geneva;font-size: small">of a "NoSQL" (aka "Not Only SQL") database. NoSQL refers to </span><span style="font-family: verdana,geneva;font-size: small">a variety of non-relational DBs. I spent about an hour reading several </span><span style="font-family: verdana,geneva;font-size: small">definitions of the "Not Only SQL" part and they don’t really converge, </span><span style="font-family: verdana,geneva;font-size: small"><a href="http://www.bing.com/search?q=define+%22not+only+sql%22">search for yourself</a>. In addition, Martin Fowler's definition of <a href="http://martinfowler.com/bliki/NosqlDefinition.html">NoSQL</a> is the most indepth explanation I've </span><span style="font-family: verdana,geneva;font-size: small">seen. </span>

<span style="font-family: verdana,geneva;font-size: small"><span style="font-family: Arial">R</span>ather than continue </span><span style="font-family: verdana,geneva;font-size: small">to spend time on a phrase lets see what HBase can do.</span>

<strong><span style="font-family: verdana,geneva;font-size: small">HBase:</span></strong>
<ul>
 	<li><span style="font-family: verdana,geneva;font-size: small">can handle massive amounts of </span><span style="font-family: verdana,geneva;font-size: small">structured or messy, unstructured data that relational DB's would struggle </span><span style="font-family: verdana,geneva;font-size: small">with. Massive amounts of data includes billions of rows and more than a </span><span style="font-family: verdana,geneva;font-size: small">million columns.</span></li>
 	<li><span style="font-family: verdana,geneva;font-size: small">functions on-top of Hadoop </span><span style="font-family: verdana,geneva;font-size: small">Distributed File System (HDFS)</span></li>
 	<li><span style="font-family: verdana,geneva;font-size: small">allows data formats to vary </span><span style="font-family: verdana,geneva;font-size: small">from row to row</span></li>
 	<li><span style="font-family: verdana,geneva;font-size: small">supports very fast updates </span><span style="font-family: verdana,geneva;font-size: small">and inserts to smaller data sets without "locking" tables like a </span><span style="font-family: verdana,geneva;font-size: small">relational DB would and provides nearly instant access to that </span><span style="font-family: verdana,geneva;font-size: small">inserted/updated data.</span></li>
 	<li><span style="font-family: verdana,geneva;font-size: small">can do much more than I've </span><span style="font-family: verdana,geneva;font-size: small">summarized here</span></li>
</ul>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Generally, there are </span><span style="font-family: verdana,geneva;font-size: small">4 types of NoSQL DBs: </span>
<ul>
 	<li><span style="font-family: verdana,geneva;font-size: small">key/value</span></li>
 	<li><span style="font-family: verdana,geneva;font-size: small">structured documents (e.g.: </span><span style="font-family: verdana,geneva;font-size: small">HTML, JSON, XML)</span></li>
 	<li><span style="font-family: verdana,geneva;font-size: small">graph (think of nodes with </span><span style="font-family: verdana,geneva;font-size: small">relationships and directions between those nodes)  </span></li>
 	<li><span style="font-family: verdana,geneva;font-size: small">columnar (data is stored in </span><span style="font-family: verdana,geneva;font-size: small">columns rather than rows).</span></li>
</ul>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">To try HBase you can </span><span style="font-family: verdana,geneva;font-size: small">provision a cluster from the <a href="https://manage.windowsazure.com/">Microsoft Azure portal</a>. </span><span style="font-family: verdana,geneva;font-size: small">As I mentioned in an earlier post the Azure emulator doesn’t come with HBase. </span>

<span style="font-family: verdana,geneva;font-size: small">After signing-in to </span><span style="font-family: verdana,geneva;font-size: small">the portal above choose Data Services -&gt; HDInsight -&gt; HBase. For my </span><span style="font-family: verdana,geneva;font-size: small">purposes I simply wanted to become familiar with HBase so I created a single node cluster. </span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small"><strong>Note</strong>, the info below has been simplified to be </span><span style="font-family: verdana,geneva;font-size: small">a quick tutorial. I would NOT follow the same steps below in a production </span><span style="font-family: verdana,geneva;font-size: small">environment. Also, my current HBase knowledge doesn’t include other means to load </span><span style="font-family: verdana,geneva;font-size: small">data into HBase. Briefly, I've read that you can also load </span><span style="font-family: verdana,geneva;font-size: small">data into HBase with Hive, Pig and tools such as CompleteBulkLoad or ImportTSV. </span><span style="font-family: verdana,geneva;font-size: small">There's also the option of writing code to load data into HBase. I'll keep this </span><span style="font-family: verdana,geneva;font-size: small">as an action item for a future post. </span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">After your HBase </span><span style="font-family: verdana,geneva;font-size: small">cluster is running, enable remote access, log into your cluster and launch the </span><span style="font-family: verdana,geneva;font-size: small">Hadoop command line enter</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">cd %HBASE_HOME%\bin</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Which took me to <strong>\apps\dist\hbase-0.98.0.2.1.6.0-2103-hadoop2\bin</strong>&gt;</span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Next, I ran</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">hbase shell</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">You should be at a </span><span style="font-family: verdana,geneva;font-size: small">prompt like this</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">hbase(main):001:0&gt;</span></strong></p>
&nbsp;

<span style="text-decoration: underline"><strong><span style="font-family: verdana,geneva;font-size: small">Tutorial </span></strong></span>

<span style="text-decoration: underline"><strong><span style="font-family: verdana,geneva;font-size: small">Create a table and add data</span></strong></span>

<span style="font-family: verdana,geneva;font-size: small">Hypothetically </span><span style="font-family: verdana,geneva;font-size: small">speaking, let's say that you want to create an HBase table to track the myriad </span><span style="font-family: verdana,geneva;font-size: small">of employees working at your imaginary company. </span><span style="font-family: verdana,geneva;font-size: small">To create an Hbase </span><span style="font-family: verdana,geneva;font-size: small">table the <strong>syntax </strong></span><span style="font-family: verdana,geneva;font-size: small">is:</span>
<p style="padding-left: 30px"> <strong><span style="font-family: verdana,geneva;font-size: small">create </span><span style="font-family: verdana,geneva;font-size: small">'&lt;table name&gt;', '&lt;column family 1&gt;', '&lt;column family 2&gt;', ...</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Enter the following </span><span style="font-family: verdana,geneva;font-size: small">at the command prompt to create a sample table with 2 column families </span><span style="font-family: verdana,geneva;font-size: small">"name" and "address"</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">create </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'name', 'address'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">To see whether the </span><span style="font-family: verdana,geneva;font-size: small">table has been created use this <strong>syntax</strong>:</span>
<p style="padding-left: 30px"> <strong><span style="font-family: verdana,geneva;font-size: small">describe </span><span style="font-family: verdana,geneva;font-size: small">'&lt;table name&gt;'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">In this case enter </span><span style="font-family: verdana,geneva;font-size: small">the following at the command prompt:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">describe </span><span style="font-family: verdana,geneva;font-size: small">'employee'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Or use the following </span><span style="font-family: verdana,geneva;font-size: small">to get a list of all tables:</span>
<p style="padding-left: 30px"> <strong><span style="font-family: verdana,geneva;font-size: small">List</span></strong></p>
<span style="font-family: verdana,geneva;font-size: small">You should see </span><span style="font-family: verdana,geneva;font-size: small">"employee" as a table.</span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">To manually add info </span><span style="font-family: verdana,geneva;font-size: small">to the table I ran the statements below at the HBase command prompt. Y</span><span style="font-family: verdana,geneva;font-size: small">ou should be able to copy and paste all put statements below and run it at once. You can delete </span><span style="font-family: verdana,geneva;font-size: small">the empty lines and leading spaces since I added these for readability. </span>

&nbsp;
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id1', 'name:first', 'Bob'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id1', 'name:last', 'Jones'</span></strong></p>
<p style="padding-left: 30px"></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id1', 'address:street', '123 Main Street'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id1', 'address:city', 'Seattle'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id1', 'address:state', 'WA'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id1', 'address:country', 'USA'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id1', 'address:zip', '98102'</span></strong></p>
<p style="padding-left: 30px"></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id2', 'name:first', 'Jane'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id2', 'name:last', 'Smith'</span></strong></p>
<p style="padding-left: 30px"></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id2', 'address:street', '456 4th Ave'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id2', 'address:city', 'Renton'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id2', 'address:state', 'WA'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id2', 'address:country', 'USA'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">put </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id2', 'address:zip', '98104'</span></strong></p>
<p style="padding-left: 30px"></p>
<span style="font-family: verdana,geneva;font-size: small">Above, 'name' is column family 1 and  'address' belongs to column family 2. </span><span style="font-family: verdana,geneva;font-size: small">Personally, I find it interesting that you can cram a bunch of fields into a </span><span style="font-family: verdana,geneva;font-size: small">single column family. Also, a column family can have a varying number of </span><span style="font-family: verdana,geneva;font-size: small">columns.</span>

<span style="font-family: verdana,geneva;font-size: small">So far the data above is in alignment. </span><span style="font-family: verdana,geneva;font-size: small">What about the "messy" data that HBase can handle well but a </span><span style="font-family: verdana,geneva;font-size: small">relational DB can't? I spent about an hour looking but couldn't find a great, </span><span style="font-family: verdana,geneva;font-size: small">messy example. If you happen to find an example of messy data that HBase </span><span style="font-family: verdana,geneva;font-size: small">handles well I'd be interested in seeing it.</span>

&nbsp;

<span style="text-decoration: underline"><span style="font-family: verdana,geneva;font-size: small"><strong>Sample queries</strong></span></span>

<span style="font-family: verdana,geneva;font-size: small">To dump the entire table to the screen the syntax is:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">scan </span><span style="font-family: verdana,geneva;font-size: small">'&lt;table name&gt;'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Enter the following at the command </span><span style="font-family: verdana,geneva;font-size: small">prompt:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">scan </span><span style="font-family: verdana,geneva;font-size: small">'employee'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">To get a specific row the syntax is: </span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">get </span><span style="font-family: verdana,geneva;font-size: small">'&lt;table name&gt;' ,'&lt;row#&gt;'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">For this example, </span><span style="font-family: verdana,geneva;font-size: small">enter the following at the command prompt: </span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">get </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id1'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">To get a count of the rows in a table the syntax is:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">count </span><span style="font-family: verdana,geneva;font-size: small">'&lt;table name&gt;'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Enter the following at the command </span><span style="font-family: verdana,geneva;font-size: small">prompt:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">count </span><span style="font-family: verdana,geneva;font-size: small">'employee'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">To query the table for a specific value, like any </span><span style="font-family: verdana,geneva;font-size: small">employee named "Bob" I ran the following (it seems to be case sensitive...)</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">scan </span><span style="font-family: verdana,geneva;font-size: small">'employee', {FILTER =&gt; "ValueFilter(=, 'binary:Bob')"}</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Or any employee with </span><span style="font-family: verdana,geneva;font-size: small">a Washington state address</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">scan </span><span style="font-family: verdana,geneva;font-size: small">'employee', {FILTER =&gt; "ValueFilter(=, 'binary:WA')"}</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Although, this only </span><span style="font-family: verdana,geneva;font-size: small">returns a specific entry rather than the whole row. The HBase filters are </span><span style="font-family: verdana,geneva;font-size: small">something that I need to become more familiar with since they are unlike anything </span><span style="font-family: verdana,geneva;font-size: small">I've used before.</span>

&nbsp;

<span style="text-decoration: underline"><strong><span style="font-family: verdana,geneva;font-size: small">Delete</span></strong></span>

<span style="font-family: verdana,geneva;font-size: small">To delete specific cell </span><span style="font-family: verdana,geneva;font-size: small">values, like "Bob" and "Jones", enter:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">delete </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id1', 'name:last'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">delete </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id1', 'name:first'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">To verify these results run a 'scan' on </span><span style="font-family: verdana,geneva;font-size: small">the employee table like:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">scan 'employee'</span></strong></p>
<p style="padding-left: 30px"><strong></strong></p>
<span style="font-family: verdana,geneva;font-size: small">...and you should see the following, although the timestamp will be different for obvious reasons:</span>

&nbsp;
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">ROW                COLUMN+CELL</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small"> id1                  column=address:city, </span></strong><strong><span style="font-family: verdana,geneva;font-size: small">timestamp=1420868942823, value=Seattle</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small"> id1                  column=address:country, </span></strong><strong><span style="font-family: verdana,geneva;font-size: small">timestamp=1420868942901, value=USA</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small"> id1                  column=address:state, </span></strong><strong><span style="font-family: verdana,geneva;font-size: small">timestamp=1420868942870, value=WA</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small"> id1                  column=address:street, </span></strong><strong><span style="font-family: verdana,geneva;font-size: small">timestamp=1420868942776, value=123 Main Street</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small"> id1                  column=address:zip, </span></strong><strong><span style="font-family: verdana,geneva;font-size: small">timestamp=1420868942948, value=98102 </span></strong></p>
<strong></strong><strong><span style="font-family: verdana,geneva;font-size: small">[Note, above there is no column=name:first or </span><span style="font-family: verdana,geneva;font-size: small">column=name:last but there is one below for the next employee.]</span></strong>
<p style="padding-left: 30px"><strong> <span style="font-family: verdana,geneva;font-size: small"> id2                  column=address:city, </span></strong><strong><span style="font-family: verdana,geneva;font-size: small">timestamp=1420868943104, value=Renton</span></strong></p>
<p style="padding-left: 30px"><strong> <span style="font-family: verdana,geneva;font-size: small"> id2                  column=address:country, </span></strong><strong><span style="font-family: verdana,geneva;font-size: small">timestamp=1420868943167, value=USA</span></strong></p>
<p style="padding-left: 30px"><strong> <span style="font-family: verdana,geneva;font-size: small"> id2                  column=address:state, </span></strong><strong><span style="font-family: verdana,geneva;font-size: small">timestamp=1420868943136, value=WA</span></strong></p>
<p style="padding-left: 30px"><strong> <span style="font-family: verdana,geneva;font-size: small"> id2                  column=address:street, </span></strong><strong><span style="font-family: verdana,geneva;font-size: small">timestamp=1420868943058, value=456 4th Ave</span></strong></p>
<p style="padding-left: 30px"><strong> <span style="font-family: verdana,geneva;font-size: small"> id2                  column=address:zip, </span></strong><strong><span style="font-family: verdana,geneva;font-size: small">timestamp=1420868944739, value=98104</span></strong></p>
<p style="padding-left: 30px"><strong> <span style="font-family: verdana,geneva;font-size: small"> id2                  column=name:first, </span></strong><strong><span style="font-family: verdana,geneva;font-size: small">timestamp=1420868942995, value=Jane</span></strong></p>
<p style="padding-left: 30px"><strong> <span style="font-family: verdana,geneva;font-size: small"> id2                  column=name:last, </span></strong><strong><span style="font-family: verdana,geneva;font-size: small">timestamp=1420868943026, value=Smith</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Alternatively, enter </span><span style="font-family: verdana,geneva;font-size: small">the command below to show everything associated with id1. You'll notice that </span><span style="font-family: verdana,geneva;font-size: small">column=name:first or column=name:last doesn’t exist:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">get </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id1'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">To prepare this post </span><span style="font-family: verdana,geneva;font-size: small">I forced myself to find how to delete an entire </span><span style="font-family: verdana,geneva;font-size: small">row (which is one reason why I'm blogging…). </span><span style="font-family: verdana,geneva;font-size: small">Since we've munged </span><span style="font-family: verdana,geneva;font-size: small">the data associated with id1 lets delete that entire row. The syntax is:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">deleteall </span><span style="font-family: verdana,geneva;font-size: small">'&lt;table name&gt;', '&lt;row&gt;'   </span></strong><span style="font-family: verdana,geneva;font-size: small">(There are some optional params that I won't mention here.)</span></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Enter the following </span><span style="font-family: verdana,geneva;font-size: small">at the command prompt:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">deleteall </span><span style="font-family: verdana,geneva;font-size: small">'employee', 'id1'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Run a 'scan' on our </span><span style="font-family: verdana,geneva;font-size: small">employee table and see that the data associated with id1 no longer exists. The s</span><span style="font-family: verdana,geneva;font-size: small">can results only show data for id2 at this point.</span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">To delete all data in a table the syntax is:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">Truncate </span><span style="font-family: verdana,geneva;font-size: small">'&lt;table name&gt;'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Enter the following at the command </span><span style="font-family: verdana,geneva;font-size: small">prompt:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">truncate </span><span style="font-family: verdana,geneva;font-size: small">'employee'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">To delete an Hbase table first drop it then delete </span><span style="font-family: verdana,geneva;font-size: small">it - the syntax is:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">disable </span><span style="font-family: verdana,geneva;font-size: small">'&lt;table name&gt;'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">drop </span><span style="font-family: verdana,geneva;font-size: small">'&lt;table name&gt;'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">In this example </span><span style="font-family: verdana,geneva;font-size: small">enter the following at the command prompt:</span>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">disable </span><span style="font-family: verdana,geneva;font-size: small">'employee'</span></strong></p>
<p style="padding-left: 30px"><strong><span style="font-family: verdana,geneva;font-size: small">drop </span><span style="font-family: verdana,geneva;font-size: small">'employee'</span></strong></p>
&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Lastly, delete the HBase test cluster we created above.</span>

&nbsp;

<span style="font-family: verdana,geneva;font-size: small">Maybe I'm a geek but I enjoyed researching HBase and putting together the small tutorial above. I hope this information was valuable to you. </span>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Getting familiar with Hive query language.</title>
      <link>https://docs.microsoft.com/archive/blogs/technotes/getting-familiar-with-hive-query-language</link>
      <pubDate>Thu, 01 Jan 2015 21:39:00 GMT</pubDate>
      <dc:creator><![CDATA[CraigGu]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/technotes/2015/01/01/getting-familiar-with-hive-query-language/</guid>
      <description><![CDATA[In my previous post I described Hive at a high level, the Hive query language and how Hive works...]]></description>
      <content:encoded><![CDATA[<span style="font-family: verdana,geneva">In my <a href="http://blogs.msdn.com/b/technotes/archive/2014/12/21/using-hadoop-distributed-file-system-and-hive.aspx">previous post</a> I described Hive at a high level, the Hive query language and how Hive works with map-reduce.</span>

<span style="font-family: verdana,geneva">In this post we'll create a hive table, get a data file and query the data in that file. These steps will also demonstrate schema on read. In addition, we'll create a view. Lastly, we'll delete that table. </span>

&nbsp;

<span style="font-family: verdana,geneva"><strong>1) Create an HDInsight cluster</strong> </span>
<ul>
 	<li><span style="font-family: verdana,geneva">After signing into <a href="https://manage.windowsazure.com/">Microsoft Azure</a> choose HDInsight -&gt; Create an HDInsight Cluster -&gt; Hadoop. </span></li>
 	<li><span style="font-family: verdana,geneva">Give your cluster a name for *.azurehdinsight.net. </span></li>
 	<li><span style="font-family: verdana,geneva">A single data node cluster is fine for testing purposes. </span></li>
 	<li><span style="font-family: verdana,geneva">In that process you'll be asked to associate your Hadoop cluster with a storage account. This is necessary so that your data can live even after your HDInsight cluster has been deleted. </span></li>
 	<li><span style="font-family: verdana,geneva">After you choose "Create HDInsight Cluster" it will take a few minutes to create your cluster. </span></li>
</ul>
<span style="font-family: verdana,geneva">You can use the sources below to get more details on creating an HDInsight cluster:  </span>
<ul>
 	<li><span style="font-family: verdana,geneva"><a href="http://azure.microsoft.com/en-us/documentation/videos/getting-started-with-azure-hdinsight-with-matt-winkler/">Getting started with Microsoft Azure HDinsight</a>.</span></li>
 	<li><span style="font-family: verdana,geneva">HDInsight background info and <a href="http://azure.microsoft.com/en-us/services/hdinsight/">creating your first Hadoop cluster with HDInsight in minutes</a>.</span></li>
 	<li><span style="font-family: verdana,geneva"><a href="http://azure.microsoft.com/en-us/documentation/articles/storage-create-storage-account/">Create an Azure storage account</a>.</span></li>
</ul>
&nbsp;

<span style="font-family: verdana,geneva"><strong>2) Access your HDInsight cluster</strong></span>

<span style="font-family: verdana,geneva">To access your HDInsight cluster you can use the query console or enable remote access. The remaining steps below assume you are using remote access to your HDInsight cluster. </span>

<span style="font-family: verdana,geneva">I noticed that each HDInsight cluster has Hive samples under \apps\dist\examples\hive. However, I also noticed that the Azure Emulator has different samples.  </span>
<ul>
 	<li><span style="font-family: verdana,geneva">Once you gain access to your cluster, on the desktop open the Hadoop command prompt and enter <strong>cd %hive_home%\bin</strong> which will take you to <strong>\apps\dist\hive-&lt;version&gt;\bin. </strong></span></li>
 	<li><span style="font-family: verdana,geneva">Run "hive" at the command prompt. </span></li>
 	<li><span style="font-family: verdana,geneva">You should see the hive command prompt as "<strong>hive&gt;</strong>"</span></li>
</ul>
&nbsp;

<span style="font-family: verdana,geneva"><strong>3) Execute the following to create and query a Hive table </strong></span>

<span style="font-family: verdana,geneva">Note, there are other ways to run Hive queries. I only describe one option below. </span>

<span style="font-family: verdana,geneva">Also, ensure that you have a semicolon at the end of each Hive statement.</span>

&nbsp;

<span style="font-family: verdana,geneva">-- At the hive prompt run the following to create a table called "HiveSampleTable": </span>

&nbsp;

<span style="font-family: verdana,geneva">CREATE TABLE IF NOT EXISTS HiveSampleTable (</span>

<span style="font-family: verdana,geneva">    ClientId string,</span>

<span style="font-family: verdana,geneva">    QueryTime string,</span>

<span style="font-family: verdana,geneva">    Market string,</span>

<span style="font-family: verdana,geneva">    DevicePlatform string,</span>

<span style="font-family: verdana,geneva">    DeviceMake string,</span>

<span style="font-family: verdana,geneva">    DeviceModel string,</span>

<span style="font-family: verdana,geneva">    State string,</span>

<span style="font-family: verdana,geneva">    Country string,</span>

<span style="font-family: verdana,geneva">    QueryDwellTime double,</span>

<span style="font-family: verdana,geneva">    SessionId bigint,</span>

<span style="font-family: verdana,geneva">    SessionPageViewOrder bigint)</span>

<span style="font-family: verdana,geneva">ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';</span>

&nbsp;

<span style="font-family: verdana,geneva">-- The statement above will create an INTERNAL table by default. This blog post gives an <a href="http://blogs.msdn.com/b/cindygross/archive/2013/02/06/hdinsight-hive-internal-and-external-tables-intro.aspx">in-depth description of internal vs. external hive tables</a>, how they function and when to use each.</span>

&nbsp;

<span style="font-family: verdana,geneva">-- Run the following at the hive prompt. This command will get the file "HiveSampleData.txt" from your local file system and place it into the default hive directory at /hive/warehouse. </span>

<span style="font-family: verdana,geneva">LOAD DATA LOCAL INPATH '\Apps\dist\examples\hive\HiveSampleData.txt' OVERWRITE INTO TABLE HiveSampleTable;</span>

&nbsp;

<span style="font-family: verdana,geneva"> -- Get some data to ensure it was created successfully.</span>

<span style="font-family: verdana,geneva">SELECT * FROM HiveSampleTable LIMIT 10;</span>

&nbsp;

<span style="font-family: verdana,geneva"><strong>Note:</strong> What you just witnessed is an example of <strong>schema on read</strong>. The schema is applied when the data is read from the data store (in this case HDFS). When we ran the select query above it applied the previously defined "HiveSampleTable" schema to the data file "HiveSampleData.txt" and showed the results. Alternatively, you could collect additional data file(s) and define one or more schemas later. You can also change your schema without affecting the data files. In addition, here is a great explanation of <a href="http://stackoverflow.com/questions/11764237/hive-enforces-schema-during-read-time">schema on read</a>.</span>

&nbsp;

<span style="font-family: verdana,geneva">-- See how many rows we have in the HiveampleTable overall.</span>

<span style="font-family: verdana,geneva">SELECT COUNT(*) FROM HiveSampleTable;</span>

&nbsp;

<span style="font-family: verdana,geneva">-- Towards the bottom of the command window you'll see something like the following, "59793" is the answer we're looking for. </span>

<span style="font-family: verdana,geneva">Total MapReduce CPU</span>
<span style="font-family: verdana,geneva">Time Spent: 5 seconds 483 msec</span>

<span style="font-family: verdana,geneva">OK</span>

<span style="font-family: verdana,geneva">59793</span>

<span style="font-family: verdana,geneva">Time taken: 33.338</span>
<span style="font-family: verdana,geneva">seconds, Fetched: 1 row(s)</span>

&nbsp;

<span style="font-family: verdana,geneva">-- Run the following to see the field names and field types of a table. </span>

<span style="font-family: verdana,geneva">Describe HiveSampleTable;</span>

&nbsp;

<span style="font-family: verdana,geneva">-- Need more info about the table? Run:</span>

<span style="font-family: verdana,geneva">Describe formatted HiveSampleTable;</span>

&nbsp;

<span style="font-family: verdana,geneva">-- Get a list of all table names</span>

<span style="font-family: verdana,geneva">Show tables;</span>

&nbsp;

<span style="font-family: verdana,geneva">-- Count the number of rows where the state is Nevada. The result should be 732.</span>

<span style="font-family: verdana,geneva">select count (*) from HiveSampleTable where state = 'Nevada';</span>

&nbsp;

<span style="font-family: verdana,geneva">-- You get the idea...</span>

<span style="font-family: verdana,geneva">select DeviceMake, DeviceModel from HiveSampleTable where state = 'Nevada';</span>

<span style="font-family: verdana,geneva">select DeviceMake, DeviceModel from HiveSampleTable where state = 'Nevada' order by DeviceMake;</span>

&nbsp;

<span style="font-family: verdana,geneva"> --  Rather than just selecting rows let's total one of the columns called "QueryDwellTime". Dwell time is the length of a users stay within a particular cell. After running the SELECT below you should see "1.314205…" in the command window.</span>

<span style="font-family: verdana,geneva">SELECT SUM(QueryDwellTime) FROM HiveSampleTable;</span>

&nbsp;

<span style="font-family: verdana,geneva">-- Let’s compare the average query dwell time from an iPhone 4.2.x and iPhone 4.3.x. You should see 38.92 and 54.04 respectively.</span>

<span style="font-family: verdana,geneva">SELECT AVG(QueryDwellTime) FROM HiveSampleTable where devicemodel='iPhone 4.2.x';</span>

<span style="font-family: verdana,geneva">SELECT AVG(QueryDwellTime) FROM HiveSampleTable where devicemodel='iPhone 4.3.x';</span>

&nbsp;

<span style="font-family: verdana,geneva"><strong>4) VIEWS</strong></span>

<span style="font-family: verdana,geneva">One of the benefits of using views is that they provide a level of abstraction from the underlying tables. For example, with views you can include a subset of data from one or more tables. Run the command below to create a view called "DeviceMake_View" for the devices used in Nevada.</span>

<span style="font-family: verdana,geneva">Create VIEW DeviceMake_View AS select DeviceMake, DeviceModel from HiveSampleTable where state = 'Nevada';</span>

&nbsp;

<span style="font-family: verdana,geneva">-- Select some data using that view using the following queries.</span>

<span style="font-family: verdana,geneva">Select * from DeviceMake_View where devicemake = 'Apple';</span>

<span style="font-family: verdana,geneva">Select count (*) from devicemake_view where devicemake = 'Apple';</span>

&nbsp;

<span style="font-family: verdana,geneva">--- Towards the bottom of the command window you'll see something like the following, "242" is the answer we're looking for.</span>

<span style="font-family: verdana,geneva">Total MapReduce CPU</span>
<span style="font-family: verdana,geneva">Time Spent: 6 seconds 374 msec</span>

<span style="font-family: verdana,geneva">OK</span>

<span style="font-family: verdana,geneva">242</span>

<span style="font-family: verdana,geneva">Time taken: 34.235</span>
<span style="font-family: verdana,geneva">seconds, Fetched: 1 row(s)</span>

&nbsp;

<span style="font-family: verdana,geneva">-- Finally, get rid of that view.</span>

<span style="font-family: verdana,geneva">drop view devicemake_view;</span>

&nbsp;

<span style="font-family: verdana,geneva">-- Get rid of the table.</span>

<span style="font-family: verdana,geneva">Drop table HiveSampleTable;</span>

&nbsp;

<span style="font-family: verdana,geneva">Be sure to delete your HDInsight cluster or else you'll be charged $$ for it. The data can still live in your storage account that was associated with the Hadoop cluster. </span>

&nbsp;

<span style="font-family: verdana,geneva">In my next post I'll provide a quick overview of HBase and some queries as well. </span>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>An overview of Hadoop Distributed File System, HCatalog, Hive and map-reduce.</title>
      <link>https://docs.microsoft.com/archive/blogs/technotes/an-overview-of-hadoop-distributed-file-system-hcatalog-hive-and-map-reduce</link>
      <pubDate>Sun, 21 Dec 2014 15:34:00 GMT</pubDate>
      <dc:creator><![CDATA[CraigGu]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/technotes/2014/12/21/an-overview-of-hadoop-distributed-file-system-hcatalog-hive-and-map-reduce/</guid>
      <description><![CDATA[Yet another step in my journey learning about big data. Below are some things I've learned along...]]></description>
      <content:encoded><![CDATA[<div class="OutlineElement Ltr SCX487026" style="margin-left: 0px">
<p class="Paragraph SCX487026" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span style="font-family: arial,helvetica,sans-serif;font-size: small"><span class="TextRun SCX487026" style="color: windowtext;line-height: 17px" xml:lang="EN-US"><span class="NormalTextRun SCX487026" style="background-color: inherit">Yet another step in my journey learning about big data. Below are some things I've learned along the way. </span></span></span></p>
<p class="Paragraph SCX487026" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"></p>
<p class="Paragraph SCX487026" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span style="font-family: arial,helvetica,sans-serif;font-size: small"><span class="TextRun SCX487026" style="color: windowtext;line-height: 17px" xml:lang="EN-US"><span class="NormalTextRun SCX487026" style="background-color: inherit">The image <a href="http://social.technet.microsoft.com/wiki/cfs-filesystemfile.ashx/__key/communityserver-components-imagefileviewer/communityserver-wikis-components-files-00-00-00-00-05/7848.TheHadoopEcosystem.png_2D00_550x0.png">here</a></span></span><span class="TextRun SCX487026" style="color: windowtext;line-height: 17px" xml:lang="EN-US"><span class="NormalTextRun SCX487026" style="background-color: inherit"> provides a high-level overview of Hadoop. (I'm still trying to find a more detailed architecture diagram that I can freely re-use).</span></span></span></p>
<p class="Paragraph SCX487026" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span style="font-family: arial,helvetica,sans-serif;font-size: small"><span class="TextRun SCX39583386" style="color: windowtext;line-height: 17px;font-style: normal;font-weight: normal" xml:lang="EN-US"><span class="NormalTextRun SCX39583386" style="background-color: inherit">After setting up an </span><span class="SpellingError SCX39583386" style="background-color: inherit">HDInsight</span><span class="NormalTextRun SCX39583386" style="background-color: inherit"> cluster on Azure </span></span><span class="TextRun SCX39583386" style="color: windowtext;line-height: 17px;font-style: normal;font-weight: normal" xml:lang="EN-US"><span class="NormalTextRun SCX39583386" style="background-color: inherit">I dove in and wrote some Hive commands. However, before going too far </span></span><span class="TextRun SCX39583386" style="color: windowtext;line-height: 17px;font-style: normal;font-weight: normal" xml:lang="EN-US"><span class="NormalTextRun SCX39583386" style="background-color: inherit">there are a few key pieces to understand namely Hive, map-reduce, Hadoop Distributed File System and </span><span class="SpellingError SCX39583386" style="background-color: inherit">HCatalog</span><span class="NormalTextRun SCX39583386" style="background-color: inherit">. </span></span><span class="EOP SCX39583386" style="line-height: 17px"> </span></span></p>
<p class="Paragraph SCX487026" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span style="font-family: arial,helvetica,sans-serif;font-size: small"> </span></p>

</div>
<p class="OutlineElement Ltr SCX39583386" style="margin-left: 0px"><span style="font-family: arial,helvetica,sans-serif;font-size: small"><strong>In summary: </strong></span></p>
<p class="Paragraph SCX39583386" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"></p>

<div class="OutlineElement Ltr SCX487026" style="margin-left: 0px">
<ul>
 	<li>
<div class="OutlineElement Ltr SCX39583386" style="margin-left: 0px"><span style="font-family: arial,helvetica,sans-serif;font-size: small">Hive is built on Hadoop. Hive enables a SQL-<em>like</em> query language. I've seen the Hive query language also referred to as HQL or HiveQL. That language is not the same as SQL but it looks very similar to SQL as I'll show in a later post. </span></div></li>
</ul>
</div>
<p class="Paragraph SCX39583386" style="text-align: left;color: windowtext;padding-left: 30px;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;margin-left: 0px;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span style="font-family: arial,helvetica,sans-serif;font-size: small">Hive functions differently than a relational DB management system. Hive is an abstraction layer on top of map-reduce and actually turns your HQL queries into map-reduce jobs. "So... why not just write map-reduce jobs?" you might ask. Well you could but you'd need to write the actual code in Java, C# or another language rather than just writing SQL-like statements. I'm sure there are times where an HQL query would suffice but other times where an actual map-reduce job would need to be written. </span></p>
<p class="OutlineElement Ltr SCX39583386" style="padding-left: 30px"><span style="font-family: arial,helvetica,sans-serif;font-size: small">Also, there are many details behind Hive and HQL that I won't go into here. The Hortonworks University has a really good <a href="http://hortonworks.com/hadoop-tutorial/how-to-process-data-with-apache-hive/">introductory tutorial on Hive</a>. </span></p>
<p class="Paragraph SCX39583386" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"></p>

<div class="OutlineElement Ltr SCX39583386" style="margin-left: 0px">
<ul>
 	<li><span style="font-family: arial,helvetica,sans-serif;font-size: small">The Hadoop Distributed File System (HDFS) is a Java based, distributed and fault tolerant file system. HDFS includes a master node and data nodes. </span></li>
</ul>
</div>
<p class="Paragraph SCX39583386" style="text-align: left;color: windowtext;padding-left: 30px;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span style="font-family: arial,helvetica,sans-serif;font-size: small">Since HDFS is a file system you will find commands that you would expect like file copy, create a subdirectory, delete files, etc. The HDFS commands <em>I used most frequently</em> from the Hadoop command line are:</span></p>
<p class="Paragraph SCX39583386" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"></p>

<ul>
<ul>
 	<li><span style="font-family: arial,helvetica,sans-serif;font-size: small">hadoop dfs -mkdir HDFS_destination_folder --&gt; Creates an HDFS subdirectory "HDFS_destination_folder"</span></li>
</ul>
</ul>
&nbsp;
<ul>
<ul>
 	<li><span style="font-family: arial,helvetica,sans-serif;font-size: small">hadoop dfs -put c:\local_subdir\filename.txt HDFS_destination_folder --&gt; Copies filename.txt to the HDFS_destination_folder</span></li>
</ul>
</ul>
&nbsp;
<ul>
<ul>
 	<li><span style="font-family: arial,helvetica,sans-serif;font-size: small">hadoop dfs -ls HDFS_destination_folder --&gt; Shows all of the files in the HDFS_destination_folder </span></li>
</ul>
</ul>
&nbsp;
<ul>
<ul>
 	<li><span style="font-family: arial,helvetica,sans-serif;font-size: small">hadoop dfs -get /HDFS_destination_folder/file.txt c:\local_subdir --&gt; Gets file.txt from HDFS and places it in your local c:\local_subdir</span></li>
</ul>
</ul>
&nbsp;
<ul>
<ul>
 	<li><span style="font-family: arial,helvetica,sans-serif;font-size: small">A full list of commands can be found by entering "hadoop dfs -help". In adddition, this seems to be a good <a href="http://hortonworks.com/hadoop-tutorial/using-commandline-manage-files-hdfs/">summary of commands</a>. </span></li>
</ul>
</ul>
<p class="Paragraph SCX39583386" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"></p>

<ul>
 	<li><span style="font-family: arial,helvetica,sans-serif;font-size: small">Map-reduce utilizes HDFS. For example, when an HQL query is submitted by a user the master node uses a "map" process to assign parts of that query to data nodes to execute. The data nodes execute their assigned portion and return their individual results back to the master node. The master node then aggregates or "reduces" the individual results into a cohesive result that is returned to the user who executed the HQL query. </span></li>
</ul>
<p class="Paragraph SCX39583386" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"></p>

<ul>
 	<li><span style="font-family: arial,helvetica,sans-serif;font-size: small">HCatalog provides an abstraction over the files in HDFS. Hive, map-reduce and other parts of Hadoop use HCatalog to simplify reading and writing to HDFS. I found this to be a good <a href="http://hortonworks.com/hadoop/hcatalog/">tutorial of HCatalog</a>. </span></li>
</ul>
<p class="Paragraph SCX39583386" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"></p>
<p class="Paragraph SCX39583386" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span style="font-family: arial,helvetica,sans-serif;font-size: small">I'm skipping over many other parts of Hadoop mainly because I haven't used them yet. Realistically, you may not need to use <em>everything</em> in the Hadoop toolset. Some of the other parts include Pig, Sqoop, etc. This a good description of <a href="http://azure.microsoft.com/en-us/documentation/articles/hdinsight-hadoop-introduction/">each of the Hadoop tools</a>. </span></p>
<p class="Paragraph SCX39583386" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"></p>
<p class="Paragraph SCX39583386" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span style="font-family: arial,helvetica,sans-serif;font-size: small">In the next post I'll import a file into a hive table and create some queries. </span></p>
<p class="Paragraph SCX39583386" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"></p>]]></content:encoded>
    </item>
    <item>
      <title>Getting started with big data (HDInsight, Hadoop, etc.)</title>
      <link>https://docs.microsoft.com/archive/blogs/technotes/getting-started-with-big-data-hdinsight-hadoop-etc</link>
      <pubDate>Sun, 21 Dec 2014 14:44:00 GMT</pubDate>
      <dc:creator><![CDATA[CraigGu]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/technotes/2014/12/21/getting-started-with-big-data-hdinsight-hadoop-etc/</guid>
      <description><![CDATA[I'm currently focused on learning about big data. Over a series of posts I'll show the path I took...]]></description>
      <content:encoded><![CDATA[<div class="OutlineElement Ltr SCX56215701" style="margin-left: 0px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span class="TextRun SCX56215701" style="color: windowtext;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">I'm currently focused on learning about big data. Over a series of posts I'll show the path I took from </span></span><span class="TextRun SCX56215701" style="color: windowtext;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">being new to big data to eventually doing something worthwhile with Big Data, specifically using HDInsight which is the Microsoft Azure Hadoop distribution. If big data is new to you then I hope you can learn a few things below.  </span></span></p>

</div>
<div class="OutlineElement Ltr SCX56215701" style="margin-left: 0px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></p>

</div>
<div class="OutlineElement Ltr SCX56215701" style="margin-left: 0px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span class="TextRun SCX56215701" style="color: windowtext;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt;font-style: normal;font-weight: normal;text-decoration: none;background-color: transparent" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">Also, this blog will contain my personal notes. Rather than keep my notes locally I thought I would share them so that others can also learn as well. Since these are my notes they will appear rough at times. </span></span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></p>
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"></p>

</div>
<div class="OutlineElement Ltr SCX56215701" style="margin-left: 0px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><strong><span class="TextRun SCX56215701" style="color: windowtext;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">Getting started with HDInsight and Hadoop</span></span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></strong></p>

</div>
<div class="OutlineElement Ltr SCX56215701" style="margin-left: 0px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span class="TextRun SCX56215701" style="color: windowtext;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">I started using HDInsight a few months ago. I found the following info helpful:  </span></span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></p>

</div>
<div class="OutlineElement Ltr SCX56215701" style="margin-left: 0px">
<ul class="BulletListStyle1 SCX56215701">
 	<li class="OutlineElement Ltr SCX56215701" style="margin-left: 24px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span class="TextRun SCX56215701" style="color: windowtext;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">Hortonworks has <a href="http://hortonworks.com/hdp/">great tutorials</a>. </span></span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></p>
</li>
 	<li class="OutlineElement Ltr SCX56215701" style="margin-left: 24px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span class="TextRun SCX56215701" style="color: #222a35;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">Microsoft offers this <a href="http://azure.microsoft.com/en-us/documentation/articles/hdinsight-learn-map/">learning map</a>. See the </span></span><span class="TextRun SCX56215701" style="color: #222a35;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">"real world scenarios" column at the bottom of that page for hands-on tutorials. </span></span></p>
</li>
</ul>
</div>
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"></p>
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span class="TextRun SCX56215701" style="color: windowtext;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">If you like the overviews above you'll need a place to try the tutorials. I'm aware of 3 options. </span></span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></p>

<div class="OutlineElement Ltr SCX56215701" style="margin-left: 0px">
<ul class="BulletListStyle1 SCX56215701">
 	<li class="OutlineElement Ltr SCX56215701" style="margin-left: 24px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span class="TextRun SCX56215701" style="color: windowtext;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">Signup and provision your own Hadoop cluster at <a href="http://azure.microsoft.com/">http://azure.microsoft.com/</a></span></span><span class="TextRun SCX56215701" style="color: windowtext;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">. You can use the free trial or when that's over pay for your usage. </span></span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></p>
</li>
 	<li class="OutlineElement Ltr SCX56215701" style="margin-left: 24px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span class="TextRun SCX56215701" style="color: windowtext;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">Use an emulator or sandbox. </span></span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></p>

<ul class="BulletListStyle2 SCX56215701">
 	<li class="OutlineElement Ltr SCX56215701" style="margin-left: 24px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span class="TextRun SCX56215701" style="color: #222a35;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit"><a href="http://azure.microsoft.com/en-us/documentation/articles/hdinsight-get-started-emulator/">Azure emulator</a> </span></span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></p>
</li>
</ul>
<blockquote style="margin-right: 0px">
<div class="OutlineElement Ltr SCX56215701" style="margin-left: 24px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span style="color: #000000"><span class="TextRun SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">I wish I would have known about the HDInsight Emulator a few months ago. It's good to know how to setup an HDInsight cluster in Azure. Also, getting remote access to your cluster in Azure is good as well. However, </span></span><span class="TextRun SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">once you do these things once it's simple to repeat. </span></span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></span></p>

</div>
<div class="OutlineElement Ltr SCX56215701" style="margin-left: 24px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span style="color: #000000"><span class="TextRun SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">However, when not using your HDInsight cluster in Azure you should <strong>delete it</strong> otherwise you'll be charged (unless you're using the free trial). Each time I wanted to learn something new about Hadoop I had to spin up a cluster, walk through tutorials and lastly delete the cluster. With the Azure emulator I could have avoided these 2 steps and a few $ bucks in charges. </span></span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></span></p>

</div>
<div class="OutlineElement Ltr SCX56215701" style="margin-left: 24px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span style="color: #000000"><span class="TextRun SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">Other than the emulator not having HBase I'm not aware of any other limitations... yet... </span></span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></span></p>

</div>
<div class="OutlineElement Ltr SCX56215701" style="margin-left: 24px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span style="color: #000000"><span class="TextRun SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">The emulator was very easy to install, very "hands off" and worked the first time. </span></span><span class="EOP SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt"> </span></span></p>

</div></blockquote>
<ul class="BulletListStyle2 SCX56215701">
 	<li class="OutlineElement Ltr SCX56215701" style="margin-left: 24px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span class="TextRun SCX56215701" style="color: #222a35;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit"><a href="http://hortonworks.com/products/hortonworks-sandbox/">Hortonworks Sandbox</a>. </span></span></p>
</li>
</ul>
<blockquote style="margin-right: 0px">
<div class="OutlineElement Ltr SCX56215701" style="margin-left: 24px">
<p class="Paragraph SCX56215701" style="text-align: left;color: windowtext;font-family: 'Segoe UI',Tahoma,Verdana,'Sans-Serif';font-size: 6pt;font-style: normal;font-weight: normal;vertical-align: baseline;background-color: transparent" xml:lang="EN-US"><span class="TextRun SCX56215701" style="color: #000000;line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit"><span class="TextRun SCX56215701" style="line-height: 17px;font-family: Calibri,Sans-Serif;font-size: 11pt" xml:lang="EN-US"><span class="NormalTextRun SCX56215701" style="background-color: inherit">Another option is to install the Hortonworks Sandbox linked above. </span></span>I haven't installed it yet since the Azure emulator is working fine for me. Hortonworks has plenty of docs and support in their forums for the sandbox. </span></span></p>

</div></blockquote>
</li>
</ul>
</div>]]></content:encoded>
    </item>
  </channel>
</rss>