Name: _____________________________ 6 Digit StudentID: ___ ___ ___ ___ ___ ___

Worksheet 10: MapReduce Card Mapper

From the prep: Learn MapReduce with Playing Cards a Mapper emits key-value pairs for only the numeric cards in a deck (the key being the suit and the value being the numeric value).

To be clear, numericValue() for ACE, KING, QUEEN, and JACK will return Optional.empty() and should be omitted.

Given these definitions:

class Deck implements Iterable<Card>

class Card
    public Suit suit();
    public Rank rank();

enum Suit
    SPADES, HEARTS, DIAMONDS, CLUBS

enum Rank
    ACE, KING, QUEEN, JACK, 
    TEN(10), NINE(9), EIGHT(8), SEVEN(7), SIX(6), FIVE(5), FOUR(4), THREE(3), TWO(2);

    Optional<Integer> numericValue()

class Optional<T>
    boolean isPresent()
    boolean isEmpty()
    T get()

Write Pseudocode for CardMapper

public class CardMapper implements Mapper<Deck, Suit, Integer> {
    @Override
    public List<Map.Entry<Suit, Integer>> map(Deck deck) {














    }
}

Post Lecture

Synthesize today's class session

 

 

What is unclear?