Package org.apache.hama.commons.util

Examples of org.apache.hama.commons.util.KeyValuePair


      convertedKey = (WritableComparable) ReflectionUtils.newInstance(
          convertedKeyClass, conf);
      value = new MapWritable();

      readers.get(i).next(convertedKey, value);
      candidates.put(i, new KeyValuePair(convertedKey, value));
    }

    while (readers.size() > 0) {
      convertedKey = (WritableComparable) ReflectionUtils.newInstance(
          convertedKeyClass, conf);
      value = new MapWritable();

      int readerIndex = 0;
      WritableComparable firstKey = null;
      MapWritable rawRecord = null;

      for (Map.Entry<Integer, KeyValuePair<WritableComparable, MapWritable>> keys : candidates
          .entrySet()) {
        if (firstKey == null) {
          readerIndex = keys.getKey();
          firstKey = keys.getValue().getKey();
          rawRecord = (MapWritable) keys.getValue().getValue();
        } else {
          WritableComparable currentKey = keys.getValue().getKey();
          if (firstKey.compareTo(currentKey) > 0) {
            readerIndex = keys.getKey();
            firstKey = currentKey;
            rawRecord = (MapWritable) keys.getValue().getValue();
          }
        }
      }

      for (Map.Entry<Writable, Writable> e : rawRecord.entrySet()) {
        writer.append(e.getKey(), e.getValue());
      }

      candidates.remove(readerIndex);

      if (readers.get(readerIndex).next(convertedKey, value)) {
        candidates.put(readerIndex, new KeyValuePair(convertedKey, value));
      } else {
        readers.get(readerIndex).close();
        readers.remove(readerIndex);
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.hama.commons.util.KeyValuePair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.