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.apache.vxquery.runtime.functions.cast.CastToStringOperation.java

public void convertDoubleCanonical(DoublePointable doublep, DataOutput dOut)
        throws SystemException, IOException {
    abvsInner.reset();//from   w ww . j av a 2  s .  co m
    double value = doublep.getDouble();

    dOut.write(returnTag);
    dOut.writeUTF(Double.toString(value));
    return;
}

From source file:org.apache.horn.core.LayeredNeuralNetwork.java

@Override
public void write(DataOutput output) throws IOException {
    super.write(output);
    output.writeInt(finalLayerIdx);//ww  w. j  a  va 2s .c  o  m
    output.writeFloat(dropRate);

    // write neuron classes
    output.writeInt(this.neuronClassList.size());
    for (Class<? extends Neuron> clazz : this.neuronClassList) {
        output.writeUTF(clazz.getName());
    }

    // write squashing functions
    output.writeInt(this.squashingFunctionList.size());
    for (FloatFunction aSquashingFunctionList : this.squashingFunctionList) {
        WritableUtils.writeString(output, aSquashingFunctionList.getFunctionName());
    }

    // write weight matrices
    output.writeInt(this.weightMatrixList.size());
    for (FloatMatrix aWeightMatrixList : this.weightMatrixList) {
        FloatMatrixWritable.write(aWeightMatrixList, output);
    }

    // DO NOT WRITE WEIGHT UPDATE
}

From source file:org.apache.geode.management.internal.cli.domain.DataCommandResult.java

public void toData(DataOutput out) throws IOException {
    DataSerializer.writeString(command, out);
    out.writeUTF(command);
    DataSerializer.writeObject(putResult, out);
    DataSerializer.writeObject(getResult, out);
    DataSerializer.writeObject(locateEntryResult, out);
    DataSerializer.writeArrayList((ArrayList<?>) locateEntryLocations, out);
    DataSerializer.writeBoolean(hasResultForAggregation, out);
    DataSerializer.writeObject(removeResult, out);
    DataSerializer.writeObject(inputKey, out);
    DataSerializer.writeObject(inputValue, out);
    DataSerializer.writeObject(error, out);
    DataSerializer.writeString(errorString, out);
    DataSerializer.writeString(infoString, out);
    DataSerializer.writeString(keyClass, out);
    DataSerializer.writeString(valueClass, out);
    DataSerializer.writeBoolean(operationCompletedSuccessfully, out);
}

From source file:com.aliyun.odps.io.TupleReaderWriter.java

private static void writeDatum(DataOutput out, Writable val) throws IOException {
    // Read the data type
    byte type = findType(val);
    switch (type) {
    case TUPLE://from   w  w  w . j  a v a2s.  c  om
        Tuple t = (Tuple) val;
        out.writeByte(TUPLE);
        int sz = t.size();
        out.writeInt(sz);
        for (int i = 0; i < sz; i++) {
            writeDatum(out, t.get(i));
        }
        break;

    case NULL:
        out.writeByte(NULL);
        break;

    case INTWRITABLE:
        out.writeByte(INTWRITABLE);
        ((IntWritable) val).write(out);
        break;

    case LONGWRITABLE:
        out.writeByte(LONGWRITABLE);
        ((LongWritable) val).write(out);
        break;

    case DATETIMEWRITABLE:
        out.writeByte(DATETIMEWRITABLE);
        ((DatetimeWritable) val).write(out);
        break;

    case DOUBLEWRITABLE:
        out.writeByte(DOUBLEWRITABLE);
        ((DoubleWritable) val).write(out);
        break;

    case BOOLEANWRITABLE:
        out.writeByte(BOOLEANWRITABLE);
        ((BooleanWritable) val).write(out);
        break;

    case BYTESWRITABLE:
        out.writeByte(BYTESWRITABLE);
        ((BytesWritable) val).write(out);
        break;

    case TEXT:
        out.writeByte(TEXT);
        ((Text) val).write(out);
        break;

    case NULLWRITABLE:
        out.writeByte(NULLWRITABLE);
        ((NullWritable) val).write(out);
        break;

    case UNKNOWN:
        out.writeByte(UNKNOWN);
        out.writeUTF(val.getClass().getName());
        val.write(out);
        break;

    default:
        throw new RuntimeException("Unexpected data type " + type + " found in stream.");
    }
}

From source file:org.apache.kylin.dict.lookup.SnapshotTable.java

