V - The same type than the RDD the SparkRecordInfoProvider is implemented for.
public interface SparkRecordInfoProvider<V>
extends java.io.Serializable
Defines a component used to extract spatial information from RDD's records independently of the data format.
The objective of a SparkRecordInfoProvider implementation is to get the spatial information and any other required data from an input value and, set the extracted data to a given SparkRecordInfo instance which is passed as an output parameter.
A record info provider is always expected to extract at least the spatial information from input values in order to perform spatial operations on RDDs. If a record does not contain spatial information it will not be considered in a spatial filter or operation. Additional record info fields are only required when it is desired to work with an RDD of type SparkRecordInfo. See SparkRecordInfo.addField(String, Object) and SparkRecordInfo.getField(String).
The following example shows how to implement a SparkRecordInfoProvider to get spatial information from an RDD which records are in CSV format:
 
 public class CSVRecordInfoProvider implements SparkRecordInfoProvider<String>{
        private int srid = 8307;
        public boolean getRecordInfo(String value, SparkRecordInfo recordInfo) {
                try {
                        String[] tokens = value.split(",");
                        //expected records have the format: id,name,last_name,x,y where x and y are optional 
                        if (tokens.length == 5) {
                                recordInfo.setGeometry(JGeometry.createPoint(tokens[3], tokens[4], 2, srid));
                        }
                } catch (Exception ex) {
                        //return false when there is an error extracting data from the input value
                        return false;
                }
                return true;
        }
        public void setSrid(int srid) {
                this.srid = srid;
        }
        public int getSrid() {
                return srid;
        }
        }
 
 
| Modifier and Type | Method and Description | 
|---|---|
boolean | 
getRecordInfo(V value, SparkRecordInfo recordInfo)
Extracts spatial and other required data from the value input parameter and sets the extracted data to the recordInfo output parameter 
 | 
int | 
getSrid()
Gets the SRID of the geometries returned by getRecordInfo 
 | 
void | 
setSrid(int srid)
Sets the SRID of the geometries returned by getRecordInfo 
 | 
boolean getRecordInfo(V value, SparkRecordInfo recordInfo)
value - a record from an RDDrecordInfo - a SparkRecordInfo instance to be filled with data from valueint getSrid()
void setSrid(int srid)
srid -Copyright © 2016 Oracle and/or its affiliates. All Rights Reserved.