[
https://issues.apache.org/jira/browse/SDAP-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16399558#comment-16399558
]
ASF GitHub Bot commented on SDAP-49:
------------------------------------
ntquach closed pull request #13: SDAP-49 Update NEXUS tile service to return
count of tiles matched
URL: https://github.com/apache/incubator-sdap-nexus/pull/13
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/data-access/nexustiles/dao/SolrProxy.pyx
b/data-access/nexustiles/dao/SolrProxy.pyx
index d99ebad..13c9c81 100644
--- a/data-access/nexustiles/dao/SolrProxy.pyx
+++ b/data-access/nexustiles/dao/SolrProxy.pyx
@@ -565,6 +565,41 @@ class SolrProxy(object):
)
return time_clause
+ def get_tile_count(self, ds, bounding_polygon=None, start_time=0,
end_time=-1, metadata=None, **kwargs):
+ """
+ Return number of tiles that match search criteria.
+ :param ds: The dataset name to search
+ :param bounding_polygon: The polygon to search for tiles
+ :param start_time: The start time to search for tiles
+ :param end_time: The end time to search for tiles
+ :param metadata: List of metadata values to search for tiles e.g
["river_id_i:1", "granule_s:granule_name"]
+ :return: number of tiles that match search criteria
+ """
+ search = 'dataset_s:%s' % ds
+
+ additionalparams = {
+ 'fq': [
+ "tile_count_i:[1 TO *]"
+ ],
+ 'rows': 0
+ }
+
+ if bounding_polygon:
+ min_lon, min_lat, max_lon, max_lat = bounding_polygon.bounds
+ additionalparams['fq'].append("geo:[%s,%s TO %s,%s]" % (min_lat,
min_lon, max_lat, max_lon))
+
+ if 0 < start_time <= end_time:
+
additionalparams['fq'].append(self.get_formatted_time_clause(start_time,
end_time))
+
+ if metadata:
+ additionalparams['fq'].extend(metadata)
+
+ self._merge_kwargs(additionalparams, **kwargs)
+
+ results, start, found = self.do_query(*(search, None, None, True,
None), **additionalparams)
+
+ return found
+
def do_query(self, *args, **params):
response = self.do_query_raw(*args, **params)
diff --git a/data-access/nexustiles/nexustiles.py
b/data-access/nexustiles/nexustiles.py
index 1330c03..90622ae 100644
--- a/data-access/nexustiles/nexustiles.py
+++ b/data-access/nexustiles/nexustiles.py
@@ -364,6 +364,18 @@ def mask_tiles_to_time_range(self, start_time, end_time,
tiles):
return tiles
+ def get_tile_count(self, ds, bounding_polygon=None, start_time=0,
end_time=-1, metadata=None, **kwargs):
+ """
+ Return number of tiles that match search criteria.
+ :param ds: The dataset name to search
+ :param bounding_polygon: The polygon to search for tiles
+ :param start_time: The start time to search for tiles
+ :param end_time: The end time to search for tiles
+ :param metadata: List of metadata values to search for tiles e.g
["river_id_i:1", "granule_s:granule_name"]
+ :return: number of tiles that match search criteria
+ """
+ return self._metadatastore.get_tile_count(ds, bounding_polygon,
start_time, end_time, metadata, **kwargs)
+
def fetch_data_for_tiles(self, *tiles):
nexus_tile_ids = set([tile.tile_id for tile in tiles])
diff --git a/data-access/tests/solrproxy_test.py
b/data-access/tests/solrproxy_test.py
index 6490baa..73936a7 100644
--- a/data-access/tests/solrproxy_test.py
+++ b/data-access/tests/solrproxy_test.py
@@ -76,3 +76,10 @@ def test_find_all_tiles_by_metadata(self):
result =
self.proxy.find_all_tiles_by_metadata(['granule_s:19811114120000-NCEI-L4_GHRSST-SSTblend-AVHRR_OI-GLOB-v02.0-fv02.0.nc'],
ds="AVHRR_OI_L4_GHRSST_NCEI")
print len(result)
+
+ def test_get_tile_count(self):
+ tile_count = self.proxy.get_tile_count("AVHRR_OI_L4_GHRSST_NCEI",
bounding_polygon=box(-180, -90, 180, 90),
+ start_time=1,
end_time=time.time(),
+
metadata=['granule_s:19811114120000-NCEI-L4_GHRSST-SSTblend-AVHRR_OI-GLOB-v02.0-fv02.0.nc'])
+
+ print(tile_count)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Update NEXUS tile service to return count of tiles matched
> ----------------------------------------------------------
>
> Key: SDAP-49
> URL: https://issues.apache.org/jira/browse/SDAP-49
> Project: Apache Science Data Analytics Platform
> Issue Type: Improvement
> Reporter: Nga Chung
> Assignee: Nga Chung
> Priority: Major
>
> To optimize NEXUS analysis algorithms, we need a way to return just the count
> of tiles that match a specified query without returning any tile data.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)