Examples of PairOfIntString


Examples of edu.umd.cloud9.io.pair.PairOfIntString

public class PairOfIntStringTest {

  @Test
  public void testBasic() throws IOException {
    PairOfIntString pair = new PairOfIntString(1, "2");

    assertEquals(1, pair.getLeftElement());
    assertEquals("2", pair.getRightElement());
  }
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntString

    assertEquals("2", pair.getRightElement());
  }

  @Test
  public void testSerialize() throws IOException {
    PairOfIntString origPair = new PairOfIntString(1, "2");

    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
    DataOutputStream dataOut = new DataOutputStream(bytesOut);

    origPair.write(dataOut);

    PairOfIntString pair = new PairOfIntString();

    pair.readFields(new DataInputStream(new ByteArrayInputStream(bytesOut.toByteArray())));

    assertEquals(1, pair.getLeftElement());
    assertEquals("2", pair.getRightElement());
  }
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntString

    assertEquals("2", pair.getRightElement());
  }

  @Test
  public void testComparison1() throws IOException {
    PairOfIntString pair1 = new PairOfIntString(1, "2");
    PairOfIntString pair2 = new PairOfIntString(1, "2");
    PairOfIntString pair3 = new PairOfIntString(1, "1");
    PairOfIntString pair4 = new PairOfIntString(0, "9");
    PairOfIntString pair5 = new PairOfIntString(9, "0");

    assertTrue(pair1.equals(pair2));
    assertFalse(pair1.equals(pair3));

    assertTrue(pair1.compareTo(pair2) == 0);
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntString

  @Test
  public void testComparison2() throws IOException {
    WritableComparator comparator = new PairOfIntString.Comparator();

    PairOfIntString pair1 = new PairOfIntString(1, "2");
    PairOfIntString pair2 = new PairOfIntString(1, "2");
    PairOfIntString pair3 = new PairOfIntString(1, "1");
    PairOfIntString pair4 = new PairOfIntString(0, "9");
    PairOfIntString pair5 = new PairOfIntString(9, "0");

    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair2) == 0);
    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair3) > 0);
    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair4) > 0);
    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair5) < 0);
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntString

  public static int exportTerms(SequenceFile.Reader sequenceFileReader,
      SequenceFile.Writer sequenceFileWriter) throws IOException {
    TreeSet<PairOfIntString> treeMap = new TreeSet<PairOfIntString>(new Comparator() {
      @Override
      public int compare(Object obj1, Object obj2) {
        PairOfIntString entry1 = (PairOfIntString) obj1;
        PairOfIntString entry2 = (PairOfIntString) obj2;
        if (entry1.getLeftElement() > entry2.getLeftElement()) {
          return -1;
        } else if (entry1.getLeftElement() < entry2.getLeftElement()) {
          return entry1.getRightElement().compareTo(entry2.getRightElement());
        } else {
          return 0;
        }
      }
    });

    Text text = new Text();
    PairOfInts pairOfInts = new PairOfInts();
    while (sequenceFileReader.next(text, pairOfInts)) {
      treeMap.add(new PairOfIntString(pairOfInts.getLeftElement(), text.toString()));
    }

    int index = 0;
    IntWritable intWritable = new IntWritable();
    Iterator<PairOfIntString> itr = treeMap.iterator();
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntString

    public void configure(JobConf job) {
      sLogger.setLevel(Level.INFO);
      srcLang = job.get("fLang");     
      mJob = job;
      pwsimMapping = new HMapIV<ArrayListOfIntsWritable>();
      valOut = new PairOfIntString();
      keyOut = new PairOfInts();

      // read doc ids of sample into vectors
      String samplesFile = job.get("Ivory.SampleFile");
      if (samplesFile != null) {
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntString

      fTitle.clear();
      sLogger.info(docnoPair);

      int cnt = 0;
      while (titles.hasNext()) {
        PairOfIntString title = titles.next();
        sLogger.info(title);
        if (title.getLeftElement() == CLIRUtils.E) {
          eTitle.set(title.getRightElement());
          cnt++;
        } else if (title.getLeftElement() == CLIRUtils.F) {
          fTitle.set(title.getRightElement());
          cnt++;
        } else {
          throw new RuntimeException("Unknown language ID: " + title.getLeftElement());
        }
      }

      if (cnt == 2) {
        output.collect(fTitle, eTitle);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.