use of com.facebook.presto.accumulo.metadata.AccumuloTable in project presto by prestodb.
the class AccumuloClient method createTable.
public AccumuloTable createTable(ConnectorTableMetadata meta) {
// Validate the DDL is something we can handle
validateCreateTable(meta);
Map<String, Object> tableProperties = meta.getProperties();
String rowIdColumn = getRowIdColumn(meta);
// Get the list of column handles
List<AccumuloColumnHandle> columns = getColumnHandles(meta, rowIdColumn);
// Create the AccumuloTable object
AccumuloTable table = new AccumuloTable(meta.getTable().getSchemaName(), meta.getTable().getTableName(), columns, rowIdColumn, AccumuloTableProperties.isExternal(tableProperties), AccumuloTableProperties.getSerializerClass(tableProperties), AccumuloTableProperties.getScanAuthorizations(tableProperties));
// First, create the metadata
metaManager.createTableMetadata(table);
// Make sure the namespace exists
tableManager.ensureNamespace(table.getSchema());
// Create the Accumulo table if it does not exist (for 'external' table)
if (!tableManager.exists(table.getFullTableName())) {
tableManager.createAccumuloTable(table.getFullTableName());
}
// Set any locality groups on the data table
setLocalityGroups(tableProperties, table);
// Create index tables, if appropriate
createIndexTables(table);
return table;
}
use of com.facebook.presto.accumulo.metadata.AccumuloTable in project presto by prestodb.
the class AccumuloMetadata method beginCreateTable.
@Override
public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorNewTableLayout> layout) {
checkNoRollback();
SchemaTableName tableName = tableMetadata.getTable();
AccumuloTable table = client.createTable(tableMetadata);
AccumuloTableHandle handle = new AccumuloTableHandle(connectorId, tableName.getSchemaName(), tableName.getTableName(), table.getRowId(), table.isExternal(), table.getSerializerClassName(), table.getScanAuthorizations());
setRollback(() -> rollbackCreateTable(table));
return handle;
}
use of com.facebook.presto.accumulo.metadata.AccumuloTable in project presto by prestodb.
the class AccumuloClient method getScanAuthorizations.
/**
* Gets the scan authorizations to use for scanning tables.
* <p>
* 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<String> 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;
}
use of com.facebook.presto.accumulo.metadata.AccumuloTable in project presto by prestodb.
the class TestAccumuloClient method testCreateTableEmptyAccumuloColumn.
@Test
public void testCreateTableEmptyAccumuloColumn() {
SchemaTableName tableName = new SchemaTableName("default", "test_create_table_empty_accumulo_column");
try {
List<ColumnMetadata> columns = ImmutableList.of(new ColumnMetadata("id", BIGINT), new ColumnMetadata("a", BIGINT), new ColumnMetadata("b", BIGINT), new ColumnMetadata("c", BIGINT), new ColumnMetadata("d", BIGINT));
Map<String, Object> properties = new HashMap<>();
new AccumuloTableProperties().getTableProperties().forEach(meta -> properties.put(meta.getName(), meta.getDefaultValue()));
properties.put("external", true);
properties.put("column_mapping", "a:a:a,b::b,c:c:,d::");
client.createTable(new ConnectorTableMetadata(tableName, columns, properties));
assertNotNull(client.getTable(tableName));
} finally {
AccumuloTable table = zooKeeperMetadataManager.getTable(tableName);
if (table != null) {
client.dropTable(table);
}
}
}
use of com.facebook.presto.accumulo.metadata.AccumuloTable in project presto by prestodb.
the class TestIndexer method setupClass.
@BeforeClass
public void setupClass() {
AccumuloColumnHandle c1 = new AccumuloColumnHandle("id", Optional.empty(), Optional.empty(), VARCHAR, 0, "", false);
AccumuloColumnHandle c2 = new AccumuloColumnHandle("age", Optional.of("cf"), Optional.of("age"), BIGINT, 1, "", true);
AccumuloColumnHandle c3 = new AccumuloColumnHandle("firstname", Optional.of("cf"), Optional.of("firstname"), VARCHAR, 2, "", true);
AccumuloColumnHandle c4 = new AccumuloColumnHandle("arr", Optional.of("cf"), Optional.of("arr"), new ArrayType(VARCHAR), 3, "", true);
table = new AccumuloTable("default", "index_test_table", ImmutableList.of(c1, c2, c3, c4), "id", true, LexicoderRowSerializer.class.getCanonicalName(), null);
m1 = new Mutation(M1_ROWID);
m1.put(CF, AGE, AGE_VALUE);
m1.put(CF, FIRSTNAME, M1_FNAME_VALUE);
m1.put(CF, SENDERS, M1_ARR_VALUE);
m2 = new Mutation(M2_ROWID);
m2.put(CF, AGE, AGE_VALUE);
m2.put(CF, FIRSTNAME, M2_FNAME_VALUE);
m2.put(CF, SENDERS, M2_ARR_VALUE);
ColumnVisibility visibility1 = new ColumnVisibility("private");
ColumnVisibility visibility2 = new ColumnVisibility("moreprivate");
m1v = new Mutation(M1_ROWID);
m1v.put(CF, AGE, visibility1, AGE_VALUE);
m1v.put(CF, FIRSTNAME, visibility1, M1_FNAME_VALUE);
m1v.put(CF, SENDERS, visibility2, M1_ARR_VALUE);
m2v = new Mutation(M2_ROWID);
m2v.put(CF, AGE, visibility1, AGE_VALUE);
m2v.put(CF, FIRSTNAME, visibility2, M2_FNAME_VALUE);
m2v.put(CF, SENDERS, visibility2, M2_ARR_VALUE);
}
Aggregations