void writeData(DataOutput out) throws IOException {
    out.writeInt(rowIndices.size());/*from  w ww .j a  v  a 2  s . c o  m*/
    if (rowIndices.size() > 0) {
        int n = rowIndices.get(0).length;
        out.writeInt(n);

        if (this.useDictionary == true) {
            dict.write(out);
            for (int i = 0; i < rowIndices.size(); i++) {
                int[] row = rowIndices.get(i);
                for (int j = 0; j < n; j++) {
                    out.writeInt(row[j]);
                }
            }

        } else {
            for (int i = 0; i < rowIndices.size(); i++) {
                int[] row = rowIndices.get(i);
                for (int j = 0; j < n; j++) {
                    // NULL_STR is tricky, but we don't want to break the current snapshots
                    out.writeUTF(dict.getValueFromId(row[j]) == null ? NULL_STR : dict.getValueFromId(row[j]));
                }
            }
        }
    }
}

From source file:org.apache.vxquery.runtime.functions.cast.CastToStringOperation.java

public void convertFloatCanonical(FloatPointable floatp, DataOutput dOut) throws SystemException, IOException {
    abvsInner.reset();/* w  ww . j  a  va  2s.  co  m*/
    float value = floatp.getFloat();

    if (Float.isInfinite(value)) {
        if (value == Float.NEGATIVE_INFINITY) {
            FunctionHelper.writeCharSequence("-", dOutInner);
        }
        FunctionHelper.writeCharSequence("INF", dOutInner);
    } else if (Float.isNaN(value)) {
        FunctionHelper.writeCharSequence("NaN", dOutInner);
    } else {
        dOut.write(returnTag);
        dOut.writeUTF(Float.toString(value));
        return;
    }
    sendStringDataOutput(dOut);
}

From source file:org.apache.horn.core.RecurrentLayeredNeuralNetwork.java

@Override
public void write(DataOutput output) throws IOException {
    super.write(output);
    output.writeInt(finalLayerIdx);// w w w . j a  v  a2 s. com
    output.writeFloat(dropRate);

    // write neuron classes
    output.writeInt(this.neuronClassList.size());
    for (Class<? extends Neuron> clazz : this.neuronClassList) {
        output.writeUTF(clazz.getName());
    }

    // write squashing functions
    output.writeInt(this.squashingFunctionList.size());
    for (FloatFunction aSquashingFunctionList : this.squashingFunctionList) {
        WritableUtils.writeString(output, aSquashingFunctionList.getFunctionName());
    }

    // write recurrent step size
    output.writeInt(this.recurrentStepSize);

    // write recurrent step size
    output.writeInt(this.numOutCells);

    // write recurrent layer list
    output.writeInt(this.recurrentLayerList.size());
    for (Boolean isReccurentLayer : recurrentLayerList) {
        output.writeBoolean(isReccurentLayer);
    }

    // write weight matrices
    output.writeInt(this.getSizeOfWeightmatrix());
    for (List<FloatMatrix> aWeightMatrixLists : this.weightMatrixLists) {
        for (FloatMatrix aWeightMatrixList : aWeightMatrixLists) {
            FloatMatrixWritable.write(aWeightMatrixList, output);
        }
    }

    // DO NOT WRITE WEIGHT UPDATE
}

From source file:com.chinamobile.bcbsp.sync.SuperStepCommand.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(this.commandType);
    Text.writeString(out, this.initWritePath);
    Text.writeString(out, this.initReadPath);
    out.writeInt(this.ableCheckPoint);
    out.writeInt(this.nextSuperStepNum);
    out.writeInt(this.oldCheckPoint);
    out.writeInt(this.aggValues.length);
    int count = this.aggValues.length;
    for (int i = 0; i < count; i++) {
        Text.writeString(out, this.aggValues[i]);
    }/*from  w  w w  . j  a  v  a2 s .c o m*/
    if (partitionToWorkerManagerNameAndPort == null) {
        WritableUtils.writeVInt(out, 0);
    } else {
        WritableUtils.writeVInt(out, partitionToWorkerManagerNameAndPort.size());
        String[] partitionToWMName = null;
        for (Integer i : this.partitionToWorkerManagerNameAndPort.keySet()) {
            partitionToWMName[i] = partitionToWorkerManagerNameAndPort.get(i);
        }
        WritableUtils.writeCompressedStringArray(out, partitionToWMName);
    }
    out.writeUTF(this.migrateStaffIDs);
    this.migrateVertexCommand.write(out);
}

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());/*  w  ww .ja v a 2  s . c  om*/
    out.writeInt(getNumColumns());
    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:com.mobicage.rogerthat.plugins.messaging.BrandingMgr.java

@Override
public void writePickle(DataOutput out) throws IOException {
    T.dontCare();/*www  .  j  av  a  2  s  .co  m*/
    out.writeInt(mQueue.size());
    for (BrandedItem item : mQueue) {
        out.writeUTF(JSONValue.toJSONString(item.toJSONMap()));
    }
    out.writeInt(mDownloadMgrQueue.size());
    for (BrandedItem item : mDownloadMgrQueue.values()) {
        out.writeUTF(JSONValue.toJSONString(item.toJSONMap()));
    }
}