You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@baremaps.apache.org by ad...@apache.org on 2022/12/01 09:47:24 UTC
[incubator-baremaps] branch main updated: Order IP to location by size of IP range (#543)
This is an automated email from the ASF dual-hosted git repository.
adrabble pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
The following commit(s) were added to refs/heads/main by this push:
new 970e36f2 Order IP to location by size of IP range (#543)
970e36f2 is described below
commit 970e36f27f42294be8b87796c85e215455f21337
Author: Antoine Drabble <an...@gmail.com>
AuthorDate: Thu Dec 1 10:47:19 2022 +0100
Order IP to location by size of IP range (#543)
* Sort SQL query by IP range start
* Sort by IP start DESC then IP end ASC
* Use triple double quotes
---
.../database/InetnumLocationDaoSqliteImpl.java | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/iploc/database/InetnumLocationDaoSqliteImpl.java b/baremaps-core/src/main/java/org/apache/baremaps/iploc/database/InetnumLocationDaoSqliteImpl.java
index 66f147d6..3437eeb0 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/iploc/database/InetnumLocationDaoSqliteImpl.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/iploc/database/InetnumLocationDaoSqliteImpl.java
@@ -36,15 +36,19 @@ import org.sqlite.SQLiteDataSource;
public final class InetnumLocationDaoSqliteImpl implements InetnumLocationDao {
private static final String INSERT_SQL =
- "INSERT INTO inetnum_locations(address, ip_start, ip_end, latitude, longitude, network, country) VALUES(?,?,?,?,?,?,?)";
-
- private static final String SELECT_ALL_SQL =
- "SELECT " + "id, \n" + "address, \n" + "ip_start, \n" + "ip_end, \n" + "latitude, \n"
- + "longitude, \n" + "network, \n" + "country \n" + " FROM inetnum_locations;";
-
- private static final String SELECT_ALL_BY_IP_SQL = "SELECT " + "id, \n" + "address, \n"
- + "ip_start, \n" + "ip_end, \n" + "latitude, \n" + "longitude, \n" + "network, \n"
- + "country FROM inetnum_locations WHERE ip_start <= ? AND ip_end >= ?;";
+ """
+ INSERT INTO inetnum_locations(address, ip_start, ip_end, latitude, longitude, network, country)
+ VALUES(?,?,?,?,?,?,?)""";
+
+ private static final String SELECT_ALL_SQL = """
+ SELECT id, address, ip_start, ip_end, latitude, longitude, network, country
+ FROM inetnum_locations;""";
+
+ private static final String SELECT_ALL_BY_IP_SQL = """
+ SELECT id, address, ip_start, ip_end, latitude, longitude, network, country
+ FROM inetnum_locations
+ WHERE ip_start <= ? AND ip_end >= ?
+ ORDER BY ip_start DESC, ip_end ASC;""";
private static final Logger logger = LoggerFactory.getLogger(InetnumLocationDaoSqliteImpl.class);