Search in sources :

Example 11 with InputInitializerContext

use of org.apache.tez.runtime.api.InputInitializerContext in project hive by apache.

the class TestDynamicPartitionPruner method testSingleSourceMultipleFiltersOrdering1.

@Test(timeout = 20000)
public void testSingleSourceMultipleFiltersOrdering1() throws InterruptedException, SerDeException {
    InputInitializerContext mockInitContext = mock(InputInitializerContext.class);
    doReturn(2).when(mockInitContext).getVertexNumTasks("v1");
    MapWork mapWork = createMockMapWork(new TestSource("v1", 2));
    DynamicPartitionPrunerForEventTesting pruner = new DynamicPartitionPrunerForEventTesting();
    pruner.initialize(mockInitContext, mapWork, new JobConf());
    PruneRunnable pruneRunnable = new PruneRunnable(pruner);
    Thread t = new Thread(pruneRunnable);
    t.start();
    try {
        pruneRunnable.start();
        InputInitializerEvent event = InputInitializerEvent.create("FakeTarget", "TargetInput", ByteBuffer.allocate(0));
        event.setSourceVertexName("v1");
        pruner.addEvent(event);
        pruner.addEvent(event);
        pruner.addEvent(event);
        pruner.addEvent(event);
        pruner.processVertex("v1");
        pruneRunnable.awaitEnd();
        assertNoError(pruneRunnable);
        assertEquals(4, pruner.eventsProceessed.intValue());
        assertEquals(2, pruner.filteredSources.intValue());
    } finally {
        t.interrupt();
        t.join();
    }
}
Also used : InputInitializerEvent(org.apache.tez.runtime.api.events.InputInitializerEvent) MapWork(org.apache.hadoop.hive.ql.plan.MapWork) InputInitializerContext(org.apache.tez.runtime.api.InputInitializerContext) JobConf(org.apache.hadoop.mapred.JobConf) Test(org.junit.Test)

Example 12 with InputInitializerContext

use of org.apache.tez.runtime.api.InputInitializerContext in project hive by apache.

the class TestDynamicPartitionPruner method testMultipleSourcesOrdering3.

@Test(timeout = 20000)
public void testMultipleSourcesOrdering3() throws InterruptedException, SerDeException {
    InputInitializerContext mockInitContext = mock(InputInitializerContext.class);
    doReturn(2).when(mockInitContext).getVertexNumTasks("v1");
    doReturn(3).when(mockInitContext).getVertexNumTasks("v2");
    MapWork mapWork = createMockMapWork(new TestSource("v1", 2), new TestSource("v2", 1));
    DynamicPartitionPrunerForEventTesting pruner = new DynamicPartitionPrunerForEventTesting();
    pruner.initialize(mockInitContext, mapWork, new JobConf());
    PruneRunnable pruneRunnable = new PruneRunnable(pruner);
    Thread t = new Thread(pruneRunnable);
    t.start();
    try {
        pruneRunnable.start();
        InputInitializerEvent eventV1 = InputInitializerEvent.create("FakeTarget", "TargetInput", ByteBuffer.allocate(0));
        eventV1.setSourceVertexName("v1");
        InputInitializerEvent eventV2 = InputInitializerEvent.create("FakeTarget", "TargetInput", ByteBuffer.allocate(0));
        eventV2.setSourceVertexName("v2");
        // 2 X 2 events for V1. 3 X 1 events for V2
        pruner.addEvent(eventV1);
        pruner.addEvent(eventV1);
        pruner.processVertex("v1");
        pruner.addEvent(eventV1);
        pruner.addEvent(eventV1);
        pruner.addEvent(eventV2);
        pruner.processVertex("v2");
        pruner.addEvent(eventV2);
        pruner.addEvent(eventV2);
        pruneRunnable.awaitEnd();
        assertNoError(pruneRunnable);
        assertEquals(7, pruner.eventsProceessed.intValue());
        assertEquals(3, pruner.filteredSources.intValue());
    } finally {
        t.interrupt();
        t.join();
    }
}
Also used : InputInitializerEvent(org.apache.tez.runtime.api.events.InputInitializerEvent) MapWork(org.apache.hadoop.hive.ql.plan.MapWork) InputInitializerContext(org.apache.tez.runtime.api.InputInitializerContext) JobConf(org.apache.hadoop.mapred.JobConf) Test(org.junit.Test)

Example 13 with InputInitializerContext

use of org.apache.tez.runtime.api.InputInitializerContext in project hive by apache.

the class TestDynamicPartitionPruner method testExtraEvents.

@Test(timeout = 20000)
public void testExtraEvents() throws InterruptedException, IOException, HiveException, SerDeException {
    InputInitializerContext mockInitContext = mock(InputInitializerContext.class);
    doReturn(1).when(mockInitContext).getVertexNumTasks("v1");
    MapWork mapWork = createMockMapWork(new TestSource("v1", 1));
    DynamicPartitionPrunerForEventTesting pruner = new DynamicPartitionPrunerForEventTesting();
    pruner.initialize(mockInitContext, mapWork, new JobConf());
    PruneRunnable pruneRunnable = new PruneRunnable(pruner);
    Thread t = new Thread(pruneRunnable);
    t.start();
    try {
        pruneRunnable.start();
        InputInitializerEvent event = InputInitializerEvent.create("FakeTarget", "TargetInput", ByteBuffer.allocate(0));
        event.setSourceVertexName("v1");
        pruner.addEvent(event);
        pruner.addEvent(event);
        pruner.processVertex("v1");
        pruneRunnable.awaitEnd();
        assertTrue(pruneRunnable.inError.get());
        assertTrue(pruneRunnable.exception instanceof IllegalStateException);
        assertEquals(2, pruner.eventsProceessed.intValue());
        assertEquals(0, pruner.filteredSources.intValue());
    } finally {
        t.interrupt();
        t.join();
    }
}
Also used : InputInitializerEvent(org.apache.tez.runtime.api.events.InputInitializerEvent) MapWork(org.apache.hadoop.hive.ql.plan.MapWork) InputInitializerContext(org.apache.tez.runtime.api.InputInitializerContext) JobConf(org.apache.hadoop.mapred.JobConf) Test(org.junit.Test)

