GithubHelp home page GithubHelp logo

Performance of Range Query about sedona HOT 4 CLOSED

apache avatar apache commented on August 20, 2024
Performance of Range Query

from sedona.

Comments (4)

jiayuasu avatar jiayuasu commented on August 20, 2024

Hi @tiwanpunit ,

Thanks for asking this interesting question. In fact, we have done some research on this.

First, I am not sure whether you are using the proper format to do iterative range query. Here is the proper format to do iterative range query with cache. (The query envelope can be replaced by JTS Polygon)

    	PointRDD objectRDD = new PointRDD(sc, inputLocation, offset, splitter);
    	objectRDD.rawPointRDD.persist(StorageLevel.MEMORY_ONLY());
    	for(int i=0;i<loopTimes;i++)
    	{
    		long resultSize = RangeQuery.SpatialRangeQuery(objectRDD, queryEnvelope, 0).getRawRectangleRDD().count();
    		assert resultSize>-1;
    	}
PointRDD objectRDD = new PointRDD(sc, inputLocation, offset, splitter);
    	objectRDD.buildIndex("rtree");
    	for(int i=0;i<loopTimes;i++)
    	{
    		long resultSize = RangeQuery.SpatialRangeQueryUsingIndex(objectRDD, queryEnvelope, 0).getRawRectangleRDD().count();
    		assert resultSize>-1;
    	}

Second, I have tested GeoSpark range query with cache on super large data. The benefit of using spatial index in range query is not very obvious, it takes some additional time to build index in the first round execution.

Moreover, range query is actual "Map" operation. This is called Narrow Dependency in Spark and a bunch of same range queries can be pipelined together and executed without a stop. The pipeline execution is super fast and using index is just a little bit faster than it. You may not even notice it.

However, if your cluster computation power is quite limited, I think using index may still speed up your execution a lot.

Thanks,
Jia

from sedona.

tiwanpunit avatar tiwanpunit commented on August 20, 2024

Thank you for replying so fast.
So in my usecase "objectRDD" is the "point" and "queryEnvelope" is the "polygon" ? i.e. objectRDD contains the points that need's to be queried and queryEnvelope is the shape on which query is performed.
Did I understand your explanation correctly?

Also you have suggested to pass JTS Polygon in place of "queryEnvelope" but the method only accepts "Envelope" type of shape not Polygon.

from sedona.

jiayuasu avatar jiayuasu commented on August 20, 2024
  1. Yes. You understand me correctly.
  2. Yes. You are right. Thanks for reminding me. Currently, it only supports Envelope type as the query window. I can add the support of polygon type query window in the upcoming version. It is very easy.

For now, it seems the only way to perform a polygon window range query is to do a join query on PolygonRDD(only 1 polygon inside) and PointRDD.

from sedona.

jiayuasu avatar jiayuasu commented on August 20, 2024

Soloved in GeoSpark 0.4.0

from sedona.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.