Package org.apache.hadoop.io

Examples of org.apache.hadoop.io.IntWritable


  private static Pair<Long[],List<Path>> createDictionaryChunks(Path featureCountPath,
                                                                String dictionaryPathBase,
                                                                int chunkSizeInMegabytes) throws IOException {
    List<Path> chunkPaths = new ArrayList<Path>();
   
    IntWritable key = new IntWritable();
    LongWritable value = new LongWritable();
    Configuration conf = new Configuration();
   
    FileSystem fs = FileSystem.get(featureCountPath.toUri(), conf);
    FileStatus[] outputFiles = fs.globStatus(new Path(featureCountPath.toString()
                                                      + OUTPUT_FILES_PATTERN));
   
    long chunkSizeLimit = chunkSizeInMegabytes * 1024 * 1024;
    int chunkIndex = 0;
    Path chunkPath = getPath(dictionaryPathBase + FREQUENCY_FILE, chunkIndex);
    chunkPaths.add(chunkPath);
    SequenceFile.Writer freqWriter = new SequenceFile.Writer(fs, conf, chunkPath, IntWritable.class,
        LongWritable.class);
   
    long currentChunkSize = 0;
    long featureCount = 0;
    long vectorCount = Long.MAX_VALUE;
    for (FileStatus fileStatus : outputFiles) {
      Path path = fileStatus.getPath();
      SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
      // key is feature value is count
      while (reader.next(key, value)) {
        if (currentChunkSize > chunkSizeLimit) {
          freqWriter.close();
          chunkIndex++;
         
          chunkPath = getPath(dictionaryPathBase + FREQUENCY_FILE, chunkIndex);
          chunkPaths.add(chunkPath);
         
          freqWriter = new SequenceFile.Writer(fs, conf, chunkPath, IntWritable.class, LongWritable.class);
          currentChunkSize = 0;
        }
       
        int fieldSize = SEQUENCEFILE_BYTE_OVERHEAD + Integer.SIZE / 8 + Long.SIZE / 8;
        currentChunkSize += fieldSize;
        if (key.get() >= 0) {
          freqWriter.append(key, value);
        } else if (key.get() == -1) {
          vectorCount = value.get();
        }
        featureCount = Math.max(key.get(), featureCount);
       
      }
    }
    featureCount++;
    freqWriter.close();
View Full Code Here


      sequentialAccess = job.getBoolean(PartialVectorMerger.SEQUENTIAL_ACCESS, false);
     
      Path dictionaryFile = new Path(localFiles[0].getPath());
      FileSystem fs = dictionaryFile.getFileSystem(job);
      SequenceFile.Reader reader = new SequenceFile.Reader(fs, dictionaryFile, job);
      IntWritable key = new IntWritable();
      LongWritable value = new LongWritable();
     
      // key is feature, value is the document frequency
      while (reader.next(key, value)) {
        dictionary.put(key.get(), value.get());
      }
    } catch (IOException e) {
      throw new IllegalStateException(e);
    }
  }
View Full Code Here

     */
    @Override
    public void map(BytesWritable key, Tuple value,
        OutputCollector<Text, IntWritable> output, Reporter reporter)
        throws IOException {
      output.collect(all, new IntWritable((Integer) value.get(0)));
    }
View Full Code Here

        throws IOException {
      int sum = 0;
      while (values.hasNext()) {
        sum += values.next().get();
      }
      output.collect(key, new IntWritable(sum));
    }
View Full Code Here

        throws IOException {
      int sum = 0;
      while (values.hasNext()) {
        sum += values.next().get();
      }
      output.collect(key, new IntWritable(sum));
    }
View Full Code Here

     * @throws IOException
     */
    @Override
    public void map(BytesWritable key, Tuple value, Context context)
    throws IOException, InterruptedException {
      context.write( all, new IntWritable((Integer) value.get(0)) );
    }
View Full Code Here

      int sum = 0;
      Iterator<IntWritable> iterator = values.iterator();
      while (iterator.hasNext()) {
        sum += iterator.next().get();
      }
      context.write(key, new IntWritable(sum));
    }
View Full Code Here

                ae.getMessage());
            responder.doRespond(failedCall);
            throw ae;
          }
          if (!isSecurityEnabled && authMethod != AuthMethod.SIMPLE) {
            doSaslReply(SaslStatus.SUCCESS, new IntWritable(
                HBaseSaslRpcServer.SWITCH_TO_SIMPLE_AUTH), null, null);
            authMethod = AuthMethod.SIMPLE;
            // client has already sent the initial Sasl message and we
            // should ignore it. Both client and server should fall back
            // to simple auth from now on.
View Full Code Here

    System.err.println("fileName: "+tmpFileName);
    Path path = new Path("file:///"+tmpFileName);
    JobConf conf = new JobConf();
    FileSystem fs = FileSystem.get(path.toUri(), conf);
   
    IntWritable key = new IntWritable();
    Text value = new Text();
    SequenceFile.Writer writer = null;
    try {
      writer = SequenceFile.createWriter(fs, conf, path,
                                         key.getClass(), value.getClass());
      for (int i=0; i < DATA.length; i++) {
        key.set(i);
        value.set(DATA[i]);
        writer.append(key, value);
      }
    } finally {
      IOUtils.closeStream(writer);
View Full Code Here

     */
    @Override
    public void map(BytesWritable key, Tuple value,
        OutputCollector<Text, IntWritable> output, Reporter reporter)
        throws IOException {
      output.collect(all, new IntWritable((Integer) value.get(0)));
    }
View Full Code Here

TOP

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

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.