Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Scala namespace from legacy to opensearch #21

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Additionally one can define an alias to save some chars:
and use `$ESSTORAGE` for storage definition.

### Reading
To read data from ES, use `EsStorage` and specify the query through the `LOAD` function:
To read data from ES, use `OpenSearchStorage` and specify the query through the `LOAD` function:
```SQL
A = LOAD 'radio/artists' USING org.opensearch.pig.hadoop.EsStorage('es.query=?q=me*');
DUMP A;
Expand Down Expand Up @@ -265,19 +265,19 @@ df.saveToEs("spark/people")

### Java

In a Java environment, use the `org.elasticsearch.spark.rdd.java.api` package, in particular the `JavaEsSpark` class.
In a Java environment, use the `org.elasticsearch.spark.rdd.java.api` package, in particular the `JavaOpenSearchSpark` class.

### Reading
To read data from ES, create a dedicated `RDD` and specify the query as an argument.

```java
import org.apache.spark.api.java.JavaSparkContext;
import org.elasticsearch.spark.rdd.api.java.JavaEsSpark;
import org.elasticsearch.spark.rdd.api.java.JavaOpenSearchSpark;

SparkConf conf = ...
JavaSparkContext jsc = new JavaSparkContext(conf);

JavaPairRDD<String, Map<String, Object>> esRDD = JavaEsSpark.esRDD(jsc, "radio/artists");
JavaPairRDD<String, Map<String, Object>> esRDD = JavaOpenSearchSpark.esRDD(jsc, "radio/artists");
```

#### Spark SQL
Expand All @@ -290,9 +290,9 @@ DataFrame playlist = df.filter(df.col("category").equalTo("pikes").and(df.col("y

### Writing

Use `JavaEsSpark` to index any `RDD` to Elasticsearch:
Use `JavaOpenSearchSpark` to index any `RDD` to Elasticsearch:
```java
import org.elasticsearch.spark.rdd.api.java.JavaEsSpark;
import org.elasticsearch.spark.rdd.api.java.JavaOpenSearchSpark;

SparkConf conf = ...
JavaSparkContext jsc = new JavaSparkContext(conf);
Expand Down Expand Up @@ -322,7 +322,7 @@ To read data from ES, use `EsSpout`:
import org.opensearch.storm.OpenSearchSpout;

TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("es-spout", new EsSpout("storm/docs", "?q=me*"), 5);
builder.setSpout("opensearch-spout", new OpenSearchSpout("storm/docs", "?q=me*"), 5);
builder.setBolt("bolt", new PrinterBolt()).shuffleGrouping("es-spout");
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apply plugin: 'opensearch.hadoop.build.root'
defaultTasks 'build'

allprojects {
group = "org.elasticsearch"
group = "org.opensearch"
tasks.withType(AbstractCopyTask) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ apply plugin: 'groovy'

String minimumGradleVersion = file('src/main/resources/minimumGradleVersion').text.trim()
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build es-hadoop")
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build opensearch-hadoop")
}

