Example usage for org.apache.hadoop.io Text writeString

List of usage examples for org.apache.hadoop.io Text writeString

Introduction

In this page you can find the example usage for org.apache.hadoop.io Text writeString.

Prototype

public static int writeString(DataOutput out, String s) throws IOException 

Source Link

Document

Write a UTF8 encoded string to out

Usage

From source file:org.apache.tez.common.TezTaskContext.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    taskAttemptId.write(out);/*  www . j  av  a2  s . co m*/
    Text.writeString(out, user);
    Text.writeString(out, jobName);
    Text.writeString(out, vertexName);
}

From source file:org.apache.tez.dag.api.EntityDescriptor.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    Text.writeString(out, className);
    // TODO: TEZ-305 - using protobuf serde instead of Writable serde.
    ByteBuffer bb = DagTypeConverters.convertFromTezUserPayload(userPayload);
    if (bb == null) {
        out.writeInt(-1);//from   w  ww.jav a  2s . c  o m
    } else {
        int size = bb.limit() - bb.position();
        if (size == 0) {
            out.writeInt(-1);
        } else {
            out.writeInt(size);
            byte[] bytes = new byte[size];
            // This modified the ByteBuffer, and primarily works since UserPayload.getByteBuffer
            // return a new copy each time
            bb.get(bytes);
            // TODO: TEZ-305 - should be more efficient by using protobuf serde.
            out.write(bytes);
        }
        out.writeInt(userPayload.getVersion());
    }
}

From source file:org.apache.tez.dag.api.TezEntityDescriptor.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    Text.writeString(out, className);
    if (userPayload == null) {
        out.writeInt(-1);/* www. ja v  a2s.co m*/
    } else {
        out.writeInt(userPayload.length);
        out.write(userPayload);
    }
}

From source file:org.apache.tez.engine.common.shuffle.impl.ShuffleHeader.java

License:Apache License

public void write(DataOutput out) throws IOException {
    Text.writeString(out, mapId);
    WritableUtils.writeVLong(out, compressedLength);
    WritableUtils.writeVLong(out, uncompressedLength);
    WritableUtils.writeVInt(out, forReduce);
}

From source file:org.apache.tez.mapreduce.processor.MapUtils.java

License:Apache License

private static void writeSplitFiles(FileSystem fs, JobConf conf, InputSplit split) throws IOException {
    Path jobSplitFile = new Path(conf.get(MRFrameworkConfigs.TASK_LOCAL_RESOURCE_DIR,
            MRFrameworkConfigs.TASK_LOCAL_RESOURCE_DIR_DEFAULT), MRJobConfig.JOB_SPLIT);
    LOG.info("Writing split to: " + jobSplitFile);
    FSDataOutputStream out = FileSystem.create(fs, jobSplitFile, new FsPermission(JOB_FILE_PERMISSION));

    long offset = out.getPos();
    Text.writeString(out, split.getClass().getName());
    split.write(out);// ww  w .j  ava2s  .c o  m
    out.close();

    String[] locations = split.getLocations();

    SplitMetaInfo info = null;
    info = new JobSplit.SplitMetaInfo(locations, offset, split.getLength());

    Path jobSplitMetaInfoFile = new Path(conf.get(MRFrameworkConfigs.TASK_LOCAL_RESOURCE_DIR),
            MRJobConfig.JOB_SPLIT_METAINFO);

    FSDataOutputStream outMeta = FileSystem.create(fs, jobSplitMetaInfoFile,
            new FsPermission(JOB_FILE_PERMISSION));
    outMeta.write(SplitMetaInfoReaderTez.META_SPLIT_FILE_HEADER);
    WritableUtils.writeVInt(outMeta, SplitMetaInfoReaderTez.META_SPLIT_VERSION);
    WritableUtils.writeVInt(outMeta, 1); // Only 1 split meta info being written
    info.write(outMeta);
    outMeta.close();
}

From source file:org.apache.tez.runtime.api.impl.GroupInputSpec.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    Text.writeString(out, groupName);
    out.writeInt(groupVertices.size());/*from   w w w .ja va  2 s  .  co  m*/
    for (String s : groupVertices) {
        Text.writeString(out, s);
    }
    mergedInputDescriptor.write(out);
}

From source file:org.apache.tez.runtime.api.impl.TaskStatistics.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    int numEntries = ioStatistics.size();
    out.writeInt(numEntries);/*from   ww  w .  j  av  a 2  s.  c o m*/
    for (Map.Entry<String, IOStatistics> entry : ioStatistics.entrySet()) {
        IOStatistics edgeStats = entry.getValue();
        Text.writeString(out, entry.getKey());
        edgeStats.write(out);
    }
}

From source file:org.apache.tez.runtime.api.impl.TezHeartbeatRequest.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    if (events != null) {
        out.writeBoolean(true);//from   w ww. j av a2s.c  o  m
        out.writeInt(events.size());
        for (TezEvent e : events) {
            e.write(out);
        }
    } else {
        out.writeBoolean(false);
    }
    if (currentTaskAttemptID != null) {
        out.writeBoolean(true);
        currentTaskAttemptID.write(out);
    } else {
        out.writeBoolean(false);
    }
    out.writeInt(startIndex);
    out.writeInt(maxEvents);
    out.writeLong(requestId);
    Text.writeString(out, containerIdentifier);
}

From source file:org.broadinstitute.sting.gatk.hadoop.XFileSplit.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    Text.writeString(out, file.toString());
    out.writeLong(start);//  www  .  j  a  va 2s  .c om
    out.writeLong(length);
    out.writeLong(fileId);
    out.writeLong(splitId);
}

From source file:org.commoncrawl.hadoop.io.ARCResource.java

License:Open Source License

/**
 * @inheritDoc
 */
public void write(DataOutput out) throws IOException {
    Text.writeString(out, name);
    out.writeLong(size);
}