Skip to content

Commit

Permalink
Turn compaction off at table level
Browse files Browse the repository at this point in the history
  • Loading branch information
nileema committed Sep 23, 2015
1 parent 39215a9 commit 03853ec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public void commitCreateTable(ConnectorSession session, ConnectorOutputTableHand

long newTableId = dbi.inTransaction((dbiHandle, status) -> {
MetadataDao dao = dbiHandle.attach(MetadataDao.class);
long tableId = dao.insertTable(table.getSchemaName(), table.getTableName());
long tableId = dao.insertTable(table.getSchemaName(), table.getTableName(), true);
List<RaptorColumnHandle> sortColumnHandles = table.getSortColumnHandles();

for (int i = 0; i < table.getColumnTypes().size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public interface MetadataDao
" schema_name VARCHAR(255) NOT NULL,\n" +
" table_name VARCHAR(255) NOT NULL,\n" +
" temporal_column_id BIGINT DEFAULT NULL,\n" +
" compaction_enabled BOOLEAN NOT NULL,\n" +
" UNIQUE (schema_name, table_name)\n" +
")")
void createTableTables();
Expand Down Expand Up @@ -138,12 +139,13 @@ List<ViewResult> getViews(
@Bind("schemaName") String schemaName,
@Bind("tableName") String tableName);

@SqlUpdate("INSERT INTO tables (schema_name, table_name)\n" +
"VALUES (:schemaName, :tableName)")
@SqlUpdate("INSERT INTO tables (schema_name, table_name, compaction_enabled)\n" +
"VALUES (:schemaName, :tableName, :compactionEnabled)")
@GetGeneratedKeys
long insertTable(
@Bind("schemaName") String schemaName,
@Bind("tableName") String tableName);
@Bind("tableName") String tableName,
@Bind("compactionEnabled") boolean compactionEnabled);

@SqlUpdate("INSERT INTO columns (table_id, column_id, column_name, ordinal_position, data_type, sort_ordinal_position)\n" +
"VALUES (:tableId, :columnId, :columnName, :ordinalPosition, :dataType, :sortOrdinalPosition)")
Expand Down Expand Up @@ -206,4 +208,7 @@ int dropView(
void updateTemporalColumnId(
@Bind("tableId") long tableId,
@Bind("columnId") long columnId);

@SqlQuery("SELECT compaction_enabled FROM tables WHERE table_id = :tableId")
boolean isCompactionEnabled(@Bind("tableId") long tableId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ private void discoverShards()

for (Entry<Long, List<ShardMetadata>> entry : Multimaps.asMap(tableShards).entrySet()) {
long tableId = entry.getKey();
if (!metadataDao.isCompactionEnabled(tableId)) {
continue;
}
List<ShardMetadata> shardMetadata = entry.getValue();

Set<ShardMetadata> shards = shardMetadata.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void testTemporalColumn()
throws Exception
{
Long columnId = 1L;
long tableId = dao.insertTable("schema1", "table1");
long tableId = dao.insertTable("schema1", "table1", true);
dao.insertColumn(tableId, columnId, "col1", 1, "bigint", null);
Long temporalColumnId = dao.getTemporalColumnId(tableId);
assertNull(temporalColumnId);
Expand All @@ -62,7 +62,7 @@ public void testTemporalColumn()
assertNotNull(temporalColumnId);
assertEquals(temporalColumnId, columnId);

long tableId2 = dao.insertTable("schema1", "table2");
long tableId2 = dao.insertTable("schema1", "table2", true);
Long columnId2 = dao.getTemporalColumnId(tableId2);
assertNull(columnId2);
}
Expand Down

0 comments on commit 03853ec

Please sign in to comment.