List of usage examples for org.apache.hadoop.io WritableUtils writeString
public static void writeString(DataOutput out, String s) throws IOException
From source file:org.apache.accumulo.core.client.IteratorSetting.java
License:Apache License
/** * @since 1.5.0//from ww w. j a v a2 s . c o m * @see Writable */ @Override public void write(DataOutput dout) throws IOException { WritableUtils.writeVInt(dout, priority); WritableUtils.writeString(dout, name); WritableUtils.writeString(dout, iteratorClass); WritableUtils.writeVInt(dout, properties.size()); for (Entry<String, String> e : properties.entrySet()) { WritableUtils.writeString(dout, e.getKey()); WritableUtils.writeString(dout, e.getValue()); } }
From source file:org.apache.accumulo.core.data.Mutation.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { serialize();/*from w w w.j a v a 2 s. c om*/ byte hasValues = (values == null) ? 0 : (byte) 1; if (!replicationSources.isEmpty()) { // Use 2nd least-significant bit for whether or not we have replication sources hasValues = (byte) (0x02 | hasValues); } out.write((byte) (0x80 | hasValues)); WritableUtils.writeVInt(out, row.length); out.write(row); WritableUtils.writeVInt(out, data.length); out.write(data); WritableUtils.writeVInt(out, entries); if (0x01 == (0x01 & hasValues)) { WritableUtils.writeVInt(out, values.size()); for (int i = 0; i < values.size(); i++) { byte val[] = values.get(i); WritableUtils.writeVInt(out, val.length); out.write(val); } } if (0x02 == (0x02 & hasValues)) { WritableUtils.writeVInt(out, replicationSources.size()); for (String source : replicationSources) { WritableUtils.writeString(out, source); } } }
From source file:org.apache.accumulo.core.replication.ReplicationTarget.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { if (null == peerName) { out.writeBoolean(false);//from ww w . j a va 2s.c o m } else { out.writeBoolean(true); WritableUtils.writeString(out, peerName); } if (null == remoteIdentifier) { out.writeBoolean(false); } else { out.writeBoolean(true); WritableUtils.writeString(out, remoteIdentifier); } if (null == sourceTableId) { out.writeBoolean(false); } else { out.writeBoolean(true); WritableUtils.writeString(out, sourceTableId); } }
From source file:org.apache.giraph.jython.wrappers.JythonWritableWrapper.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { PyString pyString;/*from w w w. j a va2 s. c o m*/ try { pyString = cPickle.dumps(getPyObject()); } catch (PyException e) { LOG.fatal("Could not serialize wrapped Jython value: " + getPyObject().__str__()); throw e; } WritableUtils.writeString(out, pyString.getString()); }
From source file:org.apache.gora.infinispan.query.InfinispanQuery.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { super.write(out); WritableUtils.writeString(out, getSortingField()); out.writeBoolean(isAscendant);/* w w w .j a va 2 s. c om*/ if (location != null) WritableUtils.writeString(out, location.getHostName() + ADDR_DELIMITATOR + location.getPort()); else WritableUtils.writeString(out, ""); }
From source file:org.apache.hama.bsp.TaskCompletionEvent.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { taskId.write(out);/* w ww . j ava2s . c o m*/ WritableUtils.writeVInt(out, idWithinJob); WritableUtils.writeEnum(out, status); WritableUtils.writeString(out, groomServerInfo); WritableUtils.writeVInt(out, taskRunTime); WritableUtils.writeVInt(out, eventId); }
From source file:org.apache.hama.ipc.AsyncServer.java
License:Apache License
/** * Setup response for the IPC Call.//from w w w . j a v a 2 s. c o m * * @param response buffer to serialize the response into * @param call {@link Call} to which we are setting up the response * @param status {@link Status} of the IPC call * @param rv return value for the IPC Call, if the call was successful * @param errorClass error class, if the the call failed * @param error error message, if the call failed * @throws IOException */ private void setupResponse(ByteArrayOutputStream response, Call call, Status status, Writable rv, String errorClass, String error) throws IOException { response.reset(); DataOutputStream out = new DataOutputStream(response); out.writeInt(call.id); // write call id out.writeInt(status.state); // write status if (status == Status.SUCCESS) { rv.write(out); } else { WritableUtils.writeString(out, errorClass); WritableUtils.writeString(out, error); } call.setResponse(ByteBuffer.wrap(response.toByteArray())); IOUtils.closeStream(out); }
From source file:org.apache.hama.ipc.Server.java
License:Apache License
/** * Setup response for the IPC Call.//from w w w. j ava 2s . c o m * * @param response buffer to serialize the response into * @param call {@link Call} to which we are setting up the response * @param status {@link Status} of the IPC call * @param rv return value for the IPC Call, if the call was successful * @param errorClass error class, if the the call failed * @param error error message, if the call failed * @throws IOException */ private void setupResponse(ByteArrayOutputStream response, Call call, Status status, Writable rv, String errorClass, String error) throws IOException { response.reset(); DataOutputStream out = new DataOutputStream(response); out.writeInt(call.id); // write call id out.writeInt(status.state); // write status if (status == Status.SUCCESS) { rv.write(out); } else { WritableUtils.writeString(out, errorClass); WritableUtils.writeString(out, error); } call.setResponse(ByteBuffer.wrap(response.toByteArray())); }
From source file:org.apache.hama.ml.ann.AbstractLayeredNeuralNetwork.java
License:Apache License
@Override public void write(DataOutput output) throws IOException { super.write(output); // write regularization weight output.writeDouble(this.regularizationWeight); // write momentum weight output.writeDouble(this.momentumWeight); // write cost function WritableUtils.writeString(output, costFunction.getFunctionName()); // write layer size list output.writeInt(this.layerSizeList.size()); for (Integer aLayerSizeList : this.layerSizeList) { output.writeInt(aLayerSizeList); }/* w w w . j a v a 2s. c o m*/ WritableUtils.writeEnum(output, this.trainingMethod); WritableUtils.writeEnum(output, this.learningStyle); }
From source file:org.apache.hama.ml.ann.NeuralNetwork.java
License:Apache License
@Override public void write(DataOutput output) throws IOException { // write model type WritableUtils.writeString(output, modelType); // write learning rate output.writeDouble(learningRate);//w ww . ja va 2s . co m // write model path if (this.modelPath != null) { WritableUtils.writeString(output, modelPath); } else { WritableUtils.writeString(output, "null"); } // serialize the class Class<? extends FeatureTransformer> featureTransformerCls = this.featureTransformer.getClass(); byte[] featureTransformerBytes = SerializationUtils.serialize(featureTransformerCls); output.writeInt(featureTransformerBytes.length); output.write(featureTransformerBytes); }