<?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 Krishna Khadka on Medium]]></title>
        <description><![CDATA[Stories by Krishna Khadka on Medium]]></description>
        <link>https://medium.com/@khadkakrishna?source=rss-294bb85da8e4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BDVbG7Gox62PiJzm5dXZYw.jpeg</url>
            <title>Stories by Krishna Khadka on Medium</title>
            <link>https://medium.com/@khadkakrishna?source=rss-294bb85da8e4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 15:49:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@khadkakrishna/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[Delta Lake Optimization with Data Skipping]]></title>
            <link>https://khadkakrishna.medium.com/delta-lake-optimization-with-data-skipping-c9d2e78a1720?source=rss-294bb85da8e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9d2e78a1720</guid>
            <category><![CDATA[delta-lake]]></category>
            <category><![CDATA[databricks-sql]]></category>
            <category><![CDATA[databricks-delta-lake]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Krishna Khadka]]></dc:creator>
            <pubDate>Tue, 28 Jan 2025 12:05:09 GMT</pubDate>
            <atom:updated>2025-01-29T11:33:25.742Z</atom:updated>
            <content:encoded><![CDATA[<h3>Demystifying Optimization with Data Skipping</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ds3X9xO4m6DuqMEB" /><figcaption>Photo by <a href="https://unsplash.com/@growtika?utm_source=medium&amp;utm_medium=referral">Growtika</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Delta Lake provides optimizations like compaction, z-ordering, data-skipping, multi-part checkpoint, optimized write etc., that accelerate data lake operations. In this blog we will talk about Data Skipping also known as file skipping or file statistics.</p><h3>Data Skipping</h3><p>Data skipping information is collected automatically when you write data into a Delta Lake table. Delta Lake takes advantage of this information (count, nulls, minimum and maximum values for each column) at query time to provide faster queries.</p><h3>Benefits of Data Skipping</h3><ul><li><em>Improved Query Performance</em>: Queries become faster as fewer files are read and processed.</li><li><em>Cost Savings</em>: Reduces compute and storage I/O costs, especially for cloud-based data lakes.</li><li><em>Seamless Integration</em>: Data skipping works out of the box for Delta tables without additional configuration.</li></ul><h3>When Data Skipping is Most Effective</h3><ul><li><em>Highly Partitioned Tables</em>: Data skipping works well when data is partitioned along commonly queried dimensions.</li><li><em>Wide Range of Values</em>: Columns with continuous or well-distributed data (like timestamps or numeric ranges) benefit more from data skipping.</li><li><em>Selective Queries</em>: Queries with selective filters (e.g., specific date ranges or categorical values) make the most use of data skipping.</li></ul><h3>Configuration Changes</h3><ul><li><em>delta.dataSkippingNumIndexedCols</em> : Set the number of columns used for column level statistics. By default 32 columns.</li><li><em>delta.dataSkippingStatsColumns</em> : Specify a list of column names for which Delta Lake collects statistics. If not specified by default first 32 columns are considered. Note that, in case of struct or nested column each field will be considered as an individual column.</li></ul><pre>/* Setting Number of columns index (-1 means all columns) */    <br>SET spark.databricks.delta.properties.defaults.dataSkippingNumIndexedCols = -1  <br><br>/*Setting the list of columns used for stats to skip data */<br>SET spark.databricks.delta.properties.defaults.dataSkippingStatsColumns = [&quot;col1&quot;, &quot;col2&quot;]Example</pre><h3>Example</h3><p>Consider the following example where the id column is used for the data-skipping and we get the statistics generated for each of the files. Let’s say we have two files and hence two statistics are available. Here the query take the advantage of available statistics and process the query faster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gHizuPPCjeBtfnUv_7Q6pw.png" /><figcaption>Figure 1: Use of file statistics for Faster Query</figcaption></figure><h3>Best Practices to Enhance Data Skipping</h3><p>By combining data skipping, partitioning, and Z-Ordering, you can significantly boost the performance of your Delta Lake queries.</p><ol><li><strong>Partitioning</strong>: Partition the Delta table on columns frequently used in filter conditions (e.g., date).</li><li><strong>Z-Ordering</strong>: Use Z-Ordering to co-locate related data in the same files. For instance, if queries often filter by customerId, Z-Ordering on customerId can further enhance skipping.</li><li><strong>Optimize Command</strong>: Use Delta Lake’s <em>OPTIMIZE</em> command to compact small files and improve the efficiency of data skipping.</li></ol><pre>OPTIMIZE delta.`/path/to/table` ZORDER BY (customerId);</pre><p>4.<strong> Analyze Data</strong>: Run DESCRIBE DETAIL or DESCRIBE HISTORY commands to understand the statistics and layout of your data.</p><h3>Limitations</h3><ul><li><strong>Skewed Data</strong>: If data is unevenly distributed, data skipping might not be as effective.</li><li><strong>Frequent Updates</strong>: Constant updates can cause fragmentation, reducing the efficiency of data skipping.</li><li><strong>Complex Filters</strong>: Data skipping works best for simple filters like equality or range conditions. Complex joins or non-standard filters may not leverage it fully.</li></ul><h3>Considerations</h3><ul><li>All columns with a position index less than the <em>delta.dataSkippingNumIndexedCols</em> property will have statistics collected.</li><li>You can increase the number of indexed columns if queries on wide tables have very different patterns. However, indexing too many columns (more than a few) usually doesn’t provide much benefit, even with ZORDER BY.</li><li>Avoid collecting statistics on columns containing long values such as string and binary as these columns are truncated during statistics collection, set the columns containing long strings to an index position greater than the <em>delta.dataSkippingNumIndexedCols</em></li><li>You can alter the table order to directly place larger valued columns after the number of indexed columns using</li></ul><pre>ALTER TABLE CHANGE COLUMN &lt;column1&gt; &lt;FIRST | AFTER&gt; [column2];  <br><br>/* Examples of arranging columns */<br>ALTER TABLE orders CHANGE articleDate FIRST; <br>ALTER TABLE orders CHANGE summary AFTER lastVisitedDate;</pre><ul><li>If you have a situation in which you are unlikely to run SELECT queries against the table, you can reduce <em>delta.dataSkippingNumIndexedCols</em> value to <strong>avoid additional overhead from the write operations</strong>.</li><li>Changing this property affects how Delta Lake collects statistics for new or updated data but doesn’t recalculate statistics for existing data. To refresh stats for older data use:</li></ul><pre>ANALYZE TABLE &lt;table_name&gt; COMPUTE [DELTA] STATISTICS FOR COLUMNS &lt;col1&gt; [, ...]; <br> <br>/* Let&#39;s say we added column name city for order tables in dataSkippingStatsColumns */<br>ANALYZE TABLE orders COMPUTE DELTA STATISTICS FOR COLUMNS city;</pre><h3>References</h3><ul><li><a href="https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-aux-analyze-table.html">ANALYZE TABLE</a></li><li><a href="https://github.com/delta-io/delta/blob/master/PROTOCOL.md#per-file-statistics">delta/PROTOCOL.md at master · delta-io/delta</a></li><li><a href="https://docs.databricks.com/en/delta/data-skipping.html">Data skipping for Delta Lake</a></li><li><a href="https://docs.delta.io/latest/optimizations-oss.html">Optimizations</a></li><li><a href="https://www.google.com.sg/books/edition/Delta_Lake_The_Definitive_Guide/n6otEQAAQBAJ?hl=en&amp;gbpv=0">Delta Lake: The Definitive Guide</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9d2e78a1720" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EDA 4-plots in python]]></title>
            <link>https://khadkakrishna.medium.com/eda-4-plots-in-python-99a1374edacd?source=rss-294bb85da8e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/99a1374edacd</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[eda]]></category>
            <category><![CDATA[seaborn]]></category>
            <category><![CDATA[matplotlib]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Krishna Khadka]]></dc:creator>
            <pubDate>Sun, 17 Sep 2023 20:31:09 GMT</pubDate>
            <atom:updated>2023-09-17T20:31:09.688Z</atom:updated>
            <content:encoded><![CDATA[<p>The 4-plot comprises four distinct exploratory data analysis (EDA) graphical methods designed to assess the underlying assumptions of most measurement procedures. It includes the following components:<br>1. Run sequence plot<br>2. Lag plot<br>3. Histogram<br>4. Normal probability plot</p><p>Here is a brief about each of the four components of a 4-plot:</p><ol><li><strong>Run Sequence Plot:</strong> A run sequence plot is a graphical representation used in exploratory data analysis (EDA) to display data points in their sequential order. It helps identify trends, shifts, or patterns in the data over time. It is particularly useful for detecting outliers and assessing the stationarity of time series data.</li><li><strong>Lag Plot:</strong> A lag plot is a type of scatterplot used to visualize the relationship between a data point and a previous data point (lagged by a certain time period). It is mainly used in time series analysis to assess autocorrelation, which is the correlation of a series with a delayed version of itself. Lag plots help in identifying patterns and dependencies within time series data.</li><li><strong>Histogram:</strong> A histogram is a graphical representation of the distribution of data, showing the frequency or count of data points within specific intervals or bins. It provides insights into the shape and spread of the data distribution, highlighting whether it is symmetric, skewed, or bimodal. Histograms are useful for understanding the data’s central tendency and variability.</li><li><strong>Normal Probability Plot (Q-Q Plot):</strong> A normal probability plot, also known as a quantile-quantile (Q-Q) plot, is used to assess whether a dataset follows a normal (Gaussian) distribution. It compares the quantiles of the observed data to the quantiles of a theoretical normal distribution. If the points on the plot approximately align with a straight line, it suggests that the data follows a normal distribution. Deviations from the line indicate departures from normality.</li></ol><p>Here is a simple example using <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set">iris dataset</a>.</p><pre>import seaborn as sns<br>import matplotlib.pyplot as plt<br>import statsmodels.api as sm<br>import numpy as np<br><br>%matplotlib inline<br><br># Load the Iris dataset<br>iris = sns.load_dataset(&quot;iris&quot;)<br><br># Set the style of the plots<br>sns.set_style(&quot;whitegrid&quot;)<br><br># Create the subplots and add plots to each<br>fig, ax  = plt.subplots(2,2, figsize=(15, 10))<br>fig.suptitle(&#39;EDA 4-plots&#39;, fontsize=24)<br><br># Create a Run Sequence Plot<br>sns.lineplot(data=iris[&#39;sepal_length&#39;], color=&#39;#db2547&#39;, marker=&#39;o&#39;, ax = ax[0,0])<br>ax[0,0].set_title(&#39;Run Sequence Plot&#39;)<br><br># Create a lag plot<br>sns.scatterplot(x=iris[&#39;sepal_length&#39;].shift(1), y=iris[&#39;sepal_length&#39;], marker=&#39;o&#39;, s=50, color=&#39;#1a876c&#39;,  ax = ax[0,1])<br>ax[0,1].set_title(&#39;Lag Plot with shift=1&#39;)<br><br># Create a histogram<br>sns.histplot(data=iris, x=&#39;sepal_length&#39;, kde=True, color=&#39;#f2903f&#39;, ax = ax[1,0])<br>ax[1,0].set_title(&#39;Histogram&#39;)<br><br># Create a normal probability plot (Q-Q Plot)<br>sm.qqplot(iris[&#39;sepal_length&#39;], line=&#39;s&#39;, ax = ax[1,1])<br>ax[1,1].set_title(&#39;Normal Probability Plot&#39;)<br><br>fig.tight_layout()<br><br># Show the plots<br>plt.show()</pre><p>The plot will look as following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G5tD9eJIio6C-QJR3zZsRQ.png" /><figcaption>4-plots EDA using seaborn python</figcaption></figure><p>4-plots are valuable tools that can answer several key questions in data analysis and quality control:</p><ol><li><strong>Randomness</strong>: Are the data points indicative of randomness, or do they exhibit patterns or dependencies?</li><li><strong>Process Control</strong>: Are the data points indicating that the process is in control, stable, and predictable over time?</li><li><strong>Location Drift</strong>: Is the process drifting concerning its central location (e.g., mean or median)?</li><li><strong>Variation Drift</strong>: Is the process drifting concerning its variation (e.g., standard deviation)?</li><li><strong>Serial Dependence</strong>: Are there correlations between adjacent observations, especially in time series data?</li><li><strong>Distribution Fit:</strong> Does the data follow a normal distribution, or does it adhere to another distribution?</li><li><strong>Outlier Detection</strong>: Are there any outliers in the data that may require special attention or investigation?</li></ol><p>References:</p><p><a href="https://www.itl.nist.gov/div898/handbook/eda/section3/4plot.htm"><em>NIST 4-plot</em></a></p><p>Like and follow for more blogs. You can find my Linkedin profile <a href="https://www.linkedin.com/in/kkhadka/">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99a1374edacd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Boot and OAuth Integration]]></title>
            <link>https://khadkakrishna.medium.com/spring-boot-and-oauth-integration-441448809dc1?source=rss-294bb85da8e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/441448809dc1</guid>
            <category><![CDATA[spring-security]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[oauth]]></category>
            <dc:creator><![CDATA[Krishna Khadka]]></dc:creator>
            <pubDate>Sat, 18 Sep 2021 11:26:14 GMT</pubDate>
            <atom:updated>2021-09-18T11:26:14.241Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eURzkOUoPDy2Zg1JqpOJQw.png" /></figure><h3>Setup Github OAuth2 Tokens</h3><p>Go to <a href="https://github.com/settings/developers">https://github.com/settings/developers</a> to create a new OAuth application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xlfILcqtccT3jn8UKFm5nw.png" /></figure><p>Click on <em>register a new application</em> and fill the following details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lGLNkdAUWIZ1o5ir0wc7Ug.png" /></figure><p>Once you click on the <em>Register application</em>, tokens will be generated, you need client-id and client-secret keys for the application.</p><h3>Setup Spring Boot Application:</h3><ol><li>use Spring Initializer (https://start.spring.io/) or Spring Tool Suite (STS) IDE to generate the structure of the application, add Spring security, web, and oauth2 client as the dependencies for the application.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8_bNuT9m7fjImXTYLl4kMA.png" /></figure><p>2. The project structure would look something like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vLazxLv-KGYlOWSE4FRbbQ.png" /></figure><p>3. The pom.xml will contain the following dependencies:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GRoIGiCu0ZXOzrb37rh4Bw.png" /></figure><p>4. Create a class src/main/java/com/development/SpringOAuthApplication/config/WebSecurityConfig.java and add the following code to configure the authentication process.</p><pre>@Override<br>protected void configure(HttpSecurity httpSecurity) throws Exception {<br>    httpSecurity<br>            .authorizeRequests()<br>            .anyRequest()<br>            .authenticated()<br>            .and()<br>            .oauth2Login()<br>            .and()<br>            .formLogin()<br>    ;<br>}</pre><p>this will enable the OAuth as well as form-based login.</p><p>Let’s add a user so that we could log in using the form.</p><pre>@Bean<br>public UserDetailsService userDetailsService() {<br>    InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();<br>    manager.createUser(User.<em>withUsername</em>(&quot;user&quot;).password(&quot;{noop}password&quot;).roles(&quot;ADMIN&quot;).build());<br>    return manager;<br>}</pre><p>5. After login the user will be redirected to <a href="http://localhost:8080/">http://localhost:8080/</a></p><p>let’s create a RestAPI for that which returns hello on successful login. The path for the controller will be src/main/java/com/development/SpringOAuthApplication/controller/Controller.java and add the following code:</p><pre>@RestController<br>public class Controller {<br>    @GetMapping(&quot;/&quot;)<br>    public String index() {<br>        return &quot;Hello&quot;;<br>    }<br>}</pre><p>6. At last add the OAuth tokens of GitHub in src/main/resources/application.properties as following:</p><pre>spring.security.oauth2.client.registration.github.clientId = &lt;github-client-id&gt;<br>spring.security.oauth2.client.registration.github.clientSecret = &lt;github-client-secret&gt;<br><br>spring.security.oauth2.client.registration.google.clientId = &lt;google-client-id&gt;<br>spring.security.oauth2.client.registration.google.clientSecret = &lt;google-client-secret&gt;</pre><blockquote>Note: you can add other OAuth clients like google, facebook etc. for instance i added the google tokens as well.</blockquote><h3>Running the application</h3><p>To run the application use mvn spring-boot:run command.</p><p>The application will be deployed at <a href="http://localhost:8080/">http://localhost:8080</a> and you will be redirected to <a href="http://localhost:8080/login">http://localhost:8080/login</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lKhDR-q_Ful0BZbaqe-KVQ.png" /></figure><p>When you click on login with OAuth 2.0 google. you will be redirected to the login. Similarly, you will see the login screen for the GitHub OAuth.</p><p>Remember that we created a user for form login with username: user and password: password</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HBACj3YKdozRrTBBYLDfgQ.png" /></figure><p>This is the message is shown from RestAPI after successful login</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gkh8GqYghidJgcw9GR9gXQ.png" /></figure><p>Full Source Code: <a href="https://github.com/khadkakrishna/spring-boot-oauth-app/">https://github.com/khadkakrishna/spring-boot-oauth-app/</a></p><p>Thanks for reading, hope you liked the article, clap if you were able to deploy it and follow for more articles on java and spring boot.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=441448809dc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Polygeohasher: an optimized way to create geo-hashes]]></title>
            <link>https://khadkakrishna.medium.com/polygeohasher-an-optimized-way-to-create-geo-hashes-62df1ba2750f?source=rss-294bb85da8e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/62df1ba2750f</guid>
            <category><![CDATA[geospatial]]></category>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[geospatial-analytics]]></category>
            <category><![CDATA[geohash]]></category>
            <category><![CDATA[geospatial-intelligence]]></category>
            <dc:creator><![CDATA[Krishna Khadka]]></dc:creator>
            <pubDate>Wed, 08 Sep 2021 19:15:36 GMT</pubDate>
            <atom:updated>2021-09-08T19:15:36.632Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dhngepGZtwBeJwda" /></figure><h3>1. What is geohash?</h3><p>Geohash is the encoding technique used to convert geoareas into base-32 alphabet encoding (characters can be 0 to 9 and a to z, excluding ‘a’, ‘i’, ‘l’, and ‘o’). the size of the geohash polygon depends upon the geohash level i.e. 1 to 12.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wzSiKaWEeilhsXz3" /></figure><h3>2. How geohash mapping is done?</h3><p>The geohash level 1 divides the world into 32 parts and each part/cell is defined by the string of length1. While in geohash level-2 each geohash level-1 cell is divided further into 32 cells, each defined by the string of length 2 and so on. Therefore, the number of letters /alphabets in the string represents the level if geohash.</p><p>As shown in the figure the world is divided into 32 geohashes of level-1 having an area of 5000x5000 kmsq. and if we go to geohash level 2 the cells are further divided into 32 parts each of area 1250x625 kmsq. level-3 geohashing will make cells with an area of 156x156 kmsq. Therefore as the geohash level increases, the area decreases, hence precision increases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hDSAy4FdX4Cg47MR" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IkOL1EHHE6WTG8yn" /></figure><h3>3. How creating geohash can be beneficial?</h3><p>A geohash is a string representation of a particular geo-polygon that is easy to remember and use, as compared to keeping track of longitudes and latitudes or points or the polygons.</p><ul><li>Proximity searches: discover the nearby locations and places of interest, number of restaurants or malls established in a particular region.</li><li>Social Networking: dating apps to find matches within a particular area, number of people using applications in a particular cell.</li></ul><h3>4. What is the need of optimizing the geohashing Technique?</h3><p>Only one type of geohash division for an area is not advantageous as that approach will have some issues:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YOGRn4zAhFxxwmkH" /></figure><p>Suppose we have the geometry of the city represented by four polygons joined together. Now, we want to create geohashes for the city.</p><p>While creating the geohash we have to choose a level that will divide the polygon into further cells according to the need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IU8xizgpU_VMjGCO" /></figure><p>Consider we choose a low precision geohash with respect to area i.e. geohash level-5 and in this case, the number of geohashes will be less and the area of each cell will be 4.89x4.89 kmsq.</p><p>The disadvantage of using this geohash level is that the area outside the boundary is also being added to the polygon although that is not the part of the city.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KKG4cIZfjpSwSWLK" /></figure><p>To overcome the issue of inclusion of the outer boundary areas, we can choose the high precision geohash level i.e. level-6. In this case, the area of each cell will be 1.22x0.61 kmsq.</p><p>The disadvantage of using this geohash level is that the no. of polygons increased by more than 30 folds which results in high computation and processing time.</p><p>What could be the solution?</p><p>Here appears the use of an optimized way to create geohash i.e. using the combination of two or more geohashes according to requirement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ht_xbWBYFmvT1PGX" /></figure><p>So, the division of polygon into two geohash levels i.e. level-5 and level-6 result in a 67% reduction of the number of polygons as compared to geohash level-6.</p><p>Hence using this optimized geohash division approach we can reduce the number of cells and the outer boundary area issue is also resolved.</p><h3>5. How polygeohasher can be used as an optimized way to create geohash?</h3><p>polygeohasher is PyPi registered library that can be installed through pip or can be downloaded from this <a href="https://pypi.org/project/polygeohasher/#description">link</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UQFb5dbjx17CNR3_" /></figure><p>1.import the polygeohasher and load the geojson file of the city/area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O0ehc7yQMmKf2IDl" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a1-GgjlI6gg_NvoH" /></figure><p>2. create a geohash layer of maximum precision as the primary dataframe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Uy98QOyEbAPrWm3g" /></figure><p>inner=False indicates we are taking values outside of the boundaries, if True only polygons lying inside are considered.</p><p>3. create an optimized geohash dataframe by passing parameters: primart_dataframe, maximum_geohash_level, minimum_geohash_level, input_geohash_level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UwCL63oW_5e2Ry_N" /></figure><p>4. calculate the optimization summary</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MAQICUzzkCMMUiIu" /></figure><p>5. save the new geojson file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WSQOoZs5k8LEl1Lp" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mx6QBkxiPD242Gdq" /></figure><h3>End Notes:</h3><ul><li>The PyPI project is available at <a href="https://pypi.org/project/polygeohasher/">https://pypi.org/project/polygeohasher/</a></li><li>The Github repository <a href="https://github.com/rohitsinghsalyan/polygeohasher">https://github.com/rohitsinghsalyan/polygeohasher</a></li></ul><p>if you like this article, please like and share, and star the repository on Github.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62df1ba2750f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Spring Boot with Angular Application]]></title>
            <link>https://khadkakrishna.medium.com/integrating-spring-boot-with-angular-application-c4a1ad114da5?source=rss-294bb85da8e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4a1ad114da5</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Krishna Khadka]]></dc:creator>
            <pubDate>Wed, 08 Sep 2021 19:06:13 GMT</pubDate>
            <atom:updated>2021-09-08T19:06:13.431Z</atom:updated>
            <content:encoded><![CDATA[<h3>Integrating Spring Boot with Angular</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_1LmpV4ynBsPaITU" /></figure><p>After struggling for a while to integrate Spring Boot with Angular, I decided to write an article so that it would be easy for someone else to do the same by simply referring to the following steps.</p><h3>Setup Spring Boot Application</h3><ol><li>You can either use Spring Initializer (https://start.spring.io/) or Spring Tool Suite (STS) IDE. I prefer to use a spring initializer as it is easy to use.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fks807nTgBcmSB0C" /></figure><p>2. Once done, import the project into the IDE. The structure of the project would look something similar to the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*KDzUFCdrFsujmEMD" /></figure><p>3. If you run the project, you will see a login form at <a href="http://localhost:8080,">http://localhost:8080,</a> for which username would be user and password would be printed on the terminal as Using generated security password: 048c1fa9-f656–4191-a939–64967ae259ee. This is the default screen provided by Spring Boot Security</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OsMGuWJK7wWellB-" /></figure><h3><strong>Setup Angular Application</strong></h3><ol><li>Install npm and nodejs, then install angular-cli. Create a new Angular project by running the command: ng new AngularApplication</li></ol><ul><li>Note: you can create the angular project anywhere, I prefer to create inside /src/main/resources</li></ul><p>2. Once done, go to the angular application directory and run ng serve, you will see the angular application running at <a href="http://localhost:4200/">http://localhost:4200</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EzUtfjy7G1-SYrTU" /></figure><h3>Integrating Spring Application with Angular</h3><p>Currently, Spring boot is running at port 8080 and angular is running at port 4200, to integrate the angular application with spring application follow the below steps:</p><ol><li>Change the output path of the angular application, i.e. whenever the ng build command will run the build files will be stored in the src/main/resources/static folder.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*05XdGsNgrYhyn6hc" /></figure><p>2. Open pom.xml and add the exec-maven-plugin dependency as it is required to run ng build whenever we will build the spring app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pLMr2-I7hMG7XWu5" /></figure><p>3. Add the plugin to run while building the spring application as below. I have added angular build command prior to the spring as I want to build angular application before spring boot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EW-fdeKAcIV9Drvc" /></figure><p>Now run the <em>mvn clean package</em> or <em>mvn clean install</em>, this will create a jar as <em>target/SpringAngularApplication-0.0.1-SNAPSHOT.jar</em></p><p>To deploy the jar run the following command:</p><p><em>java -jar target/SpringAngularApplication-0.0.1-SNAPSHOT.jar</em></p><p>The application will be up at <a href="http://localhost:8080/"><em>http://localhost:8080</em></a></p><p>For complete code refer to this <a href="https://github.com/khadkakrishna/spring-boot-angular-app">GitHub repo</a></p><p>Hit like and follow for more posts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4a1ad114da5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>