if (JavaVersion.current() < JavaVersion.VERSION_11) {
throw new GradleException('At least Java 11 is required to use elasticsearch gradle tools')
throw new GradleException('At least Java 11 is required to use opensearch gradle tools')
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ class BuildPlugin implements Plugin<Project> {

/**
* Applies a closure to all dependencies in a configuration (currently or in the future) that disables the
* resolution of transitive dependencies except for projects in the group <code>org.elasticsearch</code>.
* resolution of transitive dependencies except for projects in the group <code>org.opensearch</code>.
* @param configuration to disable transitive dependencies on
*/
static void disableTransitiveDependencies(Project project, Configuration configuration) {
configuration.dependencies.all { Dependency dep ->
if (dep instanceof ModuleDependency && !(dep instanceof ProjectDependency) && dep.group.startsWith('org.elasticsearch') == false) {
if (dep instanceof ModuleDependency && !(dep instanceof ProjectDependency) && dep.group.startsWith('org.opensearch') == false) {
dep.transitive = false

// also create a configuration just for this dependency version, so that later
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class AntFixture extends AntTask implements Fixture {
throw toThrow
}

/** Adds a task to kill an elasticsearch node with the given pidfile */
/** Adds a task to kill an opensearch node with the given pidfile */
private TaskProvider<AntFixtureStop> createStopTask() {
final AntFixture fixture = this
TaskProvider<AntFixtureStop> stop = project.tasks.register("${name}#stop", AntFixtureStop)
Expand Down
6 changes: 3 additions & 3 deletions dist/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ configurations {
BuildPlugin.disableTransitiveDependencies(project, project.configurations.thirdPartyShaded)

def distProjects = [":opensearch-hadoop-mr", ":opensearch-hadoop-hive", ":opensearch-hadoop-pig",
":opensearch-spark-20", ":elasticsearch-storm"]
":opensearch-spark-20", ":opensearch-storm"]

distProjects.each { distProject ->
def configureDistDependency = { Dependency dependency ->
if (distProject == ":opensearch-spark-20") {
dependency.capabilities {
requireCapability("org.elasticsearch.spark.sql.variant:$sparkVariantIncluded:$project.version")
requireCapability("org.opensearch.spark.sql.variant:$sparkVariantIncluded:$project.version")
}
}
}
Expand Down Expand Up @@ -117,7 +117,7 @@ jar {
}

from(project.configurations.embedded.collect { it.isDirectory() ? it : zipTree(it)}) {
include "org/elasticsearch/**"
include "org/opensearch/**"
include "opensearch-hadoop-build.properties"
include "META-INF/services/*"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

import java.util.List;

import org.elasticsearch.hadoop.rest.RestUtils;
import org.elasticsearch.hadoop.util.TestUtils;
import org.opensearch.hadoop.rest.RestUtils;
import org.opensearch.hadoop.util.TestUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.elasticsearch.hadoop.util.TestUtils.docEndpoint;
import static org.elasticsearch.hadoop.util.TestUtils.resource;
import static org.opensearch.hadoop.util.TestUtils.docEndpoint;
import static org.opensearch.hadoop.util.TestUtils.resource;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

package org.opensearch.hadoop.integration.hive;

import org.elasticsearch.hadoop.HdpBootstrap;
import org.elasticsearch.hadoop.QueryTestParams;
import org.opensearch.hadoop.HdpBootstrap;
import org.opensearch.hadoop.QueryTestParams;
import org.opensearch.hadoop.cfg.ConfigurationOptions;
import org.elasticsearch.hadoop.OpenSearchAssume;
import org.elasticsearch.hadoop.rest.RestUtils;
import org.opensearch.hadoop.OpenSearchAssume;
import org.opensearch.hadoop.rest.RestUtils;
import org.opensearch.hadoop.util.OpenSearchMajorVersion;
import org.elasticsearch.hadoop.util.TestUtils;
import org.opensearch.hadoop.util.TestUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
Expand All @@ -41,7 +41,7 @@
import java.util.Collection;
import java.util.List;

import static org.elasticsearch.hadoop.util.TestUtils.resource;
import static org.opensearch.hadoop.util.TestUtils.resource;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import java.util.List;

import org.opensearch.hadoop.cfg.ConfigurationOptions;
import org.elasticsearch.hadoop.OpenSearchAssume;
import org.elasticsearch.hadoop.rest.RestUtils;
import org.opensearch.hadoop.OpenSearchAssume;
import org.opensearch.hadoop.rest.RestUtils;
import org.opensearch.hadoop.util.OpenSearchMajorVersion;
import org.opensearch.hadoop.util.StringUtils;
import org.elasticsearch.hadoop.util.TestUtils;
import org.opensearch.hadoop.util.TestUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.FixMethodOrder;
Expand All @@ -37,7 +37,7 @@

import static org.opensearch.hadoop.integration.hive.HiveSuite.isLocal;
import static org.opensearch.hadoop.integration.hive.HiveSuite.server;
import static org.elasticsearch.hadoop.util.TestUtils.resource;
import static org.opensearch.hadoop.util.TestUtils.resource;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class AbstractHiveSaveJsonTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
package org.opensearch.hadoop.integration.hive;

import org.opensearch.hadoop.cfg.ConfigurationOptions;
import org.elasticsearch.hadoop.OpenSearchAssume;
import org.elasticsearch.hadoop.rest.RestUtils;
import org.opensearch.hadoop.OpenSearchAssume;
import org.opensearch.hadoop.rest.RestUtils;
import org.opensearch.hadoop.util.OpenSearchMajorVersion;
import org.elasticsearch.hadoop.util.TestUtils;
import org.opensearch.hadoop.util.TestUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.FixMethodOrder;
Expand All @@ -33,8 +33,8 @@
import java.sql.SQLException;

import static org.opensearch.hadoop.util.OpenSearchMajorVersion.V_5_X;
import static org.elasticsearch.hadoop.util.TestUtils.docEndpoint;
import static org.elasticsearch.hadoop.util.TestUtils.resource;
import static org.opensearch.hadoop.util.TestUtils.docEndpoint;
import static org.opensearch.hadoop.util.TestUtils.resource;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
import java.util.Collection;
import java.util.List;

import org.elasticsearch.hadoop.HdpBootstrap;
import org.elasticsearch.hadoop.QueryTestParams;
import org.opensearch.hadoop.HdpBootstrap;
import org.opensearch.hadoop.QueryTestParams;
import org.opensearch.hadoop.cfg.ConfigurationOptions;
import org.elasticsearch.hadoop.OpenSearchAssume;
import org.elasticsearch.hadoop.rest.RestUtils;
import org.opensearch.hadoop.OpenSearchAssume;
import org.opensearch.hadoop.rest.RestUtils;
import org.opensearch.hadoop.util.OpenSearchMajorVersion;
import org.opensearch.hadoop.util.StringUtils;
import org.elasticsearch.hadoop.util.TestUtils;
import org.opensearch.hadoop.util.TestUtils;
import org.junit.After;
import org.junit.Assert;
import org.junit.Assume;
Expand All @@ -42,7 +42,7 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import static org.elasticsearch.hadoop.util.TestUtils.resource;
import static org.opensearch.hadoop.util.TestUtils.resource;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
import java.util.Date;
import java.util.List;

import org.elasticsearch.hadoop.HdpBootstrap;
import org.elasticsearch.hadoop.QueryTestParams;
import org.opensearch.hadoop.HdpBootstrap;
import org.opensearch.hadoop.QueryTestParams;
import org.opensearch.hadoop.cfg.ConfigurationOptions;
import org.elasticsearch.hadoop.OpenSearchAssume;
import org.elasticsearch.hadoop.rest.RestUtils;
import org.opensearch.hadoop.OpenSearchAssume;
import org.opensearch.hadoop.rest.RestUtils;
import org.opensearch.hadoop.util.OpenSearchMajorVersion;
import org.elasticsearch.hadoop.util.TestUtils;
import org.opensearch.hadoop.util.TestUtils;
import org.junit.After;
import org.junit.Assert;
import org.junit.Assume;
Expand All @@ -45,7 +45,7 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import static org.elasticsearch.hadoop.util.TestUtils.resource;
import static org.opensearch.hadoop.util.TestUtils.resource;
import static org.junit.Assert.*;

import static org.opensearch.hadoop.integration.hive.HiveSuite.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
import org.apache.hive.service.cli.RowSet;
import org.apache.hive.service.cli.SessionHandle;
import org.apache.hive.service.server.HiveServer2;
import org.elasticsearch.hadoop.HdpBootstrap;
import org.elasticsearch.hadoop.fs.NTFSLocalFileSystem;
import org.opensearch.hadoop.HdpBootstrap;
import org.opensearch.hadoop.fs.NTFSLocalFileSystem;
import org.opensearch.hadoop.util.Assert;
import org.opensearch.hadoop.util.ReflectionUtils;
import org.opensearch.hadoop.util.StringUtils;
import org.elasticsearch.hadoop.util.TestUtils;
import org.opensearch.hadoop.util.TestUtils;

import static org.junit.Assert.fail;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.filecache.DistributedCache;
import org.apache.hadoop.fs.Path;
import org.elasticsearch.hadoop.fs.HdfsUtils;
import org.elasticsearch.hadoop.HdpBootstrap;
import org.elasticsearch.hadoop.fixtures.LocalEs;
import org.elasticsearch.hadoop.Provisioner;
import org.opensearch.hadoop.fs.HdfsUtils;
import org.opensearch.hadoop.HdpBootstrap;
import org.opensearch.hadoop.fixtures.LocalEs;
import org.opensearch.hadoop.Provisioner;
import org.opensearch.hadoop.util.StringUtils;
import org.junit.BeforeClass;
import org.junit.ClassRule;
Expand Down Expand Up @@ -138,7 +138,7 @@ public static void setup() throws Exception {


public static String tableProps(String resource, String query, String... params) {
StringBuilder sb = new StringBuilder("STORED BY 'org.opensearch.hive.hadoop.EsStorageHandler' ");
StringBuilder sb = new StringBuilder("STORED BY 'org.opensearch.hive.hadoop.OpenSearchStorageHandler' ");

sb.append("TBLPROPERTIES('es.resource'='" + resource + "'");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.opensearch.hadoop.rest.InitializationUtils;
import org.opensearch.hadoop.serialization.bulk.BulkCommand;
import org.opensearch.hadoop.serialization.bulk.BulkCommands;
import org.elasticsearch.hadoop.util.*;
import org.opensearch.hadoop.util.*;
import org.opensearch.hadoop.util.Assert;
import org.opensearch.hadoop.util.BytesArray;
import org.opensearch.hadoop.util.ClusterInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@
import static org.opensearch.hadoop.hive.HiveConstants.TABLE_LOCATION;

/**
* Hive storage for writing data into an ElasticSearch index.
* Hive storage for writing data into an OpenSearch index.
*
* The ElasticSearch host/port can be specified through Hadoop properties (see package description)
* or passed to {@link EsStorageHandler} through Hive <tt>TBLPROPERTIES</tt>
* The OpenSearch host/port can be specified through Hadoop properties (see package description)
* or passed to {@link OpenSearchStorageHandler} through Hive <tt>TBLPROPERTIES</tt>
*/
@SuppressWarnings({ "deprecation", "rawtypes" })
public class EsStorageHandler extends DefaultStorageHandler {
public class OpenSearchStorageHandler extends DefaultStorageHandler {

private static Log log = LogFactory.getLog(EsStorageHandler.class);
private static Log log = LogFactory.getLog(OpenSearchStorageHandler.class);

@Override
public Class<? extends InputFormat> getInputFormatClass() {
Expand Down Expand Up @@ -100,7 +100,7 @@ public void configureOutputJobProperties(TableDesc tableDesc, Map<String, String
}

private void setUserProviderIfNotSet(Map<String, String> jobProperties) {
String key = ConfigurationOptions.ES_SECURITY_USER_PROVIDER_CLASS;
String key = ConfigurationOptions.OPENSEARCH_SECURITY_USER_PROVIDER_CLASS;
if (!jobProperties.containsKey(key)) {
jobProperties.put(key, HadoopUserProvider.class.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@

import org.apache.hadoop.io.Text;
import org.codehaus.jackson.map.ObjectMapper;
import org.opensearch.hadoop.hive.HiveValueReader;
import org.opensearch.hadoop.serialization.ScrollReader;
import org.opensearch.hadoop.serialization.ScrollReaderConfigBuilder;
import org.opensearch.hadoop.serialization.dto.mapping.FieldParser;
import org.opensearch.hadoop.serialization.dto.mapping.Mapping;
import org.elasticsearch.hadoop.util.TestSettings;
import org.opensearch.hadoop.util.TestSettings;
import org.junit.Test;

import static org.hamcrest.Matchers.containsString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.opensearch.hadoop.serialization.HiveTypeToJsonTest.MyHiveType;
import org.opensearch.hadoop.serialization.field.ConstantFieldExtractor;
import org.opensearch.hadoop.serialization.field.FieldExtractor;
import org.elasticsearch.hadoop.util.TestSettings;
import org.opensearch.hadoop.util.TestSettings;
import org.junit.Test;

import static org.junit.Assert.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import org.opensearch.hadoop.hive.HiveValueWriter;
import org.opensearch.hadoop.serialization.builder.ContentBuilder;
import org.opensearch.hadoop.util.FastByteArrayOutputStream;
import org.elasticsearch.hadoop.util.TestSettings;
import org.opensearch.hadoop.util.TestSettings;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.opensearch.hadoop;

import org.elasticsearch.hadoop.HdpBootstrap;
import org.elasticsearch.hadoop.Provisioner;
import org.junit.Test;

public class ProvisionerTest {
Expand Down