Example usage for java.io DataOutput writeUTF

List of usage examples for java.io DataOutput writeUTF

Introduction

In this page you can find the example usage for java.io DataOutput writeUTF.

Prototype

void writeUTF(String s) throws IOException;

Source Link

Document

Writes two bytes of length information to the output stream, followed by the modified UTF-8 representation of every character in the string s.

Usage

From source file:org.kiji.schema.mapreduce.KijiPut.java

/** {@inheritDoc} */
@Override/*from www  .java 2s  .co  m*/
public void write(DataOutput out) throws IOException {
    // EntityId.
    final byte[] bytes = mEntityId.getHBaseRowKey();
    out.writeInt(bytes.length);
    out.write(bytes);

    // Family/Qualifier/Timestamp.
    out.writeUTF(mFamily);
    out.writeUTF(mQualifier);
    out.writeLong(mTimestamp);

    // Avro.
    final KijiCellEncoder encoder = new KijiCellEncoder(null);
    final byte[] cellData = encoder.encode(mCell, KijiCellFormat.NONE);
    out.writeUTF(mCell.getWriterSchema().toString());
    out.writeInt(cellData.length);
    out.write(cellData);
}

From source file:org.apache.hadoop.ipc.ConnectionHeader.java

@Override
public void write(DataOutput out) throws IOException {
    Text.writeString(out, (protocol == null) ? "" : protocol);
    if (ugi != null) {
        if (authMethod == AuthMethod.KERBEROS) {
            // Send effective user for Kerberos auth
            out.writeBoolean(true);//www  .ja  va2  s .c o  m
            out.writeUTF(ugi.getUserName());
            out.writeBoolean(false);
        } else if (authMethod == AuthMethod.DIGEST) {
            // Don't send user for token auth
            out.writeBoolean(false);
        } else {
            //Send both effective user and real user for simple auth
            out.writeBoolean(true);
            out.writeUTF(ugi.getUserName());
            if (ugi.getRealUser() != null) {
                out.writeBoolean(true);
                out.writeUTF(ugi.getRealUser().getUserName());
            } else {
                out.writeBoolean(false);
            }
        }
    } else {
        out.writeBoolean(false);
    }
}

From source file:org.apache.sqoop.connector.idf.JSONIntermediateDataFormat.java

/**
 * {@inheritDoc}/*from  w w  w. j a va 2s  .c o m*/
 */
@Override
public void write(DataOutput out) throws IOException {
    out.writeUTF(this.data.toJSONString());
}

From source file:cn.edu.xidian.repace.xml2hbase.filter.TestFilter.java

public void write(final DataOutput out) throws IOException {
    Bytes.writeByteArray(out, this.columnFamily);
    Bytes.writeByteArray(out, this.columnQualifier);
    out.writeUTF(compareOp.name());
    HbaseObjectWritable.writeObject(out, comparator, WritableByteArrayComparable.class, null);
    out.writeBoolean(foundColumn);/*from www .ja  v  a 2 s  .  c o  m*/
    out.writeBoolean(matchedColumn);
    out.writeBoolean(filterIfMissing);
    out.writeBoolean(latestVersionOnly);
}

From source file:edu.umn.cs.spatialHadoop.osm.OSMEdge.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeLong(edgeId);/*from   w w w . j ava  2s  .co  m*/
    out.writeLong(nodeId1);
    out.writeDouble(lat1);
    out.writeDouble(lon1);
    out.writeLong(nodeId2);
    out.writeDouble(lat2);
    out.writeDouble(lon2);
    out.writeLong(wayId);
    out.writeUTF(tags);
}

From source file:org.apache.hadoop.hbase.hbql.filter.SingleColumnValueFilter.java

public void write(final DataOutput out) throws IOException {

    out.writeBoolean(this.getVerbose());

    Bytes.writeByteArray(out, this.columnFamily);
    Bytes.writeByteArray(out, this.columnQualifier);
    out.writeUTF(compareOp.name());
    HbaseObjectWritable.writeObject(out, comparator, WritableByteArrayComparable.class, null);
    out.writeBoolean(foundColumn);// ww w . ja v a  2  s . c om
    out.writeBoolean(matchedColumn);
    out.writeBoolean(filterIfMissing);
    out.writeBoolean(latestVersionOnly);
}

From source file:org.kiji.schema.mapreduce.KijiDelete.java

/**
 * During serialization, if an attribute is null, write the String NULL to DataOutput,
 * else write the actual value.//  w w w  .jav a 2 s  .  c  o  m
 *
 * @param toWrite Object to write to DataOutput.
 * @param out Interface to output stream.
 * @throws IOException if an I/O error occurs.
 */
private void writeOptionalValue(Object toWrite, DataOutput out) throws IOException {
    if (null == toWrite) {
        out.writeUTF("NULL");
        return;
    }
    if (toWrite instanceof KijiDeleteOperation) {
        out.writeUTF(((KijiDeleteOperation) toWrite).name());
        return;
    }
    if (toWrite instanceof Long) {
        out.writeUTF(((Long) toWrite).toString());
        return;
    }
    out.writeUTF((String) toWrite);
}

From source file:com.kylinolap.dict.lookup.SnapshotTable.java

void writeData(DataOutput out) throws IOException {
    out.writeInt(rows.size());/*w ww.j ava 2 s.  co m*/
    if (rows.size() > 0) {
        int n = rows.get(0).length;
        out.writeInt(n);
        for (int i = 0; i < rows.size(); i++) {
            String[] row = rows.get(i);
            for (int j = 0; j < n; j++) {
                out.writeUTF(row[j]);
            }
        }
    }
}

From source file:parquet.hadoop.ParquetInputSplit.java

private void writeColumn(DataOutput out, ColumnChunkMetaData column) throws IOException {
    out.writeInt(column.getCodec().ordinal());
    out.writeInt(column.getPath().size());
    for (String s : column.getPath()) {
        out.writeUTF(s);
    }//from   www .j  av a  2s.  c o m
    out.writeInt(column.getType().ordinal());
    out.writeInt(column.getEncodings().size());
    for (Encoding encoding : column.getEncodings()) {
        out.writeInt(encoding.ordinal());
    }
    out.writeLong(column.getFirstDataPageOffset());
    out.writeLong(column.getDictionaryPageOffset());
    out.writeLong(column.getValueCount());
    out.writeLong(column.getTotalSize());
    out.writeLong(column.getTotalUncompressedSize());
}

From source file:edu.umd.cloud9.collection.wikipedia.WikipediaPage.java

/**
 * Deserializes this object./*from w w w  .j  ava  2s  .  c  o m*/
 */
public void write(DataOutput out) throws IOException {
    byte[] bytes = page.getBytes();
    WritableUtils.writeVInt(out, bytes.length);
    out.write(bytes, 0, bytes.length);
    out.writeUTF(language);
}