VenuReddy2103 commented on a change in pull request #3436: [CARBONDATA-3548]Geospatial Support: Modified to create and load the table with a nonschema dimension sort column. And added InPolygon UDF
URL: https://github.com/apache/carbondata/pull/3436#discussion_r349588241 ########## File path: integration/spark2/src/main/scala/org/apache/carbondata/geo/GeoUtils.scala ########## @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.carbondata.geo + +import java.io.{ByteArrayInputStream, ObjectInputStream} +import java.util.Base64 + +import scala.collection.mutable + +import org.apache.spark.sql.util.CarbonException + +import org.apache.carbondata.core.constants.CarbonCommonConstants +import org.apache.carbondata.core.util.CustomIndex + +object GeoUtils { + def getGeoHashHandler(tableProperties: mutable.Map[String, String]) + : (String, CustomIndex[_, _, _]) = { + val indexProperty = tableProperties.get(CarbonCommonConstants.INDEX_HANDLER) + if (indexProperty.isEmpty || indexProperty.get.trim.isEmpty) { + CarbonException.analysisException( + s"Table do not have ${CarbonCommonConstants.INDEX_HANDLER} property " + + s"with ${CarbonCommonConstants.GEOHASH} type handler") + } + val handler = indexProperty.get.split(",").map(_.trim).filter(handler => + CarbonCommonConstants.GEOHASH.equalsIgnoreCase( + tableProperties.getOrElse(s"${CarbonCommonConstants.INDEX_HANDLER}.$handler.type", ""))) + .map(handler => (handler, + tableProperties.get(s"${CarbonCommonConstants.INDEX_HANDLER}.$handler.instance"))) + if (handler.isEmpty || handler.length != 1 || handler(0)._1.isEmpty + || handler(0)._2.isEmpty) { + CarbonException.analysisException( + s"Table do not have ${CarbonCommonConstants.INDEX_HANDLER} property " + + s"with ${CarbonCommonConstants.GEOHASH} type handler") + } + val bis = new ByteArrayInputStream(Base64.getDecoder().decode(handler(0)._2.get)) Review comment: `ByteArrayOutputStream` and `ByteArrayInputStream` closing has no effect according to Oracle java docs. Should we still do it ? Base code do not seem to consistent on this point. https://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayInputStream.html https://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] With regards, Apache Git Services |
Free forum by Nabble | Edit this page |