Search in sources :

Example 1 with Layout

use of alluxio.table.common.Layout in project alluxio by Alluxio.

the class TransformManagerTest method checkLayout.

/**
 * Checks that the layouts of table partitions are the transformed layouts in info.
 *
 * @param info the job information
 * @param table the table
 */
private void checkLayout(TransformJobInfo info, String table) throws IOException {
    for (Map.Entry<String, Layout> specLayouts : info.getTransformedLayouts().entrySet()) {
        String spec = specLayouts.getKey();
        Layout layout = specLayouts.getValue();
        Partition partition = mTableMaster.getTable(DB, table).getPartition(spec);
        assertTrue(partition.isTransformed(info.getDefinition()));
        assertEquals(layout, partition.getLayout());
    }
}
Also used : Partition(alluxio.master.table.Partition) Layout(alluxio.table.common.Layout) Map(java.util.Map)

Example 2 with Layout

use of alluxio.table.common.Layout in project alluxio by Alluxio.

the class HiveLayoutTest method factoryConversions.

@Test
public void factoryConversions() throws Exception {
    HiveLayout layout = createRandom();
    alluxio.grpc.table.Layout layoutProto = layout.toProto();
    Layout layout2 = new HiveLayout.HiveLayoutFactory().create(layoutProto);
    alluxio.grpc.table.Layout layout2Proto = layout2.toProto();
    assertEquals(layoutProto, layout2Proto);
}
Also used : Layout(alluxio.table.common.Layout) Test(org.junit.Test)

Example 3 with Layout

use of alluxio.table.common.Layout in project alluxio by Alluxio.

the class AlluxioCatalog method completeTransformTable.

/**
 * Completes table transformation by updating the layouts of the table's partitions.
 *
 * @param journalContext the journal context
 * @param dbName the database name
 * @param tableName the table name
 * @param definition the transformation definition
 * @param transformedLayouts map from partition spec to the transformed layouts
 */
public void completeTransformTable(JournalContext journalContext, String dbName, String tableName, String definition, Map<String, Layout> transformedLayouts) throws IOException {
    try (LockResource l = getDbLock(dbName)) {
        // Check existence of table.
        getTableInternal(dbName, tableName);
        alluxio.proto.journal.Table.CompleteTransformTableEntry entry = alluxio.proto.journal.Table.CompleteTransformTableEntry.newBuilder().setDbName(dbName).setTableName(tableName).setDefinition(definition).putAllTransformedLayouts(Maps.transformValues(transformedLayouts, Layout::toProto)).build();
        applyAndJournal(journalContext, Journal.JournalEntry.newBuilder().setCompleteTransformTable(entry).build());
    }
}
Also used : LockResource(alluxio.resource.LockResource) Layout(alluxio.table.common.Layout)

Example 4 with Layout

use of alluxio.table.common.Layout in project alluxio by Alluxio.

the class HiveLayoutTest method registryCreate.

@Test
public void registryCreate() throws Exception {
    HiveLayout layout = createRandom();
    assertNotNull(new HiveLayout.HiveLayoutFactory().create(layout.toProto()));
    LayoutRegistry registry = new LayoutRegistry();
    registry.refresh();
    Layout instance = registry.create(layout.toProto());
    assertNotNull(instance);
    assertEquals(layout.toProto(), instance.toProto());
}
Also used : LayoutRegistry(alluxio.table.common.LayoutRegistry) Layout(alluxio.table.common.Layout) Test(org.junit.Test)

Example 5 with Layout

use of alluxio.table.common.Layout in project alluxio by Alluxio.

the class TransformPlan method computeJobConfigs.

private ArrayList<JobConfig> computeJobConfigs(TransformDefinition definition) {
    ArrayList<JobConfig> actions = new ArrayList<>();
    Layout baseLayout = mBaseLayout;
    boolean deleteSrc = false;
    for (TransformAction action : definition.getActions()) {
        actions.add(action.generateJobConfig(baseLayout, mTransformedLayout, deleteSrc));
        baseLayout = mTransformedLayout;
        deleteSrc = true;
    }
    if (actions.isEmpty()) {
        throw new IllegalArgumentException("At least one action should be defined for the transformation");
    }
    return actions;
}
Also used : Layout(alluxio.table.common.Layout) ArrayList(java.util.ArrayList) TransformAction(alluxio.table.common.transform.action.TransformAction) JobConfig(alluxio.job.JobConfig)

Aggregations

Layout (alluxio.table.common.Layout)8 Test (org.junit.Test)3 JobConfig (alluxio.job.JobConfig)2 TransformPlan (alluxio.table.common.transform.TransformPlan)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Pair (alluxio.collections.Pair)1 CompositeConfig (alluxio.job.workflow.composite.CompositeConfig)1 JournalContext (alluxio.master.journal.JournalContext)1 Partition (alluxio.master.table.Partition)1 AddTransformJobInfoEntry (alluxio.proto.journal.Table.AddTransformJobInfoEntry)1 LockResource (alluxio.resource.LockResource)1 LayoutRegistry (alluxio.table.common.LayoutRegistry)1 HiveLayout (alluxio.table.common.layout.HiveLayout)1 TransformAction (alluxio.table.common.transform.action.TransformAction)1 UdbTable (alluxio.table.common.udb.UdbTable)1 HashMap (java.util.HashMap)1