@Override public void longToRecord(TierState recordState, long record, Record toStore) { toStore.remoteness = (int) (record / 3); switch ((int) (record % 3)) { case 0: toStore.value = Value.LOSE; break; case 1: toStore.value = Value.WIN; break; case 2: toStore.value = Value.TIE; break; } }
@SuppressWarnings("unchecked") @Override public void map(LongWritable positionToMap, LongWritable record, Context context) { try { S pos = game.hashToState(positionToMap.get()); game.longToRecord(pos, record.get(), rec); rec.previousPosition(); int numParents = 0; numParents = ((Undoable<S>) game).possibleParents(pos, parentStates); for (int i = 0; i < numParents; i++) { long parentHash = game.stateToHash(parentStates[i]); RangeFile parentFile = rangeFiles.getFile(parentHash); srp.state = parentHash; srp.record = game.recordToLong(parentStates[i], rec); context.write(parentFile, new StateRecordPair(srp.state, srp.record)); } } catch (IOException e) { throw new Error(e); } catch (InterruptedException e) { e.printStackTrace(); } }