Package org.apache.hadoop.io

Examples of org.apache.hadoop.io.UTF8


        out.close();
      }
      // rename to final location
      fs.rename(tempFile, new Path(DATA_DIR, name));

      collector.collect(new UTF8("bytes"), new LongWritable(written));

      reporter.setStatus("wrote " + name);
    }
View Full Code Here


        }
      } finally {
        in.close();
      }

      collector.collect(new UTF8("bytes"), new LongWritable(read));

      reporter.setStatus("read " + name);
    }
View Full Code Here

    long totalSize = 0;
    long maxSize = ((megaBytes / numFiles) * 2) + 1;
    try {
      while (totalSize < megaBytes) {
        UTF8 name = new UTF8(Long.toString(random.nextLong()));

        long size = random.nextLong();
        if (size < 0)
          size = -size;
        size = size % maxSize;
View Full Code Here

    assertTrue(Arrays.equals(stringResults, new String[]{"foo","bar"}));

    stringResults = proxy.echo((String[])null);
    assertTrue(Arrays.equals(stringResults, null));

    UTF8 utf8Result = (UTF8)proxy.echo(new UTF8("hello world"));
    assertEquals(utf8Result, new UTF8("hello world"));

    utf8Result = (UTF8)proxy.echo((UTF8)null);
    assertEquals(utf8Result, null);

    int intResult = proxy.add(1, 2);
View Full Code Here

          throw new AssertionFailedError("Log file does not exist: "+logFile);
        }
   
      // create a directory
      try {
        assertTrue(dfsClient.mkdirs( new UTF8( "/data") ));
        assertMkdirs( "/data", false );
      } catch ( IOException ioe ) {
        ioe.printStackTrace();
      }
      
      try {
        assertTrue(dfsClient.mkdirs( new UTF8( "data") ));
        assertMkdirs( "data", true );
      } catch ( IOException ioe ) {
         ioe.printStackTrace();
      }
     
      //
      // create a file with 1 data block
      try {
        createFile("/data/xx", 1);
        assertCreate( "/data/xx", 1, false );
      } catch( IOException ioe ) {
      assertCreate( "/data/xx", 1, true );
      }
   
      // create a file with 2 data blocks
      try {
        createFile("/data/yy", BLOCK_SIZE+1);
        assertCreate( "/data/yy", BLOCK_SIZE+1, false );
      } catch( IOException ioe ) {
      assertCreate( "/data/yy", BLOCK_SIZE+1, true );
      }

      // create an existing file
      try {
        createFile("/data/xx", 2);
        assertCreate( "/data/xx", 2, false );
      } catch( IOException ioe ) {
        assertCreate( "/data/xx", 2, true );
      }
   
      // delete the file
      try {
        dfsClient.delete( new UTF8("/data/yy") );
        assertDelete("/data/yy", false);
      } catch( IOException ioe ) {
        ioe.printStackTrace();
      }

   
      // rename the file
      try {
        dfsClient.rename( new UTF8("/data/xx"), new UTF8("/data/yy") );
        assertRename( "/data/xx", "/data/yy", false );
      } catch( IOException ioe ) {
        ioe.printStackTrace();
      }

      try {
        dfsClient.delete(new UTF8("/data/xx"));
        assertDelete("/data/xx", true);
      } catch(IOException ioe) {
      ioe.printStackTrace();
      }
     
      try {
        dfsClient.rename( new UTF8("/data/xx"), new UTF8("/data/yy") );   
        assertRename( "/data/xx", "/data/yy", true );
      } catch( IOException ioe) {
      ioe.printStackTrace();
      }
       
View Full Code Here

  private void createFile( String filename, long fileSize ) throws IOException {
    //
    //           write filesize of data to file
    //
    byte[] buffer = new byte[BUFFER_SIZE];
    UTF8 testFileName = new UTF8(filename); // hardcode filename
    OutputStream nos;
  nos = dfsClient.create(testFileName, false);
    try {
      for (long nBytesWritten = 0L;
                nBytesWritten < fileSize;
View Full Code Here

        //
        //           write nBytes of data using randomDataGenerator to numFiles
        //
        ArrayList testfilesList = new ArrayList();
        byte[] buffer = new byte[bufferSize];
        UTF8 testFileName = null;
        for (int iFileNumber = 0; iFileNumber < numFiles; iFileNumber++) {
          testFileName = new UTF8("/f" + iFileNumber);
          testfilesList.add(testFileName);
          OutputStream nos = dfsClient.create(testFileName, false);
          try {
            for (long nBytesWritten = 0L;
                 nBytesWritten < nBytes;
View Full Code Here

    assertTrue(Arrays.equals(stringResults, new String[]{"foo","bar"}));

    stringResults = proxy.echo((String[])null);
    assertTrue(Arrays.equals(stringResults, null));

    UTF8 utf8Result = (UTF8)proxy.echo(new UTF8("hello world"));
    assertEquals(utf8Result, new UTF8("hello world"));

    utf8Result = (UTF8)proxy.echo((UTF8)null);
    assertEquals(utf8Result, null);

    int intResult = proxy.add(1, 2);
View Full Code Here

  public static class Map extends MapReduceBase implements Mapper {
    public void map(WritableComparable key, Writable value,
        OutputCollector output, Reporter reporter) throws IOException
    {
      String line = value.toString();
      output.collect(new UTF8(process(line)), new UTF8(""));   
    }
View Full Code Here

  public static class Reduce extends MapReduceBase implements Reducer {
    public void reduce(WritableComparable key, Iterator values,
        OutputCollector output, Reporter reporter) throws IOException
    {
      while(values.hasNext()) {
        output.collect(key, new UTF8(values.next().toString()));
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.io.UTF8

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.