<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aman Mittal on Medium]]></title>
        <description><![CDATA[Stories by Aman Mittal on Medium]]></description>
        <link>https://medium.com/@amanmittal1990?source=rss-bd0c62de0215------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RtKCpQX69QmtYPYx.</url>
            <title>Stories by Aman Mittal on Medium</title>
            <link>https://medium.com/@amanmittal1990?source=rss-bd0c62de0215------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 17:06:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amanmittal1990/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Custom Processor Apache NiFi — Eclipse]]></title>
            <link>https://medium.com/@amanmittal1990/custom-processor-apache-nifi-eclipse-dd5c44bbea88?source=rss-bd0c62de0215------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd5c44bbea88</guid>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[nifi]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[apache-nifi]]></category>
            <dc:creator><![CDATA[Aman Mittal]]></dc:creator>
            <pubDate>Wed, 20 May 2020 10:39:10 GMT</pubDate>
            <atom:updated>2020-08-18T18:52:46.009Z</atom:updated>
            <content:encoded><![CDATA[<h3>Apache NiFi Custom Processor in Eclipse</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TwHNdofXQJFT3FM_pNmo1g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@tekton_tools?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Tekton</a> on <a href="https://unsplash.com/s/photos/mechanic?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>As a Data Engineer we are constantly working on developing data pipelines using various tools , frameworks ,etc which can deliver data fast and efficiently. Data pipelines involve heavy lift and shift operations with the data from one source to another , for the same purpose I use Apache NiFi which is an open source JAVA based software product from Apache Foundation which automate the flow of data between software systems.</p><h3>Apache NiFi Processor</h3><p>A NiFi Processor is the basic building block for creating an Apache NiFi data flow. Processors provide an interface through which NiFi provides access to a flow-file, its attributes and its content. NiFi also provides capability to create your custom processor which can provides a way to perform different operations or to transform flow-file content according to objective.</p><p>In this post I am going to let you know how to create custom processor for NiFi in Eclipse using Maven Archetype of NiFi</p><h3>Creating a Custom Apache NiFi Processor in Eclipse IDE</h3><h3>Pre-requisites:</h3><ul><li>Eclipse IDE is installed on your local machine .</li><li>Maven project plugin in eclipse IDE.</li></ul><h3><strong>Steps :</strong></h3><ol><li>Add remote maven archetype in eclipse :</li></ol><p><strong>Windows &gt;&gt; preferences &gt;&gt; Archetypes &gt;&gt; Add Remote Catalog</strong></p><p><strong>Catalog File :</strong> <a href="https://repo.maven.apache.org/maven2/archetype-catalog.xml">https://repo.maven.apache.org/maven2/archetype-catalog.xml</a></p><p>Add description as <strong><em>maven catalog</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*KJ1oersIhbjnv7JJc5YI1g.png" /><figcaption><strong>Windows &gt;&gt; preferences &gt;&gt; Archetypes &gt;&gt; Add Remote Catalog</strong></figcaption></figure><p>Above step will load all the remote archetypes of maven repository when we will create a new maven project with NiFi archetype .</p><p>2. Create Maven project :</p><p><strong>File &gt;&gt; New &gt;&gt; Project &gt;&gt; Maven Project</strong></p><p>Select Maven Catalog from the drop down and filter string as NiFi and select <strong>nifi-processor-bundle-archetype</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*RfPW_mmYJ-NVfOlQ5jXKew.png" /></figure><p>3 . Provide groupId , ArtifactId in the next step . You can provide your standard groupId and artifact name. I have added for sample only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*aD0hF82RGeL-GRBj6EMzfg.png" /></figure><p>4. Once you click on finish it will create a project in eclipse with the name of Myprocessor</p><p>Then go to Myprocessor project and run <strong>mvn : clean install</strong></p><p>5 . A nar file will be created in the Myprocessor basename directory with the extention of<strong><em> “.nar” .</em></strong></p><p>6 . Copy the nar file into the lib directory of Apache Nifi and restart the application .</p><p>By above steps you will be able to see the processor in the Nifi UI . You can add custom code for any specific source based on your scenario or you can modify the existing processor code as well .</p><p>If you face any issues please don’t forget to mention in comments and if this post helped you please share a clap for me .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd5c44bbea88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reading BigQuery table in PySpark]]></title>
            <link>https://medium.com/@amanmittal1990/reading-bigquery-table-in-pyspark-cb79de236908?source=rss-bd0c62de0215------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb79de236908</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Aman Mittal]]></dc:creator>
            <pubDate>Thu, 25 Jul 2019 11:58:31 GMT</pubDate>
            <atom:updated>2019-07-25T17:05:12.742Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y0utE1TVjskJptme" /><figcaption>Photo by <a href="https://unsplash.com/@casparrubin?utm_source=medium&amp;utm_medium=referral">Caspar Camille Rubin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This post let’s you read the data from google cloud BigQuery table using BigQuery connector with Spark on local windows machine.</p><h3>Pre-requisites:</h3><ul><li><strong>Setup Spark development Environment </strong>— You can follow <a href="https://kaizen.itversity.com/setup-spark-development-environment-pycharm-and-python/">this </a>article to setup spark development Environment(Python 3 and spark-2.4.3 for hadoop 2 compatible) .</li><li><strong>Download BigQuery Connector</strong> — You can download the BigQuery connector Jar from <a href="https://github.com/ammitt90/google_cloud_example">here</a></li></ul><pre><strong>Note : </strong><em>Add the downloaded BigQuery connector jar to </em><strong><em>$SPARK_HOME/jars </em></strong><em>folder on your local machine where you have installed the spark</em></pre><h4>Let’s start coding…</h4><ul><li>Go to File&gt;New&gt;Python File .</li><li>Name the file as <strong>pysparkDemo.py</strong></li><li>Add the below code snippet step by step</li></ul><h4>1. Import libraries</h4><p>Add the below code to import the required python libraries for spark .</p><pre><strong>from </strong>__future__ <strong>import </strong>absolute_import<br><strong>import </strong>json<br><strong>import </strong>pprint<br><strong>import </strong>subprocess<br><strong>import </strong>pyspark<br><strong>from </strong>pyspark <strong>import </strong>SparkConf<br><strong>from </strong>pyspark.sql <strong>import </strong>SQLContext</pre><h4>2. Initialize SparkContext :</h4><p>Below code snippet initialized spark configuration object and creates spark context .</p><pre>sc_conf = SparkConf()<br>sc_conf.setAppName(<strong>&quot;testApp&quot;</strong>) // your spark application name<br>sc_conf.setMaster(<strong>&#39;local[*]&#39;</strong>) // specify master to run on local mode<br>sc = pyspark.SparkContext(conf=sc_conf)</pre><h4>3. Add Configuration</h4><p>Add below lines to create google cloud configuration params. Pyspark uses bucket location for map reduce operations as staging location for BigQuery import.</p><pre><em>#Use the Cloud Storage bucket for temporary BigQuery export<br></em>bucket = sc._jsc.hadoopConfiguration().get(<strong>&#39;</strong>fs.gs.system.bucket<strong>&#39;</strong>)<br>project = sc._jsc.hadoopConfiguration().get(<strong>&#39;</strong>fs.gs.project.id<strong>&#39;</strong>)<br><br>input_directory = <strong>&quot;gs://{BUCKET_NAME}/{FOLDER_NAME}&quot;</strong>.format(bucket)<br>conf = {<br>    <em># Input Parameters.<br>    </em><strong>&#39;</strong>mapred.bq.project.id<strong>&#39;</strong>: <strong>&#39;&lt;<em>Google cloud project name</em>&gt;&#39;</strong>,<br>    <strong>&#39;</strong>mapred.bq.gcs.bucket<strong>&#39;</strong>: <strong>&#39;&lt;<em>BUCKET_NAME</em>&gt;&#39;</strong>,<br>    <strong>&#39;</strong>mapred.bq.temp.gcs.path<strong>&#39;</strong>: input_directory,<br>    <strong>&#39;</strong>mapred.bq.input.project.id<strong>&#39;</strong>: <strong>&#39;&lt;<em>Google cloud project name</em>&gt;&#39;</strong>,<br>    <strong>&#39;</strong>mapred.bq.input.dataset.id<strong>&#39;</strong>: <strong>&#39;&lt;<em>BigQuery Data set name/id</em>&gt;&#39;</strong>,<br>    <strong>&#39;</strong>mapred.bq.input.table.id<strong>&#39;</strong>: <strong>&#39;athletes&#39;</strong>,<br>    <strong>&#39;</strong>google.cloud.auth.service.account.enable<strong>&#39;</strong>: <strong>&#39;true&#39;</strong>,<br>    <strong>&#39;</strong>google.cloud.auth.service.account.json.keyfile<strong>&#39;</strong>: <strong>&quot;&lt;<em>path to     key.json file</em>&gt;&quot;<br></strong>}</pre><h4>4.<em>Load data in from BigQuery</em></h4><pre>table_data = sc.newAPIHadoopRDD(<strong>&#39;</strong>com.google.cloud.hadoop.io.bigquery.JsonTextBigQueryInputFormat&#39;,&#39;org.apache.hadoop.io.LongWritable&#39;,  &#39;com.google.gson.JsonObject&#39;<strong>,</strong>conf=conf)</pre><h4>5.Create SqlContext</h4><p>Add below lines to read table_data in spark dataframes</p><pre>sql_context = SQLContext(sc)<br>wordT = table_data.map(<strong>lambda </strong>x : x[1])<br>tableDf=sql_context.read.json(wordT)</pre><h4>6.Display output</h4><pre>tableDf.show()</pre><h4>7.Delete temporary bucket files</h4><pre>input_path = sc._jvm.org.apache.hadoop.fs.Path(input_directory)<br>input_path.getFileSystem(sc._jsc.hadoopConfiguration()).delete(input_path, <strong>True</strong>)</pre><h4>8.Execute spark job from command line</h4><pre>spark-submit &lt;python file&gt; </pre><h3>Conclusion</h3><p>If you try this out and face any issues please don’t forget to mention those in comments..</p><h3>References</h3><p><a href="https://cloud.google.com/dataproc/docs/tutorials/bigquery-connector-spark-example"><em>https://cloud.google.com/dataproc/docs/tutorials/bigquery-connector-spark-example</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb79de236908" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ORC V/S TextInputOutput Format !!]]></title>
            <link>https://medium.com/@amanmittal1990/orc-v-s-textinputoutput-format-7f7e4b76b451?source=rss-bd0c62de0215------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f7e4b76b451</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[hadoop]]></category>
            <dc:creator><![CDATA[Aman Mittal]]></dc:creator>
            <pubDate>Thu, 24 May 2018 18:56:57 GMT</pubDate>
            <atom:updated>2018-05-25T11:14:35.780Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9J62HlkNNFKEiaiPrOye8g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/NDfqqq_7QWM?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Chris Liverani</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>This post reads about the Bench marking of the query time for TextInputOutput and ORC formats in hadoop . While working on Apache nifi and recording benchmarks of fetching data from hive and uploads to Azure and google cloud storage for AVRO and CSV , I was surprised to know that CSV file size (with default delimeter “,”) was lower as compared to AVRO file size instead the avro is considered to be compressed data format and the fetch time for ORC table was ~5 times faster than the text input output format.</p><p>Following post reads about my findings :</p><p>My Use Case :</p><p>Step 1 : Fetch data from hive in both AVRO and CSV file formats.</p><p>Step 2 : Upload the data to Azure storage containers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sRclMgjugdQz6t2nx9GmIA.png" /><figcaption>Simple flow of fetching data from hive and upload to Azure without compression</figcaption></figure><p>While recording the benchmarks of the steps involved from two different tables with same data but different I/O types produced very large difference in fetch time from hive .</p><p>Table 1 :<strong>Text I/O type of hive table</strong></p><p>Query : Select * from &lt;table name&gt;</p><p>Query Execution Engine : Map reduce</p><p>Fetch time of 1000000 records from hive was around ~15 minutes for CSV and around ~18 minutes for AVRO and the file size for csv was 1.18GB and for AVRO it was 1.26GB.</p><p>Table 2 : <strong>ORC I/O type of hive table</strong></p><p>Fetch time of 1000000 records from hive was around ~4 minutes for CSV and around ~3.7 minutes for AVRO and file sizes were same as above mentioned.</p><p>Avro file size was comparatively larger than CSV as It contains the schema along with the data .</p><p>TextInputOutput format is default raw data format without compression and ORC is 75% compressed .</p><p>Above statistics practically proved the ORC being the winner in optimization of the query time from hive . I will suggest the hadooper’s to try this out and keep exploring .</p><p>This short finding might help beginners to not create table with default type and choose like ORC,Parquet,Avro based on the query and usage .</p><p>Reference link : <a href="https://www.slideshare.net/HadoopSummit/file-format-benchmark-avro-json-orc-parquet">https://www.slideshare.net/HadoopSummit/file-format-benchmark-avro-json-orc-parquet</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f7e4b76b451" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Need to know Java before stepping into Big Data world ??]]></title>
            <link>https://medium.com/@amanmittal1990/need-to-know-java-before-stepping-into-big-data-world-5141af8ee6c3?source=rss-bd0c62de0215------2</link>
            <guid isPermaLink="false">https://medium.com/p/5141af8ee6c3</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[hadoop]]></category>
            <dc:creator><![CDATA[Aman Mittal]]></dc:creator>
            <pubDate>Mon, 16 Apr 2018 19:01:47 GMT</pubDate>
            <atom:updated>2018-04-16T19:01:47.136Z</atom:updated>
            <content:encoded><![CDATA[<p>In this digital era and data driven world which definitely gives temptations to every IT person to boost career growth switching to big data technology ,but the question which confuses every non Java person is DO I NEED TO GRASP ALL THE JAVA ??? My Answer would be probably NO.</p><p>This Article might help to answer this confusion ..</p><p>Hadoop is an open source framework which is built in Java and every hadoop job is converted into java code by the framework itself before it is executed .Hadoop works on the concept of MapReduce which has two phases Map phase and reduce Phase . One need not to be a java expert to learn hadoop , If you are familiar with OOPs concepts then that is more than enough to get you going ..</p><p>Below are some of the topics in Java which can be covered beforehand and load your mind to start with hadoop:</p><p>a)Class and Objects in Java</p><p>b)Inheritance</p><p>c)Polymorphism</p><p>d)Encapsulation</p><p>e)Collection (HashMap,ArrayList)</p><p>f)String manipulations</p><p>g)Regular expressions Basics (not mandatory for initial start)</p><p>h)File reader /File InputStream / File OutputStream and other file operations</p><p>If one can do some hands on on the above topics in java its good to get started with map reduce which the gate to enter into big data world . Write some sample word count programs in java and then move to next set of tools .</p><p>Rest of the tools in hadoop ecosystem demands sql knowledge which I believe most of do have some basic understanding like Select,Create,drop,truncate from a relational table .</p><p>Being a Java programmer and interest for Sql I never had tough time dealing with the concepts of big data . It was a win win situation when I started learning about hadoop ecosystem . But based on my experience I would probably say that a basic understanding of OOPs / sql will make your task much easier to get yourself comfortable in big data world .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5141af8ee6c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Publish events to PubSub Topics using Apache Ni-Fi]]></title>
            <link>https://medium.com/google-cloud/publish-events-to-pubsub-topics-using-apache-ni-fi-8adc513e8068?source=rss-bd0c62de0215------2</link>
            <guid isPermaLink="false">https://medium.com/p/8adc513e8068</guid>
            <category><![CDATA[apache-nifi]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[pub-sub]]></category>
            <dc:creator><![CDATA[Aman Mittal]]></dc:creator>
            <pubDate>Fri, 13 Apr 2018 19:05:26 GMT</pubDate>
            <atom:updated>2018-04-13T19:05:26.459Z</atom:updated>
            <content:encoded><![CDATA[<p>Apache Nifi is a real time event processing platform which can be used for data movement between disparate systems .</p><p>NiFi can also be used to connect to cloud services such as AWS,Google cloud or Microsoft Azure using the built in processors for moving data across the cloud platforms.</p><p>Following story is about publishing the real time events to google cloud pub-sub whenever any new object is created in the google cloud storage bucket .</p><p>PubSub is a publish and subscribe platform on google cloud which can be used for event processing or can be used as data communication channel between the systems just like other messaging systems .</p><p>Following are the steps which can be used to build a workflow in order to publish the OBJECT_FINALIZE event of google cloud storage to a pub-sub topic.</p><p>Use Case :</p><p>Select data from hive table , convert the file attributes like file name ,file format (Avro/Csv) and write the file to GCS storage bucket and send notification to pub sub topic with message attributes like (filename , table name,row count,file creation date,etc)</p><ol><li>Create a topic in Google cloud pub sub using your console.cloud.google.com</li><li>Create a NiFi flow by dragging the following processors to the nifi canvas</li></ol><p>SelectHiveQl,UpdateAttributes,PutGCSObject</p><p>3.Add the required controller configurations :</p><p>a)hivecontroller service to enable connection to your hive server and database.</p><p>b)GCSController service to enable connection to your google cloud storage instance</p><p>4)Download the custom pubsub processor code from the below and build the nar package and add it to nifi lib folder</p><p><a href="https://github.com/ammitt90/nifi_pub-sub_processor">ammitt90/nifi_pub-sub_processor</a></p><p>5)Add the above processor to the canvas and connect it to the putgcsobject processor . Add the topic name and project configuration in the configurations tab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*SlFawVLcnTamHkWGbsgbZQ.png" /><figcaption>Nifi PubSub flow</figcaption></figure><p>The above flow will publish the Json event to the pubsub topic mentioned in the GCPPubSubPublisher processor with the metadata of the file written in storage bucket . (It will not send the file contents to the pubsub instead it will just send and event notification that there is a new file or object available in the bucket for consumption or processing)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8adc513e8068" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/publish-events-to-pubsub-topics-using-apache-ni-fi-8adc513e8068">Publish events to PubSub Topics using Apache Ni-Fi</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>