Example 14 with InputInitializerContext

use of org.apache.tez.runtime.api.InputInitializerContext in project hive by apache.

the class TestDynamicPartitionPruner method testMultipleSourcesOrdering1.

@Test(timeout = 20000)
public void testMultipleSourcesOrdering1() throws InterruptedException, SerDeException {
    InputInitializerContext mockInitContext = mock(InputInitializerContext.class);
    doReturn(2).when(mockInitContext).getVertexNumTasks("v1");
    doReturn(3).when(mockInitContext).getVertexNumTasks("v2");
    MapWork mapWork = createMockMapWork(new TestSource("v1", 2), new TestSource("v2", 1));
    DynamicPartitionPrunerForEventTesting pruner = new DynamicPartitionPrunerForEventTesting();
    pruner.initialize(mockInitContext, mapWork, new JobConf());
    PruneRunnable pruneRunnable = new PruneRunnable(pruner);
    Thread t = new Thread(pruneRunnable);
    t.start();
    try {
        pruneRunnable.start();
        InputInitializerEvent eventV1 = InputInitializerEvent.create("FakeTarget", "TargetInput", ByteBuffer.allocate(0));
        eventV1.setSourceVertexName("v1");
        InputInitializerEvent eventV2 = InputInitializerEvent.create("FakeTarget", "TargetInput", ByteBuffer.allocate(0));
        eventV2.setSourceVertexName("v2");
        // 2 X 2 events for V1. 3 X 1 events for V2
        pruner.addEvent(eventV1);
        pruner.addEvent(eventV1);
        pruner.addEvent(eventV1);
        pruner.addEvent(eventV1);
        pruner.addEvent(eventV2);
        pruner.addEvent(eventV2);
        pruner.addEvent(eventV2);
        pruner.processVertex("v1");
        pruner.processVertex("v2");
        pruneRunnable.awaitEnd();
        assertNoError(pruneRunnable);
        assertEquals(7, pruner.eventsProceessed.intValue());
        assertEquals(3, pruner.filteredSources.intValue());
    } finally {
        t.interrupt();
        t.join();
    }
}
Also used : InputInitializerEvent(org.apache.tez.runtime.api.events.InputInitializerEvent) MapWork(org.apache.hadoop.hive.ql.plan.MapWork) InputInitializerContext(org.apache.tez.runtime.api.InputInitializerContext) JobConf(org.apache.hadoop.mapred.JobConf) Test(org.junit.Test)

Example 15 with InputInitializerContext

use of org.apache.tez.runtime.api.InputInitializerContext in project hive by apache.

the class TestDynamicPartitionPruner method testNoPruning.

@Test(timeout = 20000)
public void testNoPruning() throws InterruptedException, IOException, HiveException, SerDeException {
    InputInitializerContext mockInitContext = mock(InputInitializerContext.class);
    MapWork mapWork = mock(MapWork.class);
    DynamicPartitionPrunerForEventTesting pruner = new DynamicPartitionPrunerForEventTesting();
    pruner.initialize(mockInitContext, mapWork, new JobConf());
    PruneRunnable pruneRunnable = new PruneRunnable(pruner);
    Thread t = new Thread(pruneRunnable);
    t.start();
    try {
        pruneRunnable.start();
        pruneRunnable.awaitEnd();
        // Return immediately. No entries found for pruning. Verified via the timeout.
        assertEquals(0, pruner.eventsProceessed.intValue());
        assertEquals(0, pruner.filteredSources.intValue());
    } finally {
        t.interrupt();
        t.join();
    }
}
Also used : MapWork(org.apache.hadoop.hive.ql.plan.MapWork) InputInitializerContext(org.apache.tez.runtime.api.InputInitializerContext) JobConf(org.apache.hadoop.mapred.JobConf) Test(org.junit.Test)

Aggregations

InputInitializerContext (org.apache.tez.runtime.api.InputInitializerContext)17 Test (org.junit.Test)14 MapWork (org.apache.hadoop.hive.ql.plan.MapWork)11 InputInitializerEvent (org.apache.tez.runtime.api.events.InputInitializerEvent)11 JobConf (org.apache.hadoop.mapred.JobConf)10 ByteString (com.google.protobuf.ByteString)3 List (java.util.List)3 Configuration (org.apache.hadoop.conf.Configuration)3 InputSplit (org.apache.hadoop.mapred.InputSplit)3 InputDescriptor (org.apache.tez.dag.api.InputDescriptor)3 InputInitializerDescriptor (org.apache.tez.dag.api.InputInitializerDescriptor)3 UserPayload (org.apache.tez.dag.api.UserPayload)3 InputInitializer (org.apache.tez.runtime.api.InputInitializer)3 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 RootInputLeafOutput (org.apache.tez.dag.api.RootInputLeafOutput)2 AppContext (org.apache.tez.dag.app.AppContext)2 TezDAGID (org.apache.tez.dag.records.TezDAGID)2 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)2 TezTaskID (org.apache.tez.dag.records.TezTaskID)2 TezVertexID (org.apache.tez.dag.records.TezVertexID)2