Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Let's take a look at each option.

Using the GUI to get values from the

...

registry

BAM provides a simple GUI for you to configure Hive scripts to get values from the Registry at runtime using placeholder keys with particular registry/repository prefixes. Only text/plain media type supports parameterization.

...

You can use : ${local:/repository/credential/password} value in that format for the password resource in the Hive script.

Extending a Java

...

class and implementing its getter and setter methods

Using the GUI as described above has some limitations since it only allows you to get values from the Registry at runtime. There can be instances where you have to dynamically get and set variable values that might not necessarily be stored in the Registry. For example, sometimes you have to perform a logical operation on data, store the result in a temporary variable and use that variable value in yet another operation. In such cases, you can write your own Java class by extending the AbstractHiveAnalyzer class and implementing its getter and setter methods.

The AbstractHiveAnalyzer class is shown below.

Infocode
iconlanguagefalsejava
public abstract class AbstractHiveAnalyzer {
    public abstract void execute();
    public void setProperty(String key, String value) {
        HiveContext.getCurrentContext().setProperty(key, value);
    }
    public String getProperty(String key) {
        return HiveContext.getCurrentContext().getProperty(key);
    }
    public void removeProperty(String key, String value) {
        HiveContext.getCurrentContext().setProperty(key, null);
    }
}

You can use inherited property-methods to set parameters to the Hive configuration used during a particular Hive script execution. For example, if you set a property named lastRunTime using the setProperty method, the property will be available in subsequent Hive queries with notation {hiveconf:lasRunTime}. You can dynamically populate this lastRunTime property in each run of the script, by looking up values from the registry, databases etc. This is useful in maintaining state between two executions of a Hive script and using them subsequently.

...

Also,  add the following code segment under maven dependencies.

Infocode
iconlanguagefalsehtml/xml
<dependency>
   

    <groupId>org.wso2.carbon</groupId>
   

    <artifactId>org.wso2.carbon.analytics.hive</artifactId>
    

     <version>4.1.2</version>

</dependency>