Package eu.stratosphere.core.io

Examples of eu.stratosphere.core.io.StringRecord


    Whitebox.setInternalState(writer, "input", this.recordReader);
    when(this.environment.getTaskConfiguration()).thenReturn(this.conf);

    when(this.conf.getString("outputPath", null)).thenReturn(this.file.toURI().toString());
    when(this.recordReader.hasNext()).thenReturn(true, true, true, false);
    StringRecord in = new StringRecord("abc");
    try {
      when(this.recordReader.next()).thenReturn(in);
    } catch (IOException e) {
      fail();
      e.printStackTrace();
    } catch (InterruptedException e) {
      fail();
      e.printStackTrace();
    }
    writer.invoke();

    final FileInputSplit split = new FileInputSplit(0, new Path(this.file.toURI().toString()), 0,
      this.file.length(), null);
    when(this.environment.getInputSplitProvider()).thenReturn(this.inputSplitProvider);
    when(this.inputSplitProvider.getNextInputSplit()).thenReturn(split, (FileInputSplit) null);

    FileLineReader reader = new FileLineReader();
    Whitebox.setInternalState(reader, "environment", this.environment);
    Whitebox.setInternalState(reader, "output", this.recordWriter);
    StringRecord record = mock(StringRecord.class);

    whenNew(StringRecord.class).withNoArguments().thenReturn(record);

    reader.invoke();
View Full Code Here


    this.output1.initializeSerializers();
    this.output2.initializeSerializers();

    while (this.input.hasNext()) {

      StringRecord s = input.next();
      this.output1.emit(s);
      this.output2.emit(s);
    }

    this.output1.flush();
View Full Code Here

   * Tests the serialization/deserialization of the {@link StringRecord} class.
   */
  @Test
  public void testStringRecord() {

    final StringRecord orig = new StringRecord("Test Record");

    try {

      final StringRecord copy = (StringRecord) CommonTestUtils.createCopy(orig);
     
      assertEquals(orig.getLength(), copy.getLength());
      assertEquals(orig.toString(), copy.toString());
      assertEquals(orig, copy);
      assertEquals(orig.hashCode(), copy.hashCode());

    } catch (IOException ioe) {
      fail(ioe.getMessage());
    }
  }
View Full Code Here

      byte[] line = lineReader.readLine();

      while (line != null) {

        // Create a string object from the data read
        StringRecord str = new StringRecord();
        str.set(line);

        // Send out string
        output.emit(str);

        line = lineReader.readLine();
View Full Code Here

    final FSDataOutputStream outputStream = fs.create(outputPath, true);

    while (this.input.hasNext()) {

      StringRecord record = this.input.next();
      byte[] recordByte = (record.toString() + "\r\n").getBytes();
      outputStream.write(recordByte, 0, recordByte.length);
    }

    outputStream.close();
View Full Code Here

   * This test checks the channel selection
   */
  @Test
  public void channelSelect() {

    final StringRecord dummyRecord = new StringRecord("abc");
    final RoundRobinChannelSelector<StringRecord> selector = new RoundRobinChannelSelector<StringRecord>();
    // Test with two channels
    final int numberOfOutputChannels = 2;
    int[] selectedChannels = selector.selectChannels(dummyRecord, numberOfOutputChannels);
    assertEquals(1, selectedChannels.length);
View Full Code Here

    this.output.initializeSerializers();

    while (this.input.hasNext()) {

      StringRecord s = input.next();
      this.output.emit(s);
    }

    this.output.flush();
  }
View Full Code Here

      byte[] line = lineReader.readLine();

      while (line != null) {

        // Create a string object from the data read
        StringRecord str = new StringRecord();
        str.set(line);

        // Send out string
        output1.emit(str);
        output2.emit(str);
View Full Code Here

    this.output.initializeSerializers();

    while (this.input1.hasNext()) {

      StringRecord s = input1.next();
      this.output.emit(s);
    }

    while (this.input2.hasNext()) {

      StringRecord s = input2.next();
      this.output.emit(s);
    }

    this.output.flush();
View Full Code Here

  public void invoke() throws Exception {
    this.output.initializeSerializers();

    while (this.input1.hasNext()) {

      StringRecord s = input1.next();
      this.output.emit(s);
    }

    while (this.input2.hasNext()) {

      try {
        StringRecord s = input2.next();
        this.output.emit(s);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
View Full Code Here

TOP

Related Classes of eu.stratosphere.core.io.StringRecord

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.