getViewNames(String schema)
- {
- requireNonNull(schema, "schema is null");
- return metaManager.getViewNames(schema);
- }
-
- public AccumuloView getView(SchemaTableName viewName)
- {
- requireNonNull(viewName, "schema table name is null");
- return metaManager.getView(viewName);
- }
-
- /**
- * Fetches the TabletSplitMetadata for a query against an Accumulo table.
- *
- * Does a whole bunch of fun stuff! Splitting on row ID ranges, applying secondary indexes, column pruning,
- * all sorts of sweet optimizations. What you have here is an important method.
- *
- * @param session Current session
- * @param schema Schema name
- * @param table Table Name
- * @param rowIdDomain Domain for the row ID
- * @param constraints Column constraints for the query
- * @param serializer Instance of a row serializer
- * @return List of TabletSplitMetadata objects for Presto
- */
- public List getTabletSplits(
- ConnectorSession session,
- String schema,
- String table,
- Optional rowIdDomain,
- List constraints,
- AccumuloRowSerializer serializer)
- {
- try {
- String tableName = AccumuloTable.getFullTableName(schema, table);
- LOG.debug("Getting tablet splits for table %s", tableName);
-
- // Get the initial Range based on the row ID domain
- Collection rowIdRanges = getRangesFromDomain(rowIdDomain, serializer);
- List tabletSplits = new ArrayList<>();
-
- // Use the secondary index, if enabled
- if (AccumuloSessionProperties.isOptimizeIndexEnabled(session)) {
- // Get the scan authorizations to query the index
- Authorizations auths = getScanAuthorizations(session, schema, table);
-
- // Check the secondary index based on the column constraints
- // If this returns true, return the tablet splits to Presto
- if (indexLookup.applyIndex(schema, table, session, constraints, rowIdRanges, tabletSplits, serializer, auths)) {
- return tabletSplits;
- }
- }
-
- // If we can't (or shouldn't) use the secondary index, we will just use the Range from the row ID domain
-
- // Split the ranges on tablet boundaries, if enabled
- Collection splitRanges;
- if (AccumuloSessionProperties.isOptimizeSplitRangesEnabled(session)) {
- splitRanges = splitByTabletBoundaries(tableName, rowIdRanges);
- }
- else {
- // if not enabled, just use the same collection
- splitRanges = rowIdRanges;
- }
-
- // Create TabletSplitMetadata objects for each range
- boolean fetchTabletLocations = AccumuloSessionProperties.isOptimizeLocalityEnabled(session);
-
- LOG.debug("Fetching tablet locations: %s", fetchTabletLocations);
-
- for (Range range : splitRanges) {
- // If locality is enabled, then fetch tablet location
- if (fetchTabletLocations) {
- tabletSplits.add(new TabletSplitMetadata(getTabletLocation(tableName, range.getStartKey()), ImmutableList.of(range)));
- }
- else {
- // else, just use the default location
- tabletSplits.add(new TabletSplitMetadata(Optional.empty(), ImmutableList.of(range)));
- }
- }
-
- // Log some fun stuff and return the tablet splits
- LOG.debug("Number of splits for table %s is %d with %d ranges", tableName, tabletSplits.size(), splitRanges.size());
- return tabletSplits;
- }
- catch (Exception e) {
- throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to get splits from Accumulo", e);
- }
- }
-
- /**
- * Gets the scan authorizations to use for scanning tables.
- *
- * In order of priority: session username authorizations, then table property, then the default connector auths.
- *
- * @param session Current session
- * @param schema Schema name
- * @param table Table Name
- * @return Scan authorizations
- * @throws AccumuloException If a generic Accumulo error occurs
- * @throws AccumuloSecurityException If a security exception occurs
- */
- private Authorizations getScanAuthorizations(ConnectorSession session, String schema,
- String table)
- throws AccumuloException, AccumuloSecurityException
- {
- String sessionScanUser = AccumuloSessionProperties.getScanUsername(session);
- if (sessionScanUser != null) {
- Authorizations scanAuths = connector.securityOperations().getUserAuthorizations(sessionScanUser);
- LOG.debug("Using session scan auths for user %s: %s", sessionScanUser, scanAuths);
- return scanAuths;
- }
-
- AccumuloTable accumuloTable = this.getTable(new SchemaTableName(schema, table));
- if (accumuloTable == null) {
- throw new TableNotFoundException(new SchemaTableName(schema, table));
- }
-
- Optional strAuths = accumuloTable.getScanAuthorizations();
- if (strAuths.isPresent()) {
- Authorizations scanAuths = new Authorizations(Iterables.toArray(COMMA_SPLITTER.split(strAuths.get()), String.class));
- LOG.debug("scan_auths table property set, using: %s", scanAuths);
- return scanAuths;
- }
-
- LOG.debug("scan_auths table property not set, using connector auths: %s", this.auths);
- return this.auths;
- }
-
- private Collection splitByTabletBoundaries(String tableName, Collection ranges)
- throws org.apache.accumulo.core.client.TableNotFoundException, AccumuloException, AccumuloSecurityException
- {
- ImmutableSet.Builder rangeBuilder = ImmutableSet.builder();
- for (Range range : ranges) {
- // if start and end key are equivalent, no need to split the range
- if (range.getStartKey() != null && range.getEndKey() != null && range.getStartKey().equals(range.getEndKey())) {
- rangeBuilder.add(range);
- }
- else {
- // Call out to Accumulo to split the range on tablets
- rangeBuilder.addAll(connector.tableOperations().splitRangeByTablets(tableName, range, Integer.MAX_VALUE));
- }
- }
- return rangeBuilder.build();
- }
-
- /**
- * Gets the TabletServer hostname for where the given key is located in the given table
- *
- * @param table Fully-qualified table name
- * @param key Key to locate
- * @return The tablet location, or DUMMY_LOCATION if an error occurs
- */
- private Optional getTabletLocation(String table, Key key)
- {
- try {
- // Get the Accumulo table ID so we can scan some fun stuff
- String tableId = connector.tableOperations().tableIdMap().get(table);
-
- // Create our scanner against the metadata table, fetching 'loc' family
- Scanner scanner = connector.createScanner("accumulo.metadata", auths);
- scanner.fetchColumnFamily(new Text("loc"));
-
- // Set the scan range to just this table, from the table ID to the default tablet
- // row, which is the last listed tablet
- Key defaultTabletRow = new Key(tableId + '<');
- Key start = new Key(tableId);
- Key end = defaultTabletRow.followingKey(PartialKey.ROW);
- scanner.setRange(new Range(start, end));
-
- Optional location = Optional.empty();
- if (key == null) {
- // if the key is null, then it is -inf, so get first tablet location
- Iterator> iter = scanner.iterator();
- if (iter.hasNext()) {
- location = Optional.of(iter.next().getValue().toString());
- }
- }
- else {
- // Else, we will need to scan through the tablet location data and find the location
-
- // Create some text objects to do comparison for what we are looking for
- Text splitCompareKey = new Text();
- key.getRow(splitCompareKey);
- Text scannedCompareKey = new Text();
-
- // Scan the table!
- for (Entry entry : scanner) {
- // Get the bytes of the key
- byte[] keyBytes = entry.getKey().getRow().copyBytes();
-
- // If the last byte is <, then we have hit the default tablet, so use this location
- if (keyBytes[keyBytes.length - 1] == '<') {
- location = Optional.of(entry.getValue().toString());
- break;
- }
- else {
- // Chop off some magic nonsense
- scannedCompareKey.set(keyBytes, 3, keyBytes.length - 3);
-
- // Compare the keys, moving along the tablets until the location is found
- if (scannedCompareKey.getLength() > 0) {
- int compareTo = splitCompareKey.compareTo(scannedCompareKey);
- if (compareTo <= 0) {
- location = Optional.of(entry.getValue().toString());
- }
- else {
- // all future tablets will be greater than this key
- break;
- }
- }
- }
- }
- scanner.close();
- }
-
- // If we were unable to find the location for some reason, return the default tablet
- // location
- return location.isPresent() ? location : getDefaultTabletLocation(table);
- }
- catch (Exception e) {
- // Swallow this exception so the query does not fail due to being unable
- // to locate the tablet server for the provided Key.
- // This is purely an optimization, but we will want to log the error.
- LOG.error("Failed to get tablet location, returning dummy location", e);
- return Optional.empty();
- }
- }
-
- private Optional getDefaultTabletLocation(String fulltable)
- {
- try {
- String tableId = connector.tableOperations().tableIdMap().get(fulltable);
-
- // Create a scanner over the metadata table, fetching the 'loc' column of the default tablet row
- Scanner scan = connector.createScanner("accumulo.metadata", connector.securityOperations().getUserAuthorizations(username));
- scan.fetchColumnFamily(new Text("loc"));
- scan.setRange(new Range(tableId + '<'));
-
- // scan the entry
- Optional location = Optional.empty();
- for (Entry entry : scan) {
- if (location.isPresent()) {
- throw new PrestoException(FUNCTION_IMPLEMENTATION_ERROR, "Scan for default tablet returned more than one entry");
- }
-
- location = Optional.of(entry.getValue().toString());
- }
-
- scan.close();
- return location;
- }
- catch (Exception e) {
- // Swallow this exception so the query does not fail due to being unable to locate the tablet server for the default tablet.
- // This is purely an optimization, but we will want to log the error.
- LOG.error("Failed to get tablet location, returning dummy location", e);
- return Optional.empty();
- }
- }
-
- /**
- * Gets a collection of Accumulo Range objects from the given Presto domain.
- * This maps the column constraints of the given Domain to an Accumulo Range scan.
- *
- * @param domain Domain, can be null (returns (-inf, +inf) Range)
- * @param serializer Instance of an {@link AccumuloRowSerializer}
- * @return A collection of Accumulo Range objects
- * @throws TableNotFoundException If the Accumulo table is not found
- */
- public static Collection getRangesFromDomain(Optional domain, AccumuloRowSerializer serializer)
- throws TableNotFoundException
- {
- // if we have no predicate pushdown, use the full range
- if (!domain.isPresent()) {
- return ImmutableSet.of(new Range());
- }
-
- ImmutableSet.Builder rangeBuilder = ImmutableSet.builder();
- for (io.prestosql.spi.predicate.Range range : domain.get().getValues().getRanges().getOrderedRanges()) {
- rangeBuilder.add(getRangeFromPrestoRange(range, serializer));
- }
-
- return rangeBuilder.build();
- }
-
- private static Range getRangeFromPrestoRange(io.prestosql.spi.predicate.Range prestoRange, AccumuloRowSerializer serializer)
- throws TableNotFoundException
- {
- Range accumuloRange;
- if (prestoRange.isAll()) {
- accumuloRange = new Range();
- }
- else if (prestoRange.isSingleValue()) {
- Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getSingleValue()));
- accumuloRange = new Range(split);
- }
- else {
- if (prestoRange.getLow().isLowerUnbounded()) {
- // If low is unbounded, then create a range from (-inf, value), checking inclusivity
- boolean inclusive = prestoRange.getHigh().getBound() == Bound.EXACTLY;
- Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getHigh().getValue()));
- accumuloRange = new Range(null, false, split, inclusive);
- }
- else if (prestoRange.getHigh().isUpperUnbounded()) {
- // If high is unbounded, then create a range from (value, +inf), checking inclusivity
- boolean inclusive = prestoRange.getLow().getBound() == Bound.EXACTLY;
- Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getLow().getValue()));
- accumuloRange = new Range(split, inclusive, null, false);
- }
- else {
- // If high is unbounded, then create a range from low to high, checking inclusivity
- boolean startKeyInclusive = prestoRange.getLow().getBound() == Bound.EXACTLY;
- Text startSplit = new Text(serializer.encode(prestoRange.getType(), prestoRange.getLow().getValue()));
-
- boolean endKeyInclusive = prestoRange.getHigh().getBound() == Bound.EXACTLY;
- Text endSplit = new Text(serializer.encode(prestoRange.getType(), prestoRange.getHigh().getValue()));
- accumuloRange = new Range(startSplit, startKeyInclusive, endSplit, endKeyInclusive);
- }
- }
-
- return accumuloRange;
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloConnector.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloConnector.java
deleted file mode 100644
index 74bd9c957921..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloConnector.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo;
-
-import io.airlift.bootstrap.LifeCycleManager;
-import io.airlift.log.Logger;
-import io.prestosql.plugin.accumulo.conf.AccumuloSessionProperties;
-import io.prestosql.plugin.accumulo.conf.AccumuloTableProperties;
-import io.prestosql.plugin.accumulo.io.AccumuloPageSinkProvider;
-import io.prestosql.plugin.accumulo.io.AccumuloRecordSetProvider;
-import io.prestosql.spi.connector.Connector;
-import io.prestosql.spi.connector.ConnectorMetadata;
-import io.prestosql.spi.connector.ConnectorPageSinkProvider;
-import io.prestosql.spi.connector.ConnectorRecordSetProvider;
-import io.prestosql.spi.connector.ConnectorSplitManager;
-import io.prestosql.spi.connector.ConnectorTransactionHandle;
-import io.prestosql.spi.session.PropertyMetadata;
-import io.prestosql.spi.transaction.IsolationLevel;
-
-import javax.inject.Inject;
-
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static io.prestosql.spi.transaction.IsolationLevel.READ_UNCOMMITTED;
-import static io.prestosql.spi.transaction.IsolationLevel.checkConnectorSupports;
-import static java.util.Objects.requireNonNull;
-
-/**
- * Presto Connector for Accumulo.
- * Defines several high-level classes for properties, metadata, retrieving splits, providing I/O operations, etc.
- */
-public class AccumuloConnector
- implements Connector
-{
- private static final Logger LOG = Logger.get(AccumuloConnector.class);
-
- private final LifeCycleManager lifeCycleManager;
- private final AccumuloMetadataFactory metadataFactory;
- private final AccumuloSplitManager splitManager;
- private final AccumuloRecordSetProvider recordSetProvider;
- private final AccumuloPageSinkProvider pageSinkProvider;
- private final AccumuloSessionProperties sessionProperties;
- private final AccumuloTableProperties tableProperties;
- private final ConcurrentMap transactions = new ConcurrentHashMap<>();
-
- @Inject
- public AccumuloConnector(
- LifeCycleManager lifeCycleManager,
- AccumuloMetadataFactory metadataFactory,
- AccumuloSplitManager splitManager,
- AccumuloRecordSetProvider recordSetProvider,
- AccumuloPageSinkProvider pageSinkProvider,
- AccumuloSessionProperties sessionProperties,
- AccumuloTableProperties tableProperties)
- {
- this.lifeCycleManager = requireNonNull(lifeCycleManager, "lifeCycleManager is null");
- this.metadataFactory = requireNonNull(metadataFactory, "metadata is null");
- this.splitManager = requireNonNull(splitManager, "splitManager is null");
- this.recordSetProvider = requireNonNull(recordSetProvider, "recordSetProvider is null");
- this.pageSinkProvider = requireNonNull(pageSinkProvider, "pageSinkProvider is null");
- this.sessionProperties = requireNonNull(sessionProperties, "sessionProperties is null");
- this.tableProperties = requireNonNull(tableProperties, "tableProperties is null");
- }
-
- @Override
- public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle)
- {
- ConnectorMetadata metadata = transactions.get(transactionHandle);
- checkArgument(metadata != null, "no such transaction: %s", transactionHandle);
- return metadata;
- }
-
- @Override
- public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
- {
- checkConnectorSupports(READ_UNCOMMITTED, isolationLevel);
- ConnectorTransactionHandle transaction = new AccumuloTransactionHandle();
- transactions.put(transaction, metadataFactory.create());
- return transaction;
- }
-
- @Override
- public void commit(ConnectorTransactionHandle transactionHandle)
- {
- checkArgument(transactions.remove(transactionHandle) != null, "no such transaction: %s", transactionHandle);
- }
-
- @Override
- public void rollback(ConnectorTransactionHandle transactionHandle)
- {
- AccumuloMetadata metadata = transactions.remove(transactionHandle);
- checkArgument(metadata != null, "no such transaction: %s", transactionHandle);
- metadata.rollback();
- }
-
- @Override
- public ConnectorSplitManager getSplitManager()
- {
- return splitManager;
- }
-
- @Override
- public ConnectorRecordSetProvider getRecordSetProvider()
- {
- return recordSetProvider;
- }
-
- @Override
- public ConnectorPageSinkProvider getPageSinkProvider()
- {
- return pageSinkProvider;
- }
-
- @Override
- public List> getTableProperties()
- {
- return tableProperties.getTableProperties();
- }
-
- @Override
- public List> getSessionProperties()
- {
- return sessionProperties.getSessionProperties();
- }
-
- @Override
- public final void shutdown()
- {
- lifeCycleManager.stop();
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloConnectorFactory.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloConnectorFactory.java
deleted file mode 100644
index 624daec9a183..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloConnectorFactory.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo;
-
-import com.google.inject.Injector;
-import io.airlift.bootstrap.Bootstrap;
-import io.airlift.json.JsonModule;
-import io.prestosql.spi.connector.Connector;
-import io.prestosql.spi.connector.ConnectorContext;
-import io.prestosql.spi.connector.ConnectorFactory;
-import io.prestosql.spi.connector.ConnectorHandleResolver;
-
-import java.util.Map;
-
-import static java.util.Objects.requireNonNull;
-
-public class AccumuloConnectorFactory
- implements ConnectorFactory
-{
- public static final String CONNECTOR_NAME = "accumulo";
-
- @Override
- public String getName()
- {
- return CONNECTOR_NAME;
- }
-
- @Override
- public Connector create(String catalogName, Map config, ConnectorContext context)
- {
- requireNonNull(catalogName, "catalogName is null");
- requireNonNull(config, "requiredConfig is null");
- requireNonNull(context, "context is null");
-
- Bootstrap app = new Bootstrap(
- new JsonModule(),
- new AccumuloModule(context.getTypeManager()));
-
- Injector injector = app
- .strictConfig()
- .doNotInitializeLogging()
- .setRequiredConfigurationProperties(config)
- .initialize();
-
- return injector.getInstance(AccumuloConnector.class);
- }
-
- @Override
- public ConnectorHandleResolver getHandleResolver()
- {
- return new AccumuloHandleResolver();
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloErrorCode.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloErrorCode.java
deleted file mode 100644
index 45b0329196ad..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloErrorCode.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo;
-
-import io.prestosql.spi.ErrorCode;
-import io.prestosql.spi.ErrorCodeSupplier;
-import io.prestosql.spi.ErrorType;
-
-import static io.prestosql.spi.ErrorType.EXTERNAL;
-
-public enum AccumuloErrorCode
- implements ErrorCodeSupplier
-{
- // Thrown when an Accumulo error is caught that we were not expecting,
- // such as when a create table operation fails (even though we know it will succeed due to our validation steps)
- UNEXPECTED_ACCUMULO_ERROR(1, EXTERNAL),
-
- // Thrown when a ZooKeeper error is caught due to a failed operation
- ZOOKEEPER_ERROR(2, EXTERNAL),
-
- // Thrown when a serialization error occurs when reading/writing data from/to Accumulo
- IO_ERROR(3, EXTERNAL),
-
- // Thrown when a table that is expected to exist does not exist
- ACCUMULO_TABLE_DNE(4, EXTERNAL),
-
- // Thrown when a table that is *not* expected to exist, does exist
- ACCUMULO_TABLE_EXISTS(5, EXTERNAL),
-
- // Thrown when an attempt to start/stop MiniAccumuloCluster fails (testing only)
- MINI_ACCUMULO(6, EXTERNAL);
-
- private final ErrorCode errorCode;
-
- AccumuloErrorCode(int code, ErrorType type)
- {
- errorCode = new ErrorCode(code + 0x0103_0000, name(), type);
- }
-
- @Override
- public ErrorCode toErrorCode()
- {
- return errorCode;
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloHandleResolver.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloHandleResolver.java
deleted file mode 100644
index 5479eb84742e..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloHandleResolver.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo;
-
-import io.prestosql.plugin.accumulo.model.AccumuloColumnHandle;
-import io.prestosql.plugin.accumulo.model.AccumuloSplit;
-import io.prestosql.plugin.accumulo.model.AccumuloTableHandle;
-import io.prestosql.spi.connector.ColumnHandle;
-import io.prestosql.spi.connector.ConnectorHandleResolver;
-import io.prestosql.spi.connector.ConnectorInsertTableHandle;
-import io.prestosql.spi.connector.ConnectorOutputTableHandle;
-import io.prestosql.spi.connector.ConnectorSplit;
-import io.prestosql.spi.connector.ConnectorTableHandle;
-import io.prestosql.spi.connector.ConnectorTransactionHandle;
-
-public class AccumuloHandleResolver
- implements ConnectorHandleResolver
-{
- @Override
- public Class extends ConnectorTableHandle> getTableHandleClass()
- {
- return AccumuloTableHandle.class;
- }
-
- @Override
- public Class extends ConnectorInsertTableHandle> getInsertTableHandleClass()
- {
- return AccumuloTableHandle.class;
- }
-
- @Override
- public Class extends ConnectorOutputTableHandle> getOutputTableHandleClass()
- {
- return AccumuloTableHandle.class;
- }
-
- @Override
- public Class extends ColumnHandle> getColumnHandleClass()
- {
- return AccumuloColumnHandle.class;
- }
-
- @Override
- public Class extends ConnectorSplit> getSplitClass()
- {
- return AccumuloSplit.class;
- }
-
- @Override
- public Class extends ConnectorTransactionHandle> getTransactionHandleClass()
- {
- return AccumuloTransactionHandle.class;
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloMetadata.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloMetadata.java
deleted file mode 100644
index 3311f0868690..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloMetadata.java
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import io.airlift.json.JsonCodec;
-import io.airlift.json.JsonCodecFactory;
-import io.airlift.json.ObjectMapperProvider;
-import io.airlift.slice.Slice;
-import io.prestosql.plugin.accumulo.metadata.AccumuloTable;
-import io.prestosql.plugin.accumulo.model.AccumuloColumnHandle;
-import io.prestosql.plugin.accumulo.model.AccumuloTableHandle;
-import io.prestosql.spi.PrestoException;
-import io.prestosql.spi.connector.ColumnHandle;
-import io.prestosql.spi.connector.ColumnMetadata;
-import io.prestosql.spi.connector.ConnectorInsertTableHandle;
-import io.prestosql.spi.connector.ConnectorMetadata;
-import io.prestosql.spi.connector.ConnectorNewTableLayout;
-import io.prestosql.spi.connector.ConnectorOutputMetadata;
-import io.prestosql.spi.connector.ConnectorOutputTableHandle;
-import io.prestosql.spi.connector.ConnectorSession;
-import io.prestosql.spi.connector.ConnectorTableHandle;
-import io.prestosql.spi.connector.ConnectorTableMetadata;
-import io.prestosql.spi.connector.ConnectorTableProperties;
-import io.prestosql.spi.connector.ConnectorViewDefinition;
-import io.prestosql.spi.connector.Constraint;
-import io.prestosql.spi.connector.ConstraintApplicationResult;
-import io.prestosql.spi.connector.SchemaTableName;
-import io.prestosql.spi.connector.SchemaTablePrefix;
-import io.prestosql.spi.connector.TableNotFoundException;
-import io.prestosql.spi.predicate.TupleDomain;
-import io.prestosql.spi.statistics.ComputedStatistics;
-
-import javax.inject.Inject;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
-
-import static com.google.common.base.Preconditions.checkState;
-import static io.prestosql.plugin.accumulo.AccumuloErrorCode.ACCUMULO_TABLE_EXISTS;
-import static io.prestosql.spi.StandardErrorCode.NOT_SUPPORTED;
-import static java.lang.String.format;
-import static java.util.Objects.requireNonNull;
-
-/**
- * Presto metadata provider for Accumulo.
- * Responsible for creating/dropping/listing tables, schemas, columns, all sorts of goodness. Heavily leverages {@link AccumuloClient}.
- */
-public class AccumuloMetadata
- implements ConnectorMetadata
-{
- private static final JsonCodec VIEW_CODEC =
- new JsonCodecFactory(new ObjectMapperProvider()).jsonCodec(ConnectorViewDefinition.class);
-
- private final AccumuloClient client;
- private final AtomicReference rollbackAction = new AtomicReference<>();
-
- @Inject
- public AccumuloMetadata(AccumuloClient client)
- {
- this.client = requireNonNull(client, "client is null");
- }
-
- @Override
- public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional layout)
- {
- checkNoRollback();
-
- SchemaTableName tableName = tableMetadata.getTable();
- AccumuloTable table = client.createTable(tableMetadata);
-
- AccumuloTableHandle handle = new AccumuloTableHandle(
- tableName.getSchemaName(),
- tableName.getTableName(),
- table.getRowId(),
- table.isExternal(),
- table.getSerializerClassName(),
- table.getScanAuthorizations());
-
- setRollback(() -> rollbackCreateTable(table));
-
- return handle;
- }
-
- @Override
- public Optional finishCreateTable(ConnectorSession session, ConnectorOutputTableHandle tableHandle, Collection fragments, Collection computedStatistics)
- {
- clearRollback();
- return Optional.empty();
- }
-
- private void rollbackCreateTable(AccumuloTable table)
- {
- client.dropTable(table);
- }
-
- @Override
- public void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, boolean ignoreExisting)
- {
- client.createTable(tableMetadata);
- }
-
- @Override
- public void dropTable(ConnectorSession session, ConnectorTableHandle tableHandle)
- {
- AccumuloTableHandle handle = (AccumuloTableHandle) tableHandle;
- AccumuloTable table = client.getTable(handle.toSchemaTableName());
- if (table != null) {
- client.dropTable(table);
- }
- }
-
- @Override
- public void renameTable(ConnectorSession session, ConnectorTableHandle tableHandle,
- SchemaTableName newTableName)
- {
- if (client.getTable(newTableName) != null) {
- throw new PrestoException(ACCUMULO_TABLE_EXISTS, "Table " + newTableName + " already exists");
- }
-
- AccumuloTableHandle handle = (AccumuloTableHandle) tableHandle;
- client.renameTable(handle.toSchemaTableName(), newTableName);
- }
-
- @Override
- public void createView(ConnectorSession session, SchemaTableName viewName, ConnectorViewDefinition definition, boolean replace)
- {
- String viewData = VIEW_CODEC.toJson(definition);
- if (replace) {
- client.createOrReplaceView(viewName, viewData);
- }
- else {
- client.createView(viewName, viewData);
- }
- }
-
- @Override
- public void dropView(ConnectorSession session, SchemaTableName viewName)
- {
- client.dropView(viewName);
- }
-
- @Override
- public Optional getView(ConnectorSession session, SchemaTableName viewName)
- {
- return Optional.ofNullable(client.getView(viewName))
- .map(view -> VIEW_CODEC.fromJson(view.getData()));
- }
-
- @Override
- public List listViews(ConnectorSession session, Optional schemaName)
- {
- return listViews(schemaName);
- }
-
- /**
- * Gets all views in the given schema, or all schemas if null.
- *
- * @param filterSchema Schema to filter the views, or absent to list all schemas
- * @return List of views
- */
- private List listViews(Optional filterSchema)
- {
- ImmutableList.Builder builder = ImmutableList.builder();
- if (filterSchema.isPresent()) {
- for (String view : client.getViewNames(filterSchema.get())) {
- builder.add(new SchemaTableName(filterSchema.get(), view));
- }
- }
- else {
- for (String schemaName : client.getSchemaNames()) {
- for (String view : client.getViewNames(schemaName)) {
- builder.add(new SchemaTableName(schemaName, view));
- }
- }
- }
-
- return builder.build();
- }
-
- @Override
- public ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle)
- {
- checkNoRollback();
- AccumuloTableHandle handle = (AccumuloTableHandle) tableHandle;
- setRollback(() -> rollbackInsert(handle));
- return handle;
- }
-
- @Override
- public Optional finishInsert(ConnectorSession session, ConnectorInsertTableHandle insertHandle, Collection fragments, Collection computedStatistics)
- {
- clearRollback();
- return Optional.empty();
- }
-
- private static void rollbackInsert(ConnectorInsertTableHandle insertHandle)
- {
- // Rollbacks for inserts are off the table when it comes to data in Accumulo.
- // When a batch of Mutations fails to be inserted, the general strategy
- // is to run the insert operation again until it is successful
- // Any mutations that were successfully written will be overwritten
- // with the same values, so that isn't a problem.
- AccumuloTableHandle handle = (AccumuloTableHandle) insertHandle;
- throw new PrestoException(NOT_SUPPORTED, format("Unable to rollback insert for table %s.%s. Some rows may have been written. Please run your insert again.", handle.getSchema(), handle.getTable()));
- }
-
- @Override
- public ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName)
- {
- if (!listSchemaNames(session).contains(tableName.getSchemaName().toLowerCase(Locale.ENGLISH))) {
- return null;
- }
-
- // Need to validate that SchemaTableName is a table
- if (!this.listViews(session, Optional.of(tableName.getSchemaName())).contains(tableName)) {
- AccumuloTable table = client.getTable(tableName);
- if (table == null) {
- return null;
- }
-
- return new AccumuloTableHandle(
- table.getSchema(),
- table.getTable(),
- table.getRowId(),
- table.isExternal(),
- table.getSerializerClassName(),
- table.getScanAuthorizations());
- }
-
- return null;
- }
-
- @Override
- public ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle table)
- {
- AccumuloTableHandle handle = (AccumuloTableHandle) table;
- SchemaTableName tableName = new SchemaTableName(handle.getSchema(), handle.getTable());
- ConnectorTableMetadata metadata = getTableMetadata(tableName);
- if (metadata == null) {
- throw new TableNotFoundException(tableName);
- }
- return metadata;
- }
-
- @Override
- public Map getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle)
- {
- AccumuloTableHandle handle = (AccumuloTableHandle) tableHandle;
-
- AccumuloTable table = client.getTable(handle.toSchemaTableName());
- if (table == null) {
- throw new TableNotFoundException(handle.toSchemaTableName());
- }
-
- ImmutableMap.Builder columnHandles = ImmutableMap.builder();
- for (AccumuloColumnHandle column : table.getColumns()) {
- columnHandles.put(column.getName(), column);
- }
- return columnHandles.build();
- }
-
- @Override
- public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle)
- {
- return ((AccumuloColumnHandle) columnHandle).getColumnMetadata();
- }
-
- @Override
- public void renameColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle source, String target)
- {
- AccumuloTableHandle handle = (AccumuloTableHandle) tableHandle;
- AccumuloColumnHandle columnHandle = (AccumuloColumnHandle) source;
- AccumuloTable table = client.getTable(handle.toSchemaTableName());
- if (table == null) {
- throw new TableNotFoundException(new SchemaTableName(handle.getSchema(), handle.getTable()));
- }
-
- client.renameColumn(table, columnHandle.getName(), target);
- }
-
- @Override
- public List listSchemaNames(ConnectorSession session)
- {
- return ImmutableList.copyOf(client.getSchemaNames());
- }
-
- @Override
- public List listTables(ConnectorSession session, Optional filterSchema)
- {
- Set schemaNames = filterSchema.>map(ImmutableSet::of)
- .orElseGet(client::getSchemaNames);
-
- ImmutableList.Builder builder = ImmutableList.builder();
- for (String schemaName : schemaNames) {
- for (String tableName : client.getTableNames(schemaName)) {
- builder.add(new SchemaTableName(schemaName, tableName));
- }
- }
- return builder.build();
- }
-
- @Override
- public Map> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
- {
- requireNonNull(prefix, "prefix is null");
- ImmutableMap.Builder> columns = ImmutableMap.builder();
- for (SchemaTableName tableName : listTables(session, prefix)) {
- ConnectorTableMetadata tableMetadata = getTableMetadata(tableName);
- // table can disappear during listing operation
- if (tableMetadata != null) {
- columns.put(tableName, tableMetadata.getColumns());
- }
- }
- return columns.build();
- }
-
- @Override
- public boolean usesLegacyTableLayouts()
- {
- return false;
- }
-
- @Override
- public Optional> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint)
- {
- AccumuloTableHandle handle = (AccumuloTableHandle) table;
-
- TupleDomain oldDomain = handle.getConstraint();
- TupleDomain newDomain = oldDomain.intersect(constraint.getSummary());
- if (oldDomain.equals(newDomain)) {
- return Optional.empty();
- }
-
- handle = new AccumuloTableHandle(
- handle.getSchema(),
- handle.getTable(),
- handle.getRowId(),
- newDomain,
- handle.isExternal(),
- handle.getSerializerClassName(),
- handle.getScanAuthorizations());
-
- return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary()));
- }
-
- @Override
- public ConnectorTableProperties getTableProperties(ConnectorSession session, ConnectorTableHandle handle)
- {
- return new ConnectorTableProperties();
- }
-
- private void checkNoRollback()
- {
- checkState(rollbackAction.get() == null, "Cannot begin a new write while in an existing one");
- }
-
- private void setRollback(Runnable action)
- {
- checkState(rollbackAction.compareAndSet(null, action), "Should not have to override existing rollback action");
- }
-
- private void clearRollback()
- {
- rollbackAction.set(null);
- }
-
- public void rollback()
- {
- Runnable rollbackAction = this.rollbackAction.getAndSet(null);
- if (rollbackAction != null) {
- rollbackAction.run();
- }
- }
-
- private ConnectorTableMetadata getTableMetadata(SchemaTableName tableName)
- {
- if (!client.getSchemaNames().contains(tableName.getSchemaName())) {
- return null;
- }
-
- // Need to validate that SchemaTableName is a table
- if (!this.listViews(Optional.ofNullable(tableName.getSchemaName())).contains(tableName)) {
- AccumuloTable table = client.getTable(tableName);
- if (table == null) {
- return null;
- }
-
- return new ConnectorTableMetadata(tableName, table.getColumnsMetadata());
- }
-
- return null;
- }
-
- private List listTables(ConnectorSession session, SchemaTablePrefix prefix)
- {
- // List all tables if schema or table is null
- if (!prefix.getTable().isPresent()) {
- return listTables(session, prefix.getSchema());
- }
-
- // Make sure requested table exists, returning the single table of it does
- SchemaTableName table = prefix.toSchemaTableName();
- if (getTableHandle(session, table) != null) {
- return ImmutableList.of(table);
- }
-
- // Else, return empty list
- return ImmutableList.of();
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloMetadataFactory.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloMetadataFactory.java
deleted file mode 100644
index d5f8bf27ba0d..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloMetadataFactory.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo;
-
-import javax.inject.Inject;
-
-import static java.util.Objects.requireNonNull;
-
-public class AccumuloMetadataFactory
-{
- private final AccumuloClient client;
-
- @Inject
- public AccumuloMetadataFactory(AccumuloClient client)
- {
- this.client = requireNonNull(client, "client is null");
- }
-
- public AccumuloMetadata create()
- {
- return new AccumuloMetadata(client);
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloModule.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloModule.java
deleted file mode 100644
index a341ef934a35..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloModule.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo;
-
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.deser.std.FromStringDeserializer;
-import com.google.inject.Binder;
-import com.google.inject.Module;
-import com.google.inject.Scopes;
-import io.airlift.json.JsonCodec;
-import io.airlift.log.Logger;
-import io.prestosql.plugin.accumulo.conf.AccumuloConfig;
-import io.prestosql.plugin.accumulo.conf.AccumuloSessionProperties;
-import io.prestosql.plugin.accumulo.conf.AccumuloTableProperties;
-import io.prestosql.plugin.accumulo.index.ColumnCardinalityCache;
-import io.prestosql.plugin.accumulo.index.IndexLookup;
-import io.prestosql.plugin.accumulo.io.AccumuloPageSinkProvider;
-import io.prestosql.plugin.accumulo.io.AccumuloRecordSetProvider;
-import io.prestosql.plugin.accumulo.metadata.AccumuloTable;
-import io.prestosql.plugin.accumulo.metadata.ZooKeeperMetadataManager;
-import io.prestosql.spi.PrestoException;
-import io.prestosql.spi.type.Type;
-import io.prestosql.spi.type.TypeId;
-import io.prestosql.spi.type.TypeManager;
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.ZooKeeperInstance;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.log4j.JulAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.PatternLayout;
-
-import javax.inject.Inject;
-import javax.inject.Provider;
-
-import static io.airlift.configuration.ConfigBinder.configBinder;
-import static io.airlift.json.JsonBinder.jsonBinder;
-import static io.airlift.json.JsonCodecBinder.jsonCodecBinder;
-import static io.prestosql.plugin.accumulo.AccumuloErrorCode.UNEXPECTED_ACCUMULO_ERROR;
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static java.util.Objects.requireNonNull;
-
-/**
- * Presto module to do all kinds of run Guice injection stuff!
- *
- * WARNING: Contains black magick
- */
-public class AccumuloModule
- implements Module
-{
- private final TypeManager typeManager;
-
- public AccumuloModule(TypeManager typeManager)
- {
- this.typeManager = requireNonNull(typeManager, "typeManager is null");
- }
-
- @Override
- public void configure(Binder binder)
- {
- // Add appender to Log4J root logger
- JulAppender appender = new JulAppender(); //create appender
- appender.setLayout(new PatternLayout("%d %-5p %c - %m%n"));
- appender.setThreshold(Level.INFO);
- appender.activateOptions();
- org.apache.log4j.Logger.getRootLogger().addAppender(appender);
-
- binder.bind(TypeManager.class).toInstance(typeManager);
-
- binder.bind(AccumuloConnector.class).in(Scopes.SINGLETON);
- binder.bind(AccumuloMetadata.class).in(Scopes.SINGLETON);
- binder.bind(AccumuloMetadataFactory.class).in(Scopes.SINGLETON);
- binder.bind(AccumuloClient.class).in(Scopes.SINGLETON);
- binder.bind(AccumuloSplitManager.class).in(Scopes.SINGLETON);
- binder.bind(AccumuloRecordSetProvider.class).in(Scopes.SINGLETON);
- binder.bind(AccumuloPageSinkProvider.class).in(Scopes.SINGLETON);
- binder.bind(AccumuloHandleResolver.class).in(Scopes.SINGLETON);
- binder.bind(AccumuloSessionProperties.class).in(Scopes.SINGLETON);
- binder.bind(AccumuloTableProperties.class).in(Scopes.SINGLETON);
- binder.bind(ZooKeeperMetadataManager.class).in(Scopes.SINGLETON);
- binder.bind(AccumuloTableManager.class).in(Scopes.SINGLETON);
- binder.bind(IndexLookup.class).in(Scopes.SINGLETON);
- binder.bind(ColumnCardinalityCache.class).in(Scopes.SINGLETON);
- binder.bind(Connector.class).toProvider(ConnectorProvider.class);
-
- configBinder(binder).bindConfig(AccumuloConfig.class);
-
- jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
- jsonCodecBinder(binder).bindMapJsonCodec(String.class, JsonCodec.listJsonCodec(AccumuloTable.class));
- }
-
- public static final class TypeDeserializer
- extends FromStringDeserializer
- {
- private final TypeManager typeManager;
-
- @Inject
- public TypeDeserializer(TypeManager typeManager)
- {
- super(Type.class);
- this.typeManager = requireNonNull(typeManager, "typeManager is null");
- }
-
- @Override
- protected Type _deserialize(String value, DeserializationContext context)
- {
- return typeManager.getType(TypeId.of(value));
- }
- }
-
- private static class ConnectorProvider
- implements Provider
- {
- private static final Logger LOG = Logger.get(ConnectorProvider.class);
-
- private final String instance;
- private final String zooKeepers;
- private final String username;
- private final String password;
-
- @Inject
- public ConnectorProvider(AccumuloConfig config)
- {
- requireNonNull(config, "config is null");
- this.instance = config.getInstance();
- this.zooKeepers = config.getZooKeepers();
- this.username = config.getUsername();
- this.password = config.getPassword();
- }
-
- @Override
- public Connector get()
- {
- try {
- Instance inst = new ZooKeeperInstance(instance, zooKeepers);
- Connector connector = inst.getConnector(username, new PasswordToken(password.getBytes(UTF_8)));
- LOG.info("Connection to instance %s at %s established, user %s", instance, zooKeepers, username);
- return connector;
- }
- catch (AccumuloException | AccumuloSecurityException e) {
- throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to get connector to Accumulo", e);
- }
- }
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloPlugin.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloPlugin.java
deleted file mode 100644
index 888ab9cb7f34..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloPlugin.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo;
-
-import com.google.common.collect.ImmutableList;
-import io.prestosql.spi.Plugin;
-import io.prestosql.spi.connector.ConnectorFactory;
-
-public class AccumuloPlugin
- implements Plugin
-{
- @Override
- public Iterable getConnectorFactories()
- {
- return ImmutableList.of(new AccumuloConnectorFactory());
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloSplitManager.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloSplitManager.java
deleted file mode 100644
index 196ce3745236..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloSplitManager.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo;
-
-import com.google.common.collect.ImmutableList;
-import io.prestosql.plugin.accumulo.model.AccumuloColumnConstraint;
-import io.prestosql.plugin.accumulo.model.AccumuloColumnHandle;
-import io.prestosql.plugin.accumulo.model.AccumuloSplit;
-import io.prestosql.plugin.accumulo.model.AccumuloTableHandle;
-import io.prestosql.plugin.accumulo.model.TabletSplitMetadata;
-import io.prestosql.plugin.accumulo.model.WrappedRange;
-import io.prestosql.spi.connector.ColumnHandle;
-import io.prestosql.spi.connector.ConnectorSession;
-import io.prestosql.spi.connector.ConnectorSplit;
-import io.prestosql.spi.connector.ConnectorSplitManager;
-import io.prestosql.spi.connector.ConnectorSplitSource;
-import io.prestosql.spi.connector.ConnectorTableHandle;
-import io.prestosql.spi.connector.ConnectorTransactionHandle;
-import io.prestosql.spi.connector.FixedSplitSource;
-import io.prestosql.spi.predicate.Domain;
-import io.prestosql.spi.predicate.TupleDomain;
-import io.prestosql.spi.predicate.TupleDomain.ColumnDomain;
-
-import javax.inject.Inject;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import static java.util.Objects.requireNonNull;
-
-public class AccumuloSplitManager
- implements ConnectorSplitManager
-{
- private final AccumuloClient client;
-
- @Inject
- public AccumuloSplitManager(AccumuloClient client)
- {
- this.client = requireNonNull(client, "client is null");
- }
-
- @Override
- public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableHandle tableHandle, SplitSchedulingStrategy splitSchedulingStrategy)
- {
- AccumuloTableHandle handle = (AccumuloTableHandle) tableHandle;
-
- String schemaName = handle.getSchema();
- String tableName = handle.getTable();
- String rowIdName = handle.getRowId();
-
- // Get non-row ID column constraints
- List constraints = getColumnConstraints(rowIdName, handle.getConstraint());
-
- // Get the row domain column range
- Optional rDom = getRangeDomain(rowIdName, handle.getConstraint());
-
- // Call out to our client to retrieve all tablet split metadata using the row ID domain and the secondary index
- List tabletSplits = client.getTabletSplits(session, schemaName, tableName, rDom, constraints, handle.getSerializerInstance());
-
- // Pack the tablet split metadata into a connector split
- ImmutableList.Builder cSplits = ImmutableList.builder();
- for (TabletSplitMetadata splitMetadata : tabletSplits) {
- AccumuloSplit split = new AccumuloSplit(
- splitMetadata.getRanges().stream().map(WrappedRange::new).collect(Collectors.toList()),
- splitMetadata.getHostPort());
- cSplits.add(split);
- }
-
- return new FixedSplitSource(cSplits.build());
- }
-
- private static Optional getRangeDomain(String rowIdName, TupleDomain constraint)
- {
- if (constraint.getColumnDomains().isPresent()) {
- for (ColumnDomain cd : constraint.getColumnDomains().get()) {
- AccumuloColumnHandle col = (AccumuloColumnHandle) cd.getColumn();
- if (col.getName().equals(rowIdName)) {
- return Optional.of(cd.getDomain());
- }
- }
- }
-
- return Optional.empty();
- }
-
- /**
- * Gets a list of {@link AccumuloColumnConstraint} based on the given constraint ID, excluding the row ID column
- *
- * @param rowIdName Presto column name mapping to the Accumulo row ID
- * @param constraint Set of query constraints
- * @return List of all column constraints
- */
- private static List getColumnConstraints(String rowIdName, TupleDomain constraint)
- {
- ImmutableList.Builder constraintBuilder = ImmutableList.builder();
- for (ColumnDomain columnDomain : constraint.getColumnDomains().get()) {
- AccumuloColumnHandle columnHandle = (AccumuloColumnHandle) columnDomain.getColumn();
-
- if (!columnHandle.getName().equals(rowIdName)) {
- // Family and qualifier will exist for non-row ID columns
- constraintBuilder.add(new AccumuloColumnConstraint(
- columnHandle.getName(),
- columnHandle.getFamily().get(),
- columnHandle.getQualifier().get(),
- Optional.of(columnDomain.getDomain()),
- columnHandle.isIndexed()));
- }
- }
-
- return constraintBuilder.build();
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloTableManager.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloTableManager.java
deleted file mode 100644
index 7b2f2f792d02..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloTableManager.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo;
-
-import io.airlift.log.Logger;
-import io.prestosql.spi.PrestoException;
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.NamespaceExistsException;
-import org.apache.accumulo.core.client.TableExistsException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
-import org.apache.hadoop.io.Text;
-
-import javax.inject.Inject;
-
-import java.util.EnumSet;
-import java.util.Map;
-import java.util.Set;
-
-import static io.prestosql.plugin.accumulo.AccumuloErrorCode.ACCUMULO_TABLE_DNE;
-import static io.prestosql.plugin.accumulo.AccumuloErrorCode.ACCUMULO_TABLE_EXISTS;
-import static io.prestosql.plugin.accumulo.AccumuloErrorCode.UNEXPECTED_ACCUMULO_ERROR;
-import static java.util.Objects.requireNonNull;
-
-/**
- * This class is a light wrapper for Accumulo's Connector object.
- * It will perform the given operation, or throw an exception if an Accumulo- or ZooKeeper-based error occurs.
- */
-public class AccumuloTableManager
-{
- private static final Logger LOG = Logger.get(AccumuloTableManager.class);
- private static final String DEFAULT = "default";
- private final Connector connector;
-
- @Inject
- public AccumuloTableManager(Connector connector)
- {
- this.connector = requireNonNull(connector, "connector is null");
- }
-
- /**
- * Ensures the given Accumulo namespace exist, creating it if necessary
- *
- * @param schema Presto schema (Accumulo namespace)
- */
- public void ensureNamespace(String schema)
- {
- try {
- // If the table schema is not "default" and the namespace does not exist, create it
- if (!schema.equals(DEFAULT) && !connector.namespaceOperations().exists(schema)) {
- connector.namespaceOperations().create(schema);
- }
- }
- catch (AccumuloException | AccumuloSecurityException e) {
- throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to check for existence or create Accumulo namespace", e);
- }
- catch (NamespaceExistsException e) {
- // Suppress race condition between test for existence and creation
- LOG.warn("NamespaceExistsException suppressed when creating " + schema);
- }
- }
-
- public boolean exists(String table)
- {
- return connector.tableOperations().exists(table);
- }
-
- public void createAccumuloTable(String table)
- {
- try {
- connector.tableOperations().create(table);
- }
- catch (AccumuloException | AccumuloSecurityException e) {
- throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to create Accumulo table", e);
- }
- catch (TableExistsException e) {
- throw new PrestoException(ACCUMULO_TABLE_EXISTS, "Accumulo table already exists", e);
- }
- }
-
- public void setLocalityGroups(String tableName, Map> groups)
- {
- if (groups.isEmpty()) {
- return;
- }
-
- try {
- connector.tableOperations().setLocalityGroups(tableName, groups);
- LOG.debug("Set locality groups for %s to %s", tableName, groups);
- }
- catch (AccumuloException | AccumuloSecurityException e) {
- throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to set locality groups", e);
- }
- catch (TableNotFoundException e) {
- throw new PrestoException(ACCUMULO_TABLE_DNE, "Failed to set locality groups, table does not exist", e);
- }
- }
-
- public void setIterator(String table, IteratorSetting setting)
- {
- try {
- // Remove any existing iterator settings of the same name, if applicable
- Map> iterators = connector.tableOperations().listIterators(table);
- if (iterators.containsKey(setting.getName())) {
- connector.tableOperations().removeIterator(table, setting.getName(), iterators.get(setting.getName()));
- }
-
- connector.tableOperations().attachIterator(table, setting);
- }
- catch (AccumuloSecurityException | AccumuloException e) {
- throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to set iterator on table " + table, e);
- }
- catch (TableNotFoundException e) {
- throw new PrestoException(ACCUMULO_TABLE_DNE, "Failed to set iterator, table does not exist", e);
- }
- }
-
- public void deleteAccumuloTable(String tableName)
- {
- try {
- connector.tableOperations().delete(tableName);
- }
- catch (AccumuloException | AccumuloSecurityException e) {
- throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to delete Accumulo table", e);
- }
- catch (TableNotFoundException e) {
- throw new PrestoException(ACCUMULO_TABLE_DNE, "Failed to delete Accumulo table, does not exist", e);
- }
- }
-
- public void renameAccumuloTable(String oldName, String newName)
- {
- try {
- connector.tableOperations().rename(oldName, newName);
- }
- catch (AccumuloSecurityException | AccumuloException e) {
- throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to rename table", e);
- }
- catch (TableNotFoundException e) {
- throw new PrestoException(ACCUMULO_TABLE_DNE, "Failed to rename table, old table does not exist", e);
- }
- catch (TableExistsException e) {
- throw new PrestoException(ACCUMULO_TABLE_EXISTS, "Failed to rename table, new table already exists", e);
- }
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloTransactionHandle.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloTransactionHandle.java
deleted file mode 100644
index 317bcdcc0116..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/AccumuloTransactionHandle.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import io.prestosql.spi.connector.ConnectorTransactionHandle;
-
-import java.util.Objects;
-import java.util.UUID;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static java.util.Objects.requireNonNull;
-
-public class AccumuloTransactionHandle
- implements ConnectorTransactionHandle
-{
- private final UUID uuid;
-
- public AccumuloTransactionHandle()
- {
- this(UUID.randomUUID());
- }
-
- @JsonCreator
- public AccumuloTransactionHandle(@JsonProperty("uuid") UUID uuid)
- {
- this.uuid = requireNonNull(uuid, "uuid is null");
- }
-
- @JsonProperty
- public UUID getUuid()
- {
- return uuid;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj) {
- return true;
- }
- if ((obj == null) || (getClass() != obj.getClass())) {
- return false;
- }
-
- return Objects.equals(uuid, ((AccumuloTransactionHandle) obj).uuid);
- }
-
- @Override
- public int hashCode()
- {
- return Objects.hash(uuid);
- }
-
- @Override
- public String toString()
- {
- return toStringHelper(this).add("uuid", uuid).toString();
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/Types.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/Types.java
deleted file mode 100644
index ba5951ebebda..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/Types.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo;
-
-import io.prestosql.spi.type.ArrayType;
-import io.prestosql.spi.type.MapType;
-import io.prestosql.spi.type.Type;
-
-/**
- * Utility class for Presto Type-related functionality.
- */
-public final class Types
-{
- private Types() {}
-
- public static boolean isArrayType(Type type)
- {
- return type instanceof ArrayType;
- }
-
- public static boolean isMapType(Type type)
- {
- return type instanceof MapType;
- }
-
- /**
- * Gets the element type of the given array type. Does not validate that the given type is an array.
- *
- * @param type An array type
- * @return Element type of the array
- * @throws IndexOutOfBoundsException If type is not an array
- * @see Types#isArrayType
- */
- public static Type getElementType(Type type)
- {
- return type.getTypeParameters().get(0);
- }
-
- /**
- * Gets the key type of the given map type. Does not validate that the given type is a map.
- *
- * @param type A map type
- * @return Key type of the map
- * @throws IndexOutOfBoundsException If type is not a map
- * @see Types#isMapType
- */
- public static Type getKeyType(Type type)
- {
- return type.getTypeParameters().get(0);
- }
-
- /**
- * Gets the value type of the given map type. Does not validate that the given type is a map.
- *
- * @param type A map type
- * @return Value type of the map
- * @throws IndexOutOfBoundsException If type is not a map
- * @see Types#isMapType
- */
- public static Type getValueType(Type type)
- {
- return type.getTypeParameters().get(1);
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/conf/AccumuloConfig.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/conf/AccumuloConfig.java
deleted file mode 100644
index 7939ab88446d..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/conf/AccumuloConfig.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo.conf;
-
-import io.airlift.configuration.Config;
-import io.airlift.configuration.ConfigDescription;
-import io.airlift.configuration.ConfigSecuritySensitive;
-import io.airlift.units.Duration;
-
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * File-based configuration properties for the Accumulo connector
- */
-public class AccumuloConfig
-{
- public static final String INSTANCE = "accumulo.instance";
- public static final String ZOOKEEPERS = "accumulo.zookeepers";
- public static final String USERNAME = "accumulo.username";
- public static final String PASSWORD = "accumulo.password";
- public static final String ZOOKEEPER_METADATA_ROOT = "accumulo.zookeeper.metadata.root";
- public static final String CARDINALITY_CACHE_SIZE = "accumulo.cardinality.cache.size";
- public static final String CARDINALITY_CACHE_EXPIRE_DURATION = "accumulo.cardinality.cache.expire.duration";
-
- private String instance;
- private String zooKeepers;
- private String username;
- private String password;
- private String zkMetadataRoot = "/presto-accumulo";
- private int cardinalityCacheSize = 100_000;
- private Duration cardinalityCacheExpiration = new Duration(5, TimeUnit.MINUTES);
-
- @NotNull
- public String getInstance()
- {
- return this.instance;
- }
-
- @Config(INSTANCE)
- @ConfigDescription("Accumulo instance name")
- public AccumuloConfig setInstance(String instance)
- {
- this.instance = instance;
- return this;
- }
-
- @NotNull
- public String getZooKeepers()
- {
- return this.zooKeepers;
- }
-
- @Config(ZOOKEEPERS)
- @ConfigDescription("ZooKeeper quorum connect string for Accumulo")
- public AccumuloConfig setZooKeepers(String zooKeepers)
- {
- this.zooKeepers = zooKeepers;
- return this;
- }
-
- @NotNull
- public String getUsername()
- {
- return this.username;
- }
-
- @Config(USERNAME)
- @ConfigDescription("Sets the user to use when interacting with Accumulo. This user will require administrative permissions")
- public AccumuloConfig setUsername(String username)
- {
- this.username = username;
- return this;
- }
-
- @NotNull
- public String getPassword()
- {
- return this.password;
- }
-
- @Config(PASSWORD)
- @ConfigSecuritySensitive
- @ConfigDescription("Sets the password for the configured user")
- public AccumuloConfig setPassword(String password)
- {
- this.password = password;
- return this;
- }
-
- @NotNull
- public String getZkMetadataRoot()
- {
- return zkMetadataRoot;
- }
-
- @Config(ZOOKEEPER_METADATA_ROOT)
- @ConfigDescription("Sets the root znode for metadata storage")
- public void setZkMetadataRoot(String zkMetadataRoot)
- {
- this.zkMetadataRoot = zkMetadataRoot;
- }
-
- @NotNull
- @Min(1)
- public int getCardinalityCacheSize()
- {
- return cardinalityCacheSize;
- }
-
- @Config(CARDINALITY_CACHE_SIZE)
- @ConfigDescription("Sets the cardinality cache size")
- public void setCardinalityCacheSize(int cardinalityCacheSize)
- {
- this.cardinalityCacheSize = cardinalityCacheSize;
- }
-
- @NotNull
- public Duration getCardinalityCacheExpiration()
- {
- return cardinalityCacheExpiration;
- }
-
- @Config(CARDINALITY_CACHE_EXPIRE_DURATION)
- @ConfigDescription("Sets the cardinality cache expiration")
- public void setCardinalityCacheExpiration(Duration cardinalityCacheExpiration)
- {
- this.cardinalityCacheExpiration = cardinalityCacheExpiration;
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/conf/AccumuloSessionProperties.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/conf/AccumuloSessionProperties.java
deleted file mode 100644
index fee1f433e314..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/conf/AccumuloSessionProperties.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo.conf;
-
-import com.google.common.collect.ImmutableList;
-import io.airlift.units.Duration;
-import io.prestosql.spi.connector.ConnectorSession;
-import io.prestosql.spi.session.PropertyMetadata;
-
-import javax.inject.Inject;
-
-import java.util.List;
-
-import static io.prestosql.spi.session.PropertyMetadata.booleanProperty;
-import static io.prestosql.spi.session.PropertyMetadata.doubleProperty;
-import static io.prestosql.spi.session.PropertyMetadata.integerProperty;
-import static io.prestosql.spi.session.PropertyMetadata.stringProperty;
-import static io.prestosql.spi.type.VarcharType.VARCHAR;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-
-/**
- * Class contains all session-based properties for the Accumulo connector.
- * Use SHOW SESSION to view all available properties in the Presto CLI.
- *
- * Can set the property using:
- *
- * SET SESSION <property> = <value>;
- */
-public final class AccumuloSessionProperties
-{
- private static final String OPTIMIZE_LOCALITY_ENABLED = "optimize_locality_enabled";
- private static final String OPTIMIZE_SPLIT_RANGES_ENABLED = "optimize_split_ranges_enabled";
- private static final String OPTIMIZE_INDEX_ENABLED = "optimize_index_enabled";
- private static final String INDEX_ROWS_PER_SPLIT = "index_rows_per_split";
- private static final String INDEX_THRESHOLD = "index_threshold";
- private static final String INDEX_LOWEST_CARDINALITY_THRESHOLD = "index_lowest_cardinality_threshold";
- private static final String INDEX_METRICS_ENABLED = "index_metrics_enabled";
- private static final String SCAN_USERNAME = "scan_username";
- private static final String INDEX_SHORT_CIRCUIT_CARDINALITY_FETCH = "index_short_circuit_cardinality_fetch";
- private static final String INDEX_CARDINALITY_CACHE_POLLING_DURATION = "index_cardinality_cache_polling_duration";
-
- private final List> sessionProperties;
-
- @Inject
- public AccumuloSessionProperties()
- {
- sessionProperties = ImmutableList.of(
- booleanProperty(
- OPTIMIZE_LOCALITY_ENABLED,
- "Set to true to enable data locality for non-indexed scans. Default true.", true,
- false),
- booleanProperty(
- OPTIMIZE_SPLIT_RANGES_ENABLED,
- "Set to true to split non-indexed queries by tablet splits. Should generally be true.",
- true, false),
- stringProperty(
- SCAN_USERNAME,
- "User to impersonate when scanning the tables. This property trumps the scan_auths table property. Default is the user in the configuration file.", null, false),
- booleanProperty(
- OPTIMIZE_INDEX_ENABLED,
- "Set to true to enable usage of the secondary index on query. Default true.",
- true,
- false),
- integerProperty(
- INDEX_ROWS_PER_SPLIT,
- "The number of Accumulo row IDs that are packed into a single Presto split. Default 10000",
- 10000,
- false),
- doubleProperty(
- INDEX_THRESHOLD,
- "The ratio between number of rows to be scanned based on the index over the total number of rows. If the ratio is below this threshold, the index will be used. Default .2",
- 0.2,
- false),
- doubleProperty(
- INDEX_LOWEST_CARDINALITY_THRESHOLD,
- "The threshold where the column with the lowest cardinality will be used instead of computing an intersection of ranges in the secondary index. Secondary index must be enabled. Default .01",
- 0.01,
- false),
- booleanProperty(
- INDEX_METRICS_ENABLED,
- "Set to true to enable usage of the metrics table to optimize usage of the index. Default true",
- true,
- false),
- booleanProperty(
- INDEX_SHORT_CIRCUIT_CARDINALITY_FETCH,
- "Short circuit the retrieval of index metrics once any column is less than the lowest cardinality threshold. Default true",
- true,
- false),
- durationProperty(
- INDEX_CARDINALITY_CACHE_POLLING_DURATION,
- "Sets the cardinality cache polling duration for short circuit retrieval of index metrics. Default 10ms",
- new Duration(10, MILLISECONDS),
- false));
- }
-
- public List> getSessionProperties()
- {
- return sessionProperties;
- }
-
- public static boolean isOptimizeLocalityEnabled(ConnectorSession session)
- {
- return session.getProperty(OPTIMIZE_LOCALITY_ENABLED, Boolean.class);
- }
-
- public static boolean isOptimizeSplitRangesEnabled(ConnectorSession session)
- {
- return session.getProperty(OPTIMIZE_SPLIT_RANGES_ENABLED, Boolean.class);
- }
-
- public static boolean isOptimizeIndexEnabled(ConnectorSession session)
- {
- return session.getProperty(OPTIMIZE_INDEX_ENABLED, Boolean.class);
- }
-
- public static double getIndexThreshold(ConnectorSession session)
- {
- return session.getProperty(INDEX_THRESHOLD, Double.class);
- }
-
- public static int getNumIndexRowsPerSplit(ConnectorSession session)
- {
- return session.getProperty(INDEX_ROWS_PER_SPLIT, Integer.class);
- }
-
- public static double getIndexSmallCardThreshold(ConnectorSession session)
- {
- return session.getProperty(INDEX_LOWEST_CARDINALITY_THRESHOLD, Double.class);
- }
-
- public static Duration getIndexCardinalityCachePollingDuration(ConnectorSession session)
- {
- return session.getProperty(INDEX_CARDINALITY_CACHE_POLLING_DURATION, Duration.class);
- }
-
- public static boolean isIndexMetricsEnabled(ConnectorSession session)
- {
- return session.getProperty(INDEX_METRICS_ENABLED, Boolean.class);
- }
-
- public static String getScanUsername(ConnectorSession session)
- {
- return session.getProperty(SCAN_USERNAME, String.class);
- }
-
- public static boolean isIndexShortCircuitEnabled(ConnectorSession session)
- {
- return session.getProperty(INDEX_SHORT_CIRCUIT_CARDINALITY_FETCH, Boolean.class);
- }
-
- private static PropertyMetadata durationProperty(String name, String description, Duration defaultValue, boolean hidden)
- {
- return new PropertyMetadata<>(
- name,
- description,
- VARCHAR,
- Duration.class,
- defaultValue,
- hidden,
- value -> Duration.valueOf((String) value),
- Duration::toString);
- }
-}
diff --git a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/conf/AccumuloTableProperties.java b/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/conf/AccumuloTableProperties.java
deleted file mode 100644
index 4cb63890156a..000000000000
--- a/presto-accumulo/src/main/java/io/prestosql/plugin/accumulo/conf/AccumuloTableProperties.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Licensed 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 io.prestosql.plugin.accumulo.conf;
-
-import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import io.prestosql.plugin.accumulo.serializers.AccumuloRowSerializer;
-import io.prestosql.plugin.accumulo.serializers.LexicoderRowSerializer;
-import io.prestosql.plugin.accumulo.serializers.StringRowSerializer;
-import io.prestosql.spi.PrestoException;
-import io.prestosql.spi.session.PropertyMetadata;
-import io.prestosql.spi.type.VarcharType;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.tuple.Pair;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkState;
-import static io.prestosql.spi.StandardErrorCode.INVALID_TABLE_PROPERTY;
-import static io.prestosql.spi.session.PropertyMetadata.booleanProperty;
-import static io.prestosql.spi.session.PropertyMetadata.stringProperty;
-import static java.util.Objects.requireNonNull;
-
-/**
- * Class contains all table properties for the Accumulo connector. Used when creating a table:
- *
- * CREATE TABLE foo (a VARCHAR, b INT)
- * WITH (column_mapping = 'b:md:b', external = true);
- */
-public final class AccumuloTableProperties
-{
- public static final String COLUMN_MAPPING = "column_mapping";
- public static final String INDEX_COLUMNS = "index_columns";
- public static final String EXTERNAL = "external";
- public static final String LOCALITY_GROUPS = "locality_groups";
- public static final String ROW_ID = "row_id";
- public static final String SERIALIZER = "serializer";
- public static final String SCAN_AUTHS = "scan_auths";
- private static final Splitter COLON_SPLITTER = Splitter.on(':').trimResults();
- private static final Splitter COMMA_SPLITTER = Splitter.on(',').omitEmptyStrings().trimResults();
- private static final Splitter PIPE_SPLITTER = Splitter.on('|').omitEmptyStrings().trimResults();
-
- private final List> tableProperties;
-
- public AccumuloTableProperties()
- {
- PropertyMetadata s1 = stringProperty(
- COLUMN_MAPPING,
- "Comma-delimited list of column metadata: col_name:col_family:col_qualifier,[...]. Required for external tables. Not setting this property results in auto-generated column names.",
- null,
- false);
-
- PropertyMetadata s2 = stringProperty(
- INDEX_COLUMNS,
- "A comma-delimited list of Presto columns that are indexed in this table's corresponding index table. Default is no indexed columns.",
- "",
- false);
-
- PropertyMetadata s3 = booleanProperty(
- EXTERNAL,
- "If true, Presto will only do metadata operations for the table. Else, Presto will create and drop Accumulo tables where appropriate. Default false.",
- false,
- false);
-
- PropertyMetadata s4 = stringProperty(
- LOCALITY_GROUPS,
- "List of locality groups to set on the Accumulo table. Only valid on internal tables. String format is locality group name, colon, comma delimited list of Presto column names in the group. Groups are delimited by pipes. Example: group1:colA,colB,colC|group2:colD,colE,colF|etc.... Default is no locality groups.",
- null,
- false);
-
- PropertyMetadata s5 = stringProperty(
- ROW_ID,
- "Presto column name that maps to the Accumulo row ID. Default is the first column.",
- null,
- false);
-
- PropertyMetadata s6 = new PropertyMetadata<>(
- SERIALIZER,
- "Serializer for Accumulo data encodings. Can either be 'default', 'string', 'lexicoder', or a Java class name. Default is 'default', i.e. the value from AccumuloRowSerializer.getDefault(), i.e. 'lexicoder'.",
- VarcharType.VARCHAR, String.class,
- AccumuloRowSerializer.getDefault().getClass().getName(),
- false,
- x -> x.equals("default")
- ? AccumuloRowSerializer.getDefault().getClass().getName()
- : (x.equals("string") ? StringRowSerializer.class.getName()
- : (x.equals("lexicoder")
- ? LexicoderRowSerializer.class.getName()
- : (String) x)),
- object -> object);
-
- PropertyMetadata s7 = stringProperty(
- SCAN_AUTHS,
- "Scan-time authorizations set on the batch scanner. Default is all scan authorizations for the user",
- null,
- false);
-
- tableProperties = ImmutableList.of(s1, s2, s3, s4, s5, s6, s7);
- }
-
- public List> getTableProperties()
- {
- return tableProperties;
- }
-
- /**
- * Gets the value of the column_mapping property, or Optional.empty() if not set.
- *
- * Parses the value into a map of Presto column name to a pair of strings, the Accumulo column family and qualifier.
- *
- * @param tableProperties The map of table properties
- * @return The column mapping, presto name to (accumulo column family, qualifier)
- */
- public static Optional