[ 
https://issues.apache.org/jira/browse/DRILL-3914?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14960331#comment-14960331
 ] 

ASF GitHub Bot commented on DRILL-3914:
---------------------------------------

Github user k255 commented on a diff in the pull request:

    https://github.com/apache/drill/pull/191#discussion_r42217546
  
    --- Diff: 
contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsText.java 
---
    @@ -0,0 +1,58 @@
    +/**
    + * 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.drill.exec.expr.fn.impl.gis;
    +
    +import javax.inject.Inject;
    +
    +import org.apache.drill.exec.expr.DrillSimpleFunc;
    +import org.apache.drill.exec.expr.annotations.FunctionTemplate;
    +import org.apache.drill.exec.expr.annotations.Output;
    +import org.apache.drill.exec.expr.annotations.Param;
    +import org.apache.drill.exec.expr.holders.VarBinaryHolder;
    +import org.apache.drill.exec.expr.holders.VarCharHolder;
    +
    +import io.netty.buffer.DrillBuf;
    +
    +@FunctionTemplate(name = "st_astext", scope = 
FunctionTemplate.FunctionScope.SIMPLE,
    +  nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
    +public class STAsText implements DrillSimpleFunc {
    +  @Param
    +  VarBinaryHolder geom1Param;
    +
    +  @Output
    +  VarCharHolder out;
    +
    +  @Inject
    +  DrillBuf buffer;
    +
    +  public void setup() {
    +  }
    +
    +  public void eval() {
    +    com.esri.core.geometry.ogc.OGCGeometry geom1 = 
com.esri.core.geometry.ogc.OGCGeometry
    +        .fromBinary(geom1Param.buffer.nioBuffer(geom1Param.start, 
geom1Param.end));
    +
    +    String geomWKT = geom1.asText();
    +
    +    int outputSize = geomWKT.getBytes().length;
    +    out.buffer = buffer.reallocIfNeeded(outputSize);
    --- End diff --
    
    Thanks, this was helpful. You're right the next executions failed with 
"Tried to remove unmanaged buffer.". Now it's fixed. Is it also valid to use 
BufferManager.getManagedBuffer(size) somehow (maybe instead of injecting the 
DrillBuf)?


> Support geospatial queries
> --------------------------
>
>                 Key: DRILL-3914
>                 URL: https://issues.apache.org/jira/browse/DRILL-3914
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Client - JDBC, Functions - Drill
>            Reporter: Karol Potocki
>
> Implement spatial query functionality in Drill to provide location based 
> queries and filtering. It could be similar to PostGIS for Postgres and allow 
> queries like:
> select * from
>     (select columns[2] as location, columns[4] as lon, columns[3] as lat,
>         ST_DWithin(ST_Point(-121.895, 37.339), ST_Point(columns[4], 
> columns[3]), 0.1) as isWithin
>         from dfs.`default`.`/home/k255/drill/sample-data/CA-cities.csv`
>     )
>     where isWithin = true;
> Working proposal is available at http://github.com/k255 (see drill-gis and 
> drill fork).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to