You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "Jeff Johnson (Created) (JIRA)" <ji...@apache.org> on 2011/10/17 02:56:11 UTC

[Lucene.Net] [jira] [Created] (LUCENENET-448) GeoHashFilteredDocIdSet does not work at all

GeoHashFilteredDocIdSet does not work at all
--------------------------------------------

                 Key: LUCENENET-448
                 URL: https://issues.apache.org/jira/browse/LUCENENET-448
             Project: Lucene.Net
          Issue Type: Bug
          Components: Lucene.Net Contrib
    Affects Versions: Lucene.Net 2.9.4
         Environment: Windows 7 x64
            Reporter: Jeff Johnson
             Fix For: Lucene.Net 2.9.4


The GeoHashFilteredDocIdSet is assuming the values are always in the cache which is wrong. A proposed fix for the method is listed here for GeoHashDistanceFilter.cs:

public GeoHashFilteredDocIdSet(DocIdSet innerSet, string[] geoHashValues, Dictionary<string, double> distanceLookupCache, double lat, double lng, int docBase, double distance, Dictionary<int, double> distances) 
                : base(innerSet , (docid) => /* was: public override Match */
			{
				String geoHash = geoHashValues[docid];
				double[] coords = GeoHashUtils.Decode(geoHash);
				double x = coords[0];
				double y = coords[1];

				double cachedDistance;
                distanceLookupCache.TryGetValue(geoHash, out cachedDistance);
				double d;

				if (cachedDistance > 0)
				{
					d = cachedDistance;
				}
				else
				{
					d = DistanceUtils.GetInstance().GetDistanceMi(lat, lng, x, y);
					distanceLookupCache[geoHash] = d;
				}

				if (d < distance)
				{
					distances[docid + docBase] = d;
					return true;
				}
				
				return false;
			})
			{
				_geoHashValues = geoHashValues;
				_distances = distances;
				_distance = distance;
				_docBase = docBase;
				_lng = lng;
				_lat = lat;
				_distanceLookupCache = distanceLookupCache;
			}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[Lucene.Net] [jira] [Resolved] (LUCENENET-448) GeoHashFilteredDocIdSet does not work at all

Posted by "Digy (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENENET-448?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Digy resolved LUCENENET-448.
----------------------------

    Resolution: Fixed

Hi Jeff,
Your fix is for 2.9.4g branch and I committed it.
(Although I was hard to compare your code with the current code).
Thank you.
                
> GeoHashFilteredDocIdSet does not work at all
> --------------------------------------------
>
>                 Key: LUCENENET-448
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-448
>             Project: Lucene.Net
>          Issue Type: Bug
>          Components: Lucene.Net Contrib
>    Affects Versions: Lucene.Net 2.9.4g
>         Environment: Windows 7 x64
>            Reporter: Jeff Johnson
>              Labels: contrib, spatial
>             Fix For: Lucene.Net 2.9.4g
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The GeoHashFilteredDocIdSet is assuming the values are always in the cache which is wrong. A proposed fix for the method is listed here for GeoHashDistanceFilter.cs:
> public GeoHashFilteredDocIdSet(DocIdSet innerSet, string[] geoHashValues, Dictionary<string, double> distanceLookupCache, double lat, double lng, int docBase, double distance, Dictionary<int, double> distances) 
>                 : base(innerSet , (docid) => /* was: public override Match */
> 			{
> 				String geoHash = geoHashValues[docid];
> 				double[] coords = GeoHashUtils.Decode(geoHash);
> 				double x = coords[0];
> 				double y = coords[1];
> 				double cachedDistance;
>                 distanceLookupCache.TryGetValue(geoHash, out cachedDistance);
> 				double d;
> 				if (cachedDistance > 0)
> 				{
> 					d = cachedDistance;
> 				}
> 				else
> 				{
> 					d = DistanceUtils.GetInstance().GetDistanceMi(lat, lng, x, y);
> 					distanceLookupCache[geoHash] = d;
> 				}
> 				if (d < distance)
> 				{
> 					distances[docid + docBase] = d;
> 					return true;
> 				}
> 				
> 				return false;
> 			})
> 			{
> 				_geoHashValues = geoHashValues;
> 				_distances = distances;
> 				_distance = distance;
> 				_docBase = docBase;
> 				_lng = lng;
> 				_lat = lat;
> 				_distanceLookupCache = distanceLookupCache;
> 			}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[Lucene.Net] [jira] [Updated] (LUCENENET-448) GeoHashFilteredDocIdSet does not work at all

