Examples of TextFileReader


Examples of org.hsqldb.persist.TextFileReader

            database.persistentStoreCollection.getStore(this);

        this.store = store;

        TextCache      cache  = null;
        TextFileReader reader = null;

        try {
            cache = (TextCache) database.logger.openTextFilePersistence(this,
                    dataSource, withReadOnlyData, isReversed);

            store.setCache(cache);

            reader = cache.getTextFileReader();

            // read and insert all the rows from the source file
            Row row     = null;
            long nextpos = 0;

            if (cache.isIgnoreFirstLine()) {
                nextpos += reader.readHeaderLine();
                cache.setHeaderInitialise(reader.getHeaderLine());
            }

            while (true) {
                RowInputInterface rowIn = reader.readObject(nextpos);

                if (rowIn == null) {
                    break;
                }

                row = (Row) store.get(rowIn);

                if (row == null) {
                    break;
                }

                Object[] data = row.getData();

                nextpos = (int) row.getPos() + row.getStorageSize();

                systemUpdateIdentityValue(data);
                enforceRowConstraints(session, data);
                store.indexRow(session, row);
            }
        } catch (Throwable t) {
            int linenumber = reader == null ? 0
                                            : reader.getLineNumber();

            clearAllData(session);

            if (cache != null) {
                database.logger.closeTextCache(this);
View Full Code Here

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

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

    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

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

  @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

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

  @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

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

  @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

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

  @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

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

    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

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

  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

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

  @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
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.