You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Ilya Bystrov (JIRA)" <ji...@apache.org> on 2016/09/19 17:46:20 UTC

[jira] [Created] (HIVE-14787) Ability to access DistributedCache from UDFs via Java API

Ilya Bystrov created HIVE-14787:
-----------------------------------

             Summary: Ability to access DistributedCache from UDFs via Java API
                 Key: HIVE-14787
                 URL: https://issues.apache.org/jira/browse/HIVE-14787
             Project: Hive
          Issue Type: Bug
          Components: Query Processor
         Environment: 1.1.0+cdh5.7.1
            Reporter: Ilya Bystrov


I'm trying to create custom function

{{create function geoip as 'some.package.UDFGeoIp' using jar 'hdfs:///user/hive/ext/HiveGeoIP.jar', file 'hdfs:///user/hive/ext/GeoIP.dat';}}

According to https://issues.apache.org/jira/browse/HIVE-1016
I should be able to access file via {{new File("./GeoIP.dat");}} (in overridden method {{GenericUDF#evaluate(DeferredObject[] arguments)}})
But this doesn't work.

I use the following workaround, but it's ugly:
{code}
CodeSource codeSource = GenericUDFGeoIP.class.getProtectionDomain().getCodeSource();
File jarFile = new File(codeSource.getLocation().toURI().getPath());
String jarDir = jarFile.getParentFile().getPath();
File actualFile = new File(jarDir + "/GeoIP.dat");
{code}



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