Posted by "Digy (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENENET-448?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Digy updated LUCENENET-448:
---------------------------

    Affects Version/s:     (was: Lucene.Net 2.9.4)
                       Lucene.Net 2.9.4g
        Fix Version/s:     (was: Lucene.Net 2.9.4)
                       Lucene.Net 2.9.4g
    
> GeoHashFilteredDocIdSet does not work at all
> --------------------------------------------
>
>                 Key: LUCENENET-448
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-448
>             Project: Lucene.Net
>          Issue Type: Bug
>          Components: Lucene.Net Contrib
>    Affects Versions: Lucene.Net 2.9.4g
>         Environment: Windows 7 x64
>            Reporter: Jeff Johnson
>              Labels: contrib, spatial
>             Fix For: Lucene.Net 2.9.4g
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The GeoHashFilteredDocIdSet is assuming the values are always in the cache which is wrong. A proposed fix for the method is listed here for GeoHashDistanceFilter.cs:
> public GeoHashFilteredDocIdSet(DocIdSet innerSet, string[] geoHashValues, Dictionary<string, double> distanceLookupCache, double lat, double lng, int docBase, double distance, Dictionary<int, double> distances) 
>                 : base(innerSet , (docid) => /* was: public override Match */
> 			{
> 				String geoHash = geoHashValues[docid];
> 				double[] coords = GeoHashUtils.Decode(geoHash);
> 				double x = coords[0];
> 				double y = coords[1];
> 				double cachedDistance;
>                 distanceLookupCache.TryGetValue(geoHash, out cachedDistance);
> 				double d;
> 				if (cachedDistance > 0)
> 				{
> 					d = cachedDistance;
> 				}
> 				else
> 				{
> 					d = DistanceUtils.GetInstance().GetDistanceMi(lat, lng, x, y);
> 					distanceLookupCache[geoHash] = d;
> 				}
> 				if (d < distance)
> 				{
> 					distances[docid + docBase] = d;
> 					return true;
> 				}
> 				
> 				return false;
> 			})
> 			{
> 				_geoHashValues = geoHashValues;
> 				_distances = distances;
> 				_distance = distance;
> 				_docBase = docBase;
> 				_lng = lng;
> 				_lat = lat;
> 				_distanceLookupCache = distanceLookupCache;
> 			}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[Lucene.Net] [jira] [Commented] (LUCENENET-448) GeoHashFilteredDocIdSet does not work at all

Posted by "Jeff Johnson (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENENET-448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13145968#comment-13145968 ] 

Jeff Johnson commented on LUCENENET-448:
----------------------------------------

Sorry it looks like my code got a little garbled, the stray }) near the bottom seems fishy :)

Thanks for adding it though, does it compile OK?
                
> GeoHashFilteredDocIdSet does not work at all
> --------------------------------------------
>
>                 Key: LUCENENET-448
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-448
>             Project: Lucene.Net
>          Issue Type: Bug
>          Components: Lucene.Net Contrib
>    Affects Versions: Lucene.Net 2.9.4g
>         Environment: Windows 7 x64
>            Reporter: Jeff Johnson
>              Labels: contrib, spatial
>             Fix For: Lucene.Net 2.9.4g
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The GeoHashFilteredDocIdSet is assuming the values are always in the cache which is wrong. A proposed fix for the method is listed here for GeoHashDistanceFilter.cs:
> public GeoHashFilteredDocIdSet(DocIdSet innerSet, string[] geoHashValues, Dictionary<string, double> distanceLookupCache, double lat, double lng, int docBase, double distance, Dictionary<int, double> distances) 
>                 : base(innerSet , (docid) => /* was: public override Match */
> 			{
> 				String geoHash = geoHashValues[docid];
> 				double[] coords = GeoHashUtils.Decode(geoHash);
> 				double x = coords[0];
> 				double y = coords[1];
> 				double cachedDistance;
>                 distanceLookupCache.TryGetValue(geoHash, out cachedDistance);
> 				double d;
> 				if (cachedDistance > 0)
> 				{
> 					d = cachedDistance;
> 				}
> 				else
> 				{
> 					d = DistanceUtils.GetInstance().GetDistanceMi(lat, lng, x, y);
> 					distanceLookupCache[geoHash] = d;
> 				}
> 				if (d < distance)
> 				{
> 					distances[docid + docBase] = d;
> 					return true;
> 				}
> 				
> 				return false;
> 			})
> 			{
> 				_geoHashValues = geoHashValues;
> 				_distances = distances;
> 				_distance = distance;
> 				_docBase = docBase;
> 				_lng = lng;
> 				_lat = lat;
> 				_distanceLookupCache = distanceLookupCache;
> 			}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira