Search in sources :

Example 6 with HadoopMultimap

use of org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopMultimap in project ignite by apache.

the class HadoopShuffleJob method collectUpdatesAndSend.

/**
 * Send updates to concrete remote reducer.
 *
 * @param rmtMapIdx Remote map index.
 * @param flush Flush flag.
 * @throws IgniteCheckedException If failed.
 */
private void collectUpdatesAndSend(int rmtMapIdx, boolean flush) throws IgniteCheckedException {
    final int rmtRdcIdx = stripeMappers ? rmtMapIdx % totalReducerCnt : rmtMapIdx;
    HadoopMultimap map = rmtMaps.get(rmtMapIdx);
    if (map == null)
        return;
    if (msgs[rmtMapIdx] == null)
        msgs[rmtMapIdx] = new HadoopShuffleMessage(job.id(), rmtRdcIdx, msgSize);
    visit(map, rmtMapIdx, rmtRdcIdx);
    if (flush && msgs[rmtMapIdx].offset() != 0)
        send(rmtMapIdx, rmtRdcIdx, 0);
}
Also used : HadoopMultimap(org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopMultimap)

Example 7 with HadoopMultimap

use of org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopMultimap in project ignite by apache.

the class HadoopShuffleJob method onDirectShuffleMessage.

/**
 * Process shuffle message.
 *
 * @param src Source.
 * @param msg Message.
 * @throws IgniteCheckedException Exception.
 */
public void onDirectShuffleMessage(T src, HadoopDirectShuffleMessage msg) throws IgniteCheckedException {
    byte[] buf = extractBuffer(msg);
    assert buf != null;
    int rdc = msg.reducer();
    HadoopTaskContext taskCtx = locReducersCtx.get(rdc).get();
    HadoopPerformanceCounter perfCntr = HadoopPerformanceCounter.getCounter(taskCtx.counters(), null);
    perfCntr.onShuffleMessage(rdc, U.currentTimeMillis());
    HadoopMultimap map = getOrCreateMap(locMaps, rdc);
    HadoopSerialization keySer = taskCtx.keySerialization();
    HadoopSerialization valSer = taskCtx.valueSerialization();
    // Add data from message to the map.
    try (HadoopMultimap.Adder adder = map.startAdding(taskCtx)) {
        HadoopDirectDataInput in = new HadoopDirectDataInput(buf);
        Object key = null;
        Object val = null;
        for (int i = 0; i < msg.count(); i++) {
            key = keySer.read(in, key);
            val = valSer.read(in, val);
            adder.write(key, val);
        }
    }
    if (localShuffleState(src).onShuffleMessage())
        sendFinishResponse(src, msg.jobId());
}
Also used : HadoopDirectDataInput(org.apache.ignite.internal.processors.hadoop.shuffle.direct.HadoopDirectDataInput) HadoopMultimap(org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopMultimap) HadoopTaskContext(org.apache.ignite.internal.processors.hadoop.HadoopTaskContext) HadoopPerformanceCounter(org.apache.ignite.internal.processors.hadoop.counter.HadoopPerformanceCounter) HadoopSerialization(org.apache.ignite.internal.processors.hadoop.HadoopSerialization)

Aggregations

HadoopMultimap (org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopMultimap)7 HadoopTaskContext (org.apache.ignite.internal.processors.hadoop.HadoopTaskContext)4 IntWritable (org.apache.hadoop.io.IntWritable)3 HadoopTaskInput (org.apache.ignite.internal.processors.hadoop.HadoopTaskInput)3 IOException (java.io.IOException)2 Collection (java.util.Collection)2 Random (java.util.Random)2 HadoopJobInfo (org.apache.ignite.internal.processors.hadoop.HadoopJobInfo)2 HadoopPerformanceCounter (org.apache.ignite.internal.processors.hadoop.counter.HadoopPerformanceCounter)2 HadoopSkipList (org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopSkipList)2 GridRandom (org.apache.ignite.internal.util.GridRandom)2 GridUnsafeDataInput (org.apache.ignite.internal.util.io.GridUnsafeDataInput)2 GridUnsafeMemory (org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory)2 LinkedList (java.util.LinkedList)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 Writable (org.apache.hadoop.io.Writable)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 HadoopSerialization (org.apache.ignite.internal.processors.hadoop.HadoopSerialization)1 HadoopDirectDataInput (org.apache.ignite.internal.processors.hadoop.shuffle.direct.HadoopDirectDataInput)1