Package org.springframework.data.hadoop.store.input

Examples of org.springframework.data.hadoop.store.input.TextFileReader


  @Test
  public void testWithOneReader() throws Exception {
    Path path = new Path("/syarn-tmp/DataStoreItemReaderTests-testWithOneReader/data.txt");
    createTestData(path);
    DataStoreReader<String> reader = new TextFileReader(configuration, path, null, null, null);
    DataStoreItemReader<String> itemReader = new DataStoreItemReader<String>();
    itemReader.setDataStoreReader(reader);
    itemReader.setLineDataMapper(new PassThroughLineDataMapper());
    int count = 0;
    while (itemReader.read() != null) {
View Full Code Here


    StaticLengthSplitter splitter = new StaticLengthSplitter(getConfiguration(), 1500);
    List<Split> splits = splitter.getSplits(path);
    assertThat(splits.size(), is(2));

    DataStoreReader<String> reader = new TextFileReader(configuration, path, null, splits.get(0), null);
    DataStoreItemReader<String> itemReader = new DataStoreItemReader<String>();
    itemReader.setDataStoreReader(reader);
    itemReader.setLineDataMapper(new PassThroughLineDataMapper());
    int count = 0;
    while (itemReader.read() != null) {
      count++;
    }

    reader = new TextFileReader(configuration, path, null, splits.get(1), null);
    itemReader = new DataStoreItemReader<String>();
    itemReader.setDataStoreReader(reader);
    itemReader.setLineDataMapper(new PassThroughLineDataMapper());
    while (itemReader.read() != null) {
      count++;
View Full Code Here

  @Test
  public void testRestore() throws Exception {
    Path path = new Path("/syarn-tmp/DataStoreItemReaderTests-testRestore/data.txt");
    createTestData(path);
    DataStoreReader<String> reader = new TextFileReader(configuration, path, null, null, null);
    DataStoreItemReader<String> itemReader = new DataStoreItemReader<String>();
    itemReader.setDataStoreReader(reader);
    itemReader.setLineDataMapper(new PassThroughLineDataMapper());

    ExecutionContext context = new ExecutionContext();
View Full Code Here

  @Test
  public void testRestoreToEnd() throws Exception {
    Path path = new Path("/syarn-tmp/DataStoreItemReaderTests-testRestoreToEnd/data.txt");
    createTestData(path);
    DataStoreReader<String> reader = new TextFileReader(configuration, path, null, null, null);
    DataStoreItemReader<String> itemReader = new DataStoreItemReader<String>();
    itemReader.setDataStoreReader(reader);
    itemReader.setLineDataMapper(new PassThroughLineDataMapper());

    ExecutionContext context = new ExecutionContext();
View Full Code Here

  @Test(expected = ItemStreamException.class)
  public void testRestoreFailure() throws Exception {
    Path path = new Path("/syarn-tmp/DataStoreItemReaderTests-testRestoreFailure/data.txt");
    createTestData(path);
    DataStoreReader<String> reader = new TextFileReader(configuration, path, null, null, null);
    DataStoreItemReader<String> itemReader = new DataStoreItemReader<String>();
    itemReader.setDataStoreReader(reader);
    itemReader.setLineDataMapper(new PassThroughLineDataMapper());

    ExecutionContext context = new ExecutionContext();
View Full Code Here

  @Test
  public void testSavePosition() throws Exception {
    Path path = new Path("/syarn-tmp/DataStoreItemReaderTests-testSavePosition/data.txt");
    createTestData(path);
    DataStoreReader<String> reader = new TextFileReader(configuration, path, null, null, null);
    DataStoreItemReader<String> itemReader = new DataStoreItemReader<String>();
    itemReader.setDataStoreReader(reader);
    itemReader.setLineDataMapper(new PassThroughLineDataMapper());
    int count = 0;
    while (itemReader.read() != null) {
View Full Code Here

    TextFileWriter writer = context.getBean("writer", TextFileWriter.class);

    TestUtils.writeData(writer, DATA09ARRAY, false, false);
    writer.flush();

    TextFileReader reader = new TextFileReader(getConfiguration(), writer.getPath(), null);
    TestUtils.readDataAndAssert(reader, DATA09ARRAY);
    writer.close();
    reader.close();
  }
View Full Code Here

  public void testWriteAppendReadTextManyLines() throws IOException {
    TextFileWriter writer = new TextFileWriter(getConfiguration(), testDefaultPath, null);
    writer.setAppendable(true);
    TestUtils.writeData(writer, DATA09ARRAY, false);

    TextFileReader reader = new TextFileReader(getConfiguration(), testDefaultPath, null);
    TestUtils.readDataAndAssert(reader, DATA09ARRAY);
    writer.close();
  }
View Full Code Here

  @Test
  public void testWriteAppendReopen() throws IOException {
    TextFileWriter writer = new TextFileWriter(getConfiguration(), testDefaultPath, null);
    writer.setAppendable(true);
    TestUtils.writeData(writer, DATA09ARRAY, false);
    TextFileReader reader = new TextFileReader(getConfiguration(), testDefaultPath, null);
    TestUtils.readDataAndAssert(reader, DATA09ARRAY);
    writer.close();
    reader.close();

    writer = new TextFileWriter(getConfiguration(), testDefaultPath, null);
    writer.setAppendable(true);
    TestUtils.writeData(writer, DATA09ARRAY, false);
    reader = new TextFileReader(getConfiguration(), testDefaultPath, null);
    TestUtils.readDataAndAssert(reader, StringUtils.concatenateStringArrays(DATA09ARRAY, DATA09ARRAY));
    writer.close();
    reader.close();
  }
View Full Code Here

    writer.setAppendable(true);

    writer.write(dataArray[0], headers);
    writer.flush();

    TextFileReader reader = new TextFileReader(getConfiguration(), new Path(testDefaultPath, "foo/" + nowYYYYMM + "/0_hash/jee_list/10_range/bar"), null);
    TestUtils.readDataAndAssert(reader, dataArray);
    writer.close();
    reader.close();
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.hadoop.store.input.TextFileReader

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.