Create a spatial index using the Spark API
post
/spatialviewer/api/v1/spark/createIndex
The index metadata directory is the directory spark_index_metadata contained in the SpatialViewer local working directory (see SpatialViewer configuration).
Request
Supported Media Types
- application/json
Query Parameters
-
asynchronous: boolean
if true the index is created asynchronously.Default Value:
false
Index details
Root Schema : SparkIndexInfo
Type:
Show Source
object
-
dataPath(optional):
string
Path of the file or files to index in HDFS.Example:
/user/oracle/spatialviewer/tweetsJune.json
-
dbConnURL(optional):
string
Database URL. Specify this property if useDBDataSource is true.Example:
jdbc:oracle:thin:@myhost:1521:orcl
-
dbPwd(optional):
string
Database password. Specify this property if useDBDataSource is true.Example:
tiger
-
dbUsr(optional):
string
Database user name. Specify this property if useDBDataSource is true.Example:
scott
-
indexName(optional):
string
The index name.Example:
TweetsJune
-
indexPath(optional):
string
New index path. This is the job output path.Example:
/user/oracle/spatialviewer/TweetsJune
-
inputFormatClass(optional):
string
The input format class. Optional. If the input format class is not specified then the SparkContext's textFile is used.Example:
oracle.spatial.hadoop.vector.geojson.mapred.GeoJsonInputFormat
-
jarWithNeededClasses(optional):
string
jar name with the user-defined classes like custom RecordInfoProvider or InputFormat. If the InputFormat class or the RecordInfoProvider class is not in the API, or in the hadoop API classes, then a jar with the user-defined classes must be provided. To be able to use this jar the user must add it in the /opt/oracle/oracle-spatial-graph/spatial/web-server/spatialviewer/WEB-INF/lib directory and restart the server. Optional property.Example:
myjar.jar
-
keyClass(optional):
string
Class of the input format keys. This property is required if an input format is defined.Example:
org.apache.hadoop.io.LongWritable
-
recordInfoProviderClass(optional):
string
The class that provides the spatial information.Example:
oracle.spatial.spark.vector.recordinfoprovider.GeoJsonRecordInfoProvider
-
sqlQuery(optional):
string
SQL query or table name (to query the whole table). Specify this property if useDBDataSource is true.Example:
select * from POI_RESTAURANT where POI_POSTCODE=94133 and POI_STREET_NAME='COLUMBUS AVE'
-
srid(optional):
integer(int32)
SRID of the geometries to be indexed.Example:
8307
-
tolerance(optional):
number(double)
Double value that represents the tolerance used when performing spatial operations.Example:
0.05
-
useDBDataSource(optional):
boolean
true if Oracle Database data are used as the data source, false otherwise. False by default. If true then the properties dataPath, inputFormatClass, keyClass, valueClass and recordInfoProviderClass are ignored.Example:
false
-
valueClass(optional):
string
Class of the input format values. This property is required if an input format is defined.Example:
org.apache.hadoop.io.Text
Response
Supported Media Types
- application/json
201 Response
successful index creation
Root Schema : CreateSparkIndexJobResponse
Type:
Show Source
object
-
o:successCode(optional):
string
The success code.Example:
SV-05006
-
response(optional):
string
The response contains the location of the new created index.Example:
hdfs://<namenode>:8020/user/oracle/spatialviewer/TweetsJune
-
status(optional):
string
success or errorExample:
success
-
title(optional):
string
Service title.Example:
Create Spark Index.
202 Response
accepted asynchronous index creation
Root Schema : AsyncCreateSparkIndexJobResponse
Type:
Show Source
object
-
o:successCode(optional):
string
The success code.Example:
SV-05006
-
response(optional):
string
The response contains the location of the resource manager web application URL to track the job (see in the configuration the Hadoop parameter yarn.resourcemanager.webapp.address).Example:
http://resource.manager.webapp:8088
-
status(optional):
string
success or errorExample:
success
-
title(optional):
string
Service title.Example:
Create Spark Index.
Examples
The following example shows how to create a Spark index by submitting a POST request on the REST resource using cURL.
curl -v -X POST "http://localhost:8045/spatialviewer/api/v1/spark/createIndex" -H "accept: application/json" -H "content-type: application/json" -d "{ \"indexName\": \"TweetsJune\", \"dataPath\": \"/user/oracle/tweets.json\", \"indexPath\": \"/user/oracle/HOL/tweetsJune\", \"srid\": 8307, \"tolerance\": 0.05, \"inputFormatClass\": \"oracle.spatial.hadoop.vector.geojson.mapred.GeoJsonInputFormat\", \"recordInfoProviderClass\": \"oracle.spatial.spark.vector.recordinfoprovider.GeoJsonRecordInfoProvider\", \"keyClass\": \"org.apache.hadoop.io.LongWritable\", \"valueClass\": \"org.apache.hadoop.io.Text\"}"
Example of Response Header
The following shows an example of the response header.
HTTP/1.1 201 Created Date: Wed, 15 Nov 2017 17:50:38 GMT Location: hdfs://localhost:8020/user/oracle/tweetsJune Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, POST, DELETE, PUT Access-Control-Allow-Headers: Content-Type, Accept Transfer-Encoding: chunked Content-Type: application/json
Example of Response Body
The following example shows the contents of the response body in JSON format:
{"status" : "success", "title" : "Create Spark Index.", "o:successCode" : "SV-05006", "response" : "hdfs://localhost:8020/user/oracle/tweetsJune"}