Package com.twitter.elephanttwin.io

Examples of com.twitter.elephanttwin.io.LongPairWritable


          throw new RuntimeException("Index Block end offset is not more than start offset:");
        }
      }
    }
    if (!map.containsKey(columnValue)) {
      map.put(columnValue, new LongPairWritable(outputValue));
    } else {

      LongPairWritable prevPair = map.get(columnValue);

      if (prevPair.getSecond() > outputValue.getFirst() &&
          outputValue.getFirst() < prevPair.getFirst()) {
        throw new RuntimeException("error: overalapping index blocks at offset: " + key);
      }

      /*
       *if we can combine the two blocks, then combine, otherwise send the
       * previously stored index entry to reducer and store the new index entry.
       * Two conditions to be met to combine:
       *  a) "adjacent" to each other;
       *  b) combined size cannot be more than the threshold
      */
      if (prevPair.getSecond() + gapsize < outputValue.getFirst() ||
          outputValue.getSecond() - prevPair.getFirst() > maxBlockSize) {
        context.write(new TextLongPairWritable(new Text(columnValue), prevPair.getFirst()), prevPair);
        if (LOG.isDebugEnabled()) {
          LOG.debug("write to reducer: " + prevPair);
        }

        map.put(columnValue, new LongPairWritable(outputValue));
      } else {
        prevPair.setSecond(outputValue.getSecond());
        map.put(columnValue, prevPair);
      }
    }

    previousRowLineOffset = lineOffset;
View Full Code Here


    if (LOG.isDebugEnabled()) {
      LOG.debug("totalRowsInABlock is:" + totalRowsInABlock + " for the last " +
          "lzoblock ended at"  +  previousRowLineOffset);
    }
    for (Entry<String, LongPairWritable> e : map.entrySet()) {
      LongPairWritable lp = e.getValue();
      context.write(new TextLongPairWritable( new Text(e.getKey()),lp.getFirst()),lp);
    }
    map.clear();
  }
View Full Code Here

TOP

Related Classes of com.twitter.elephanttwin.io.LongPairWritable

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.