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

Added nosql and dynamo plugins #429

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
<module>presto-testing-server-launcher</module>
<module>presto-plugin-toolkit</module>
<module>presto-resource-group-managers</module>
<module>presto-base-plugin-nosql</module>
<module>presto-dynamo</module>
</modules>

<dependencyManagement>
Expand Down
122 changes: 122 additions & 0 deletions presto-base-plugin-nosql/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>presto-root</artifactId>
<groupId>com.facebook.presto</groupId>
<version>0.156</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>presto-base-plugin</artifactId>
<description>Presto - Base plugin</description>

<properties>
<air.check.skip-extended>true</air.check.skip-extended>
<air.check.skip-license>true</air.check.skip-license>

<air.check.fail-checkstyle>false</air.check.fail-checkstyle>
<air.check.skip-checkstyle>true</air.check.skip-checkstyle>
</properties>

<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>bootstrap</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>log</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>configuration</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>

<!-- Presto SPI -->
<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-spi</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>slice</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.weakref</groupId>
<artifactId>jmxutils</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>

<!-- for testing -->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary comment.

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-main</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>testing</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.facebook.presto.baseplugin;

import com.facebook.presto.spi.ColumnHandle;
import com.facebook.presto.spi.ColumnMetadata;
import com.facebook.presto.spi.type.Type;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.util.Objects;

import static com.google.common.base.MoreObjects.toStringHelper;
import static java.util.Objects.requireNonNull;

/**
* Created by amehta on 6/13/16.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove that.

*/
public class BaseColumnHandle implements ColumnHandle {
private final String columnName;
private final Type columnType;
private final int ordinalPosition;

@JsonCreator
public BaseColumnHandle(
@JsonProperty("columnName") String columnName,
@JsonProperty("columnType") Type columnType,
@JsonProperty("ordinalPosition") int ordinalPosition)
{
this.columnName = requireNonNull(columnName, "columnName is null");
this.columnType = requireNonNull(columnType, "columnType is null");
this.ordinalPosition = ordinalPosition;
}

@JsonProperty
public String getColumnName()
{
return columnName;
}

@JsonProperty
public Type getColumnType()
{
return columnType;
}

@JsonProperty
public int getOrdinalPosition()
{
return ordinalPosition;
}

public ColumnMetadata toColumnMetadata()
{
return new ColumnMetadata(columnName, columnType);
}

@Override
public boolean equals(Object o)
{
if(o == this){
return true;
}
if(o instanceof BaseColumnHandle){
BaseColumnHandle baseColumnHandle = (BaseColumnHandle) o;
return new EqualsBuilder()
.append(columnName, baseColumnHandle.columnName)
.append(columnType, baseColumnHandle.columnType)
.append(ordinalPosition, baseColumnHandle.ordinalPosition)
.isEquals();
}
return false;
}

@Override
public int hashCode()
{
return new HashCodeBuilder()
.append(columnName)
.append(columnType)
.append(ordinalPosition)
.toHashCode();
}

@Override
public String toString()
{
return toStringHelper(this)
.add("columnName", columnName)
.add("columnType", columnType)
.add("ordinalPosition", ordinalPosition)
.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.facebook.presto.baseplugin;

import com.facebook.presto.spi.ConnectorSession;
import io.airlift.configuration.Config;
import io.airlift.configuration.ConfigDescription;

import java.util.Optional;
import java.util.Properties;

/**
* Created by amehta on 6/13/16.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

*/
public abstract class BaseConfig {
private final Properties properties;

public BaseConfig(){
this.properties = new Properties();

setProperty("basePlugin.cacheEnabled", false);
setProperty("basePlugin.metastoreJdbcUrl", "jdbc:h2:~/h2/presto");
setProperty("basePlugin.metastoreUsername", "sa");
setProperty("basePlugin.metastorePassword", "sa");
setProperty("basePlugin.defaultSchemaName", "default_schema");
}

protected void setProperty(String propertyName, Object value){
this.properties.setProperty(propertyName, value.toString());
}

protected <T> T getProperty(String propertyName, Class<T> clazz, Optional<ConnectorSession> session){
//return session.isPresent() ? BaseUtils.getPropertyFromSessionConfig(propertyName, clazz, session.get(), this) : BaseUtils.getPropertyFromMap(propertyName, clazz, properties);
return BaseUtils.getPropertyFromMap(propertyName, clazz, properties);
}

@Config("basePlugin.cacheEnabled")
@ConfigDescription("Whether the cache is enabled for this plugin")
public void setCacheEnabled(Boolean cacheEnabled){
setProperty("basePlugin.cacheEnabled", cacheEnabled);
}

public Boolean getCacheEnabled(Optional<ConnectorSession> session){
return getProperty("basePlugin.cacheEnabled", Boolean.class, session);
}

public Boolean getCacheEnabled(){
return getCacheEnabled(Optional.empty());
}

@Config("basePlugin.metastoreJdbcUrl")
@ConfigDescription("the location of the metadata store")
public void setMetastoreJdbcUrl(String metastoreJdbcUrl){
setProperty("basePlugin.metastoreJdbcUrl", metastoreJdbcUrl);
}

public String getMetastoreJdbcUrl(Optional<ConnectorSession> session){
return getProperty("basePlugin.metastoreJdbcUrl", String.class, session);
}

public String getMetastoreJdbcUrl(){
return getMetastoreJdbcUrl(Optional.empty());
}

@Config("basePlugin.metastoreUsername")
@ConfigDescription("the username for connecting to the metadata store")
public void setMetastoreUsername(String metastoreUsername){
setProperty("basePlugin.metastoreUsername", metastoreUsername);
}

public String getMetastoreUsername(Optional<ConnectorSession> session){
return getProperty("basePlugin.metastoreUsername", String.class, session);
}

public String getMetastoreUsername(){
return getMetastoreUsername(Optional.empty());
}

@Config("basePlugin.metastorePassword")
@ConfigDescription("the password for connecting to the metadata store")
public void setMetastorePassword(String metastorePassword){
setProperty("basePlugin.metastorePassword", metastorePassword);
}

public String getMetastorePassword(Optional<ConnectorSession> session){
return getProperty("basePlugin.metastorePassword", String.class, session);
}

public String getMetastorePassword(){
return getMetastorePassword(Optional.empty());
}

@Config("basePlugin.defaultSchemaName")
@ConfigDescription("the name of the default schema for datasources that don't have schemas")
public void setDefaultSchemaName(String defaultSchemaName){
setProperty("basePlugin.defaultSchemaName", defaultSchemaName);
}

public String getDefaultSchemaName(Optional<ConnectorSession> session){
return getProperty("basePlugin.defaultSchemaName", String.class, session);
}

public String getDefaultSchemaName(){
return getDefaultSchemaName(Optional.empty());
}
}
Loading