Package no.priv.garshol.duke

Examples of no.priv.garshol.duke.RecordIterator


    else
      sources = config.getDataSources(1);

    database = config.getDatabase(true);
    for (DataSource src : sources) {
      RecordIterator it = src.getRecords();
      while (it.hasNext())
        database.index(it.next());
    }
    database.commit();

    // remember second set of records, too
    if (!config.isDeduplicationMode() && active) {
      // in record linkage mode we need to be able to look up records
      // in the second group, so that we can show them to the user
      // when asking questions about them
      secondary = new HashMap();
      for (DataSource src : config.getDataSources(2)) {
        RecordIterator it = src.getRecords();
        while (it.hasNext()) {
          Record r = it.next();
          secondary.put(getid(r), r);
        }
      }
    }
View Full Code Here


    source = new CSVDataSource();
  }

  @Test
  public void testEmpty() throws IOException {
    RecordIterator it = read("");
    assertTrue(!it.hasNext());
  }
View Full Code Here

  public void testSingleRecord() throws IOException {
    source.addColumn(new Column("F1", null, null, null));
    source.addColumn(new Column("F2", null, null, null));
    source.addColumn(new Column("F3", null, null, null));

    RecordIterator it = read("F1,F2,F3\na,b,c");

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
    assertEquals("b", r.getValue("F2"));
    assertEquals("c", r.getValue("F3"));
  }
View Full Code Here

    source.addColumn(new Column("F1", null, null, null));
    source.addColumn(new Column("F2", null, null, null));
    source.addColumn(new Column("F3", null, null, null));
    source.setSkipLines(1);

    RecordIterator it = read("# this is a comment\nF1,F2,F3\na,b,c");

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
    assertEquals("b", r.getValue("F2"));
    assertEquals("c", r.getValue("F3"));
  }
View Full Code Here

    source.addColumn(new Column("1", "F1", null, null));
    source.addColumn(new Column("2", "F2", null, null));
    source.addColumn(new Column("3", "F3", null, null));
    source.setHeaderLine(false);

    RecordIterator it = read("a,b,c");

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
    assertEquals("b", r.getValue("F2"));
    assertEquals("c", r.getValue("F3"));
  }
View Full Code Here

    source.addColumn(new Column("1", "F1", null, null));
    source.addColumn(new Column("2", "F2", null, null));
    source.addColumn(new Column("3", "F3", null, null));
    source.setHeaderLine(false);

    RecordIterator it = read("a,b,c,d");

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
    assertEquals("b", r.getValue("F2"));
    assertEquals("c", r.getValue("F3"));
  }
View Full Code Here

  public void testSingleRecordWithoutHeaderSkipColumn() throws IOException {
    source.addColumn(new Column("1", "F1", null, null));
    source.addColumn(new Column("3", "F3", null, null));
    source.setHeaderLine(false);

    RecordIterator it = read("a,b,c");

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
    assertEquals(null, r.getValue("F2"));
    assertEquals("c", r.getValue("F3"));
  }
View Full Code Here

    source.addColumn(new Column("F2", null, null, null));
    source.addColumn(new Column("F3", null, null, null));
    source.addColumn(new Column("F4", null, null, null));

    try {
      RecordIterator it = read("F1,F2,F3\na,b,c");
      Record r = it.next();
      fail("Didn't catch missing column F4");
    } catch (DukeConfigException e) {
      // caught the configuration mistake
    }
  }
View Full Code Here

    source.addColumn(new Column("F2", null, null, null));
    source.addColumn(new Column("F3", null, null, null));
    source.addColumn(new Column("F4", null, null, null));

    try {
      RecordIterator it = read("F5,F2,F3\na,b,c");
      Record r = it.next();
      fail("Didn't catch unknown column F5");
    } catch (DukeConfigException e) {
      // caught the configuration mistake
    }
  }
View Full Code Here

    Column c = new Column("F2", null, null, null);
    c.setSplitOn(";");
    source.addColumn(c);
    source.addColumn(new Column("F3", null, null, null));

    RecordIterator it = read("F1,F2,F3\na,b;d;e,c");

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
    assertEquals("c", r.getValue("F3"));

    Collection<String> values = r.getValues("F2");
    assertEquals(3, values.size());
View Full Code Here

TOP

Related Classes of no.priv.garshol.duke.RecordIterator

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.