Example usage for java.io DataOutput writeInt

List of usage examples for java.io DataOutput writeInt

Introduction

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

Prototype

void writeInt(int v) throws IOException;

Source Link

Document

Writes an int value, which is comprised of four bytes, to the output stream.

Usage

From source file:com.mapr.hbase.support.objects.MHRegionInfo.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeByte(getVersion());//w ww .  ja va2 s.c o m
    Bytes.writeByteArray(out, endKey);
    out.writeBoolean(offLine);
    out.writeLong(regionId);
    Bytes.writeByteArray(out, regionName);
    out.writeBoolean(split);
    Bytes.writeByteArray(out, startKey);
    if (getVersion() == 0) {
        tableDesc.write(out);
    } else {
        Bytes.writeByteArray(out, tableName);
    }
    out.writeInt(hashCode);
}

From source file:com.fiorano.openesb.application.aps.ApplicationContext.java

/**
 *  This method writes this <code>ApplicationContext</code> object to the
 *  specified output stream object./*from  ww  w.  j  av a  2s.  c om*/
 *
 * @param out DataOutput object
 * @param versionNo
 * @exception IOException if an error occurs while converting data and
 *      writing it to a binary stream.
        
 * @since Tifosi2.0
 */
public void toStream(DataOutput out, int versionNo) throws IOException {
    super.toStream(out, versionNo);

    if (m_structure != null)
        UTFReaderWriter.writeUTF(out, m_structure);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_defaultInstance != null)
        UTFReaderWriter.writeUTF(out, m_defaultInstance);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_rootElement != null)
        UTFReaderWriter.writeUTF(out, m_rootElement);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_rootElementNamespace != null)
        UTFReaderWriter.writeUTF(out, m_rootElementNamespace);
    else
        UTFReaderWriter.writeUTF(out, "");

    out.writeInt(m_structureType);
}

From source file:org.apache.hama.graph.GraphJobMessage.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeByte(this.flag);
    if (isVertexMessage()) {
        // we don't need to write the classes because the other side has the
        // same/*from   w ww  . j  a v  a 2  s  .c  o  m*/
        // classes for the two entities.
        vertexId.write(out);
        vertexValue.write(out);
    } else if (isMapMessage()) {
        map.write(out);
    } else if (isPartitioningMessage()) {
        //LOG.info("????????????????");
        //LOG.info("vertex.getVertexID() : "+ vertex.getVertexID().toString());
        vertex.getVertexID().write(out);
        //LOG.info("vertex.getValue() : " + vertex.getValue());
        if (vertex.getValue() != null) {
            //LOG.info("vertexvalue");
            out.writeBoolean(true);
            vertex.getValue().write(out);
        } else {
            out.writeBoolean(false);
        }
        List<?> outEdges = vertex.getEdges();
        out.writeInt(outEdges.size());
        //LOG.info("?: " + outEdges.size());
        for (Object e : outEdges) {
            Edge<?, ?> edge = (Edge<?, ?>) e;
            //LOG.info(" : " + edge);
            edge.getDestinationVertexID().write(out);
            if (edge.getValue() != null) {
                out.writeBoolean(true);
                edge.getValue().write(out);
            } else {
                //LOG.info(",?dge.getValue()==null");
                out.writeBoolean(false);
            }
        }
    } else if (isVerticesSizeMessage()) {
        vertices_size.write(out);
    } else if (isBoundaryVertexSizeMessage()) {
        boundaryVertex_size.write(out);
    } else {
        vertexId.write(out);
    }

}

From source file:bobs.is.compress.sevenzip.SevenZOutputFile.java

private void writePackInfo(final DataOutput header) throws IOException {
    header.write(NID.kPackInfo);//from   w w w  . ja  v  a 2  s. c om

    writeUint64(header, 0);
    writeUint64(header, 0xffffFFFFL & numNonEmptyStreams);

    header.write(NID.kSize);
    for (final SevenZArchiveEntry entry : files) {
        if (entry.hasStream()) {
            writeUint64(header, entry.getCompressedSize());
        }
    }

    header.write(NID.kCRC);
    header.write(1); // "allAreDefined" == true
    for (final SevenZArchiveEntry entry : files) {
        if (entry.hasStream()) {
            header.writeInt(Integer.reverseBytes((int) entry.getCompressedCrcValue()));
        }
    }

    header.write(NID.kEnd);
}

From source file:org.apache.hadoop.hbase.HTableDescriptor.java

/**
 * <em> INTERNAL </em> This method is a part of {@link WritableComparable} interface
 * and is used for serialization of the HTableDescriptor over RPC
 * @deprecated Writables are going away.
 * Use {@link com.google.protobuf.MessageLite#toByteArray} instead.
 *//* w w w.j a v  a  2s .c  om*/
@Deprecated
@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(TABLE_DESCRIPTOR_VERSION);
    Bytes.writeByteArray(out, name.toBytes());
    out.writeBoolean(isRootRegion());
    out.writeBoolean(isMetaRegion());
    out.writeInt(values.size());
    for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> e : values.entrySet()) {
        e.getKey().write(out);
        e.getValue().write(out);
    }
    out.writeInt(families.size());
    for (Iterator<HColumnDescriptor> it = families.values().iterator(); it.hasNext();) {
        HColumnDescriptor family = it.next();
        family.write(out);
    }
    out.writeInt(configuration.size());
    for (Map.Entry<String, String> e : configuration.entrySet()) {
        new ImmutableBytesWritable(Bytes.toBytes(e.getKey())).write(out);
        new ImmutableBytesWritable(Bytes.toBytes(e.getValue())).write(out);
    }
}

From source file:org.apache.hadoop.hbase.HRegionInfo.java

/**
 * @deprecated Use protobuf serialization instead.  See {@link #toByteArray()} and
 * {@link #toDelimitedByteArray()}/*w w w  .j  a  v  a  2s  .  c  o m*/
 */
@Deprecated
public void write(DataOutput out) throws IOException {
    out.writeByte(getVersion());
    Bytes.writeByteArray(out, endKey);
    out.writeBoolean(offLine);
    out.writeLong(regionId);
    Bytes.writeByteArray(out, regionName);
    out.writeBoolean(split);
    Bytes.writeByteArray(out, startKey);
    Bytes.writeByteArray(out, tableName.getName());
    out.writeInt(hashCode);
}

From source file:org.apache.hadoop.mapred.Task.java

public void write(DataOutput out) throws IOException {
    Text.writeString(out, jobFile);
    taskId.write(out);/*  www.  java 2s .c o  m*/
    out.writeInt(partition);
    out.writeInt(numSlotsRequired);
    taskStatus.write(out);
    skipRanges.write(out);
    out.writeBoolean(skipping);
    out.writeBoolean(jobCleanup);
    if (jobCleanup) {
        WritableUtils.writeEnum(out, jobRunStateForCleanup);
    }
    out.writeBoolean(jobSetup);
    out.writeBoolean(writeSkipRecs);
    out.writeBoolean(taskCleanup);
    Text.writeString(out, user);
}

From source file:org.apache.sysml.runtime.matrix.data.FrameBlock.java

@Override
public void write(DataOutput out) throws IOException {
    boolean isDefaultMeta = isColNamesDefault() && isColumnMetadataDefault();
    //write header (rows, cols, default)
    out.writeInt(getNumRows());
    out.writeInt(getNumColumns());//  w  w  w .j a  va  2  s  .  c  o  m
    out.writeBoolean(isDefaultMeta);
    //write columns (value type, data)
    for (int j = 0; j < getNumColumns(); j++) {
        out.writeByte(_schema[j].ordinal());
        if (!isDefaultMeta) {
            out.writeUTF(getColumnName(j));
            out.writeLong(_colmeta[j].getNumDistinct());
            out.writeUTF((_colmeta[j].getMvValue() != null) ? _colmeta[j].getMvValue() : "");
        }
        _coldata[j].write(out);
    }
}

From source file:org.apache.pig.data.BinInterSedes.java

private void writeMap(DataOutput out, Map<String, Object> m) throws IOException {

    final int sz = m.size();
    if (sz < UNSIGNED_BYTE_MAX) {
        out.writeByte(TINYMAP);/*from  w w w. j ava  2  s.c  om*/
        out.writeByte(sz);
    } else if (sz < UNSIGNED_SHORT_MAX) {
        out.writeByte(SMALLMAP);
        out.writeShort(sz);
    } else {
        out.writeByte(MAP);
        out.writeInt(sz);
    }
    Iterator<Map.Entry<String, Object>> i = m.entrySet().iterator();
    while (i.hasNext()) {
        Map.Entry<String, Object> entry = i.next();
        writeDatum(out, entry.getKey());
        writeDatum(out, entry.getValue());
    }
}

From source file:bobs.is.compress.sevenzip.SevenZOutputFile.java

private void writeUnpackInfo(final DataOutput header) throws IOException {
    header.write(NID.kUnpackInfo);//  w w w.  j  a va 2 s .  c o  m

    header.write(NID.kFolder);
    writeUint64(header, numNonEmptyStreams);
    header.write(0);
    for (final SevenZArchiveEntry entry : files) {
        if (entry.hasStream()) {
            writeFolder(header, entry);
        }
    }

    header.write(NID.kCodersUnpackSize);
    for (final SevenZArchiveEntry entry : files) {
        if (entry.hasStream()) {
            final long[] moreSizes = additionalSizes.get(entry);
            if (moreSizes != null) {
                for (final long s : moreSizes) {
                    writeUint64(header, s);
                }
            }
            writeUint64(header, entry.getSize());
        }
    }

    header.write(NID.kCRC);
    header.write(1); // "allAreDefined" == true
    for (final SevenZArchiveEntry entry : files) {
        if (entry.hasStream()) {
            header.writeInt(Integer.reverseBytes((int) entry.getCrcValue()));
        }
    }

    header.write(NID.kEnd);
}