Java Code Examples for org.apache.hadoop.io.WritableUtils#writeString()

The following examples show how to use org.apache.hadoop.io.WritableUtils#writeString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractNeuralNetwork.java    From incubator-retired-horn with Apache License 2.0 6 votes vote down vote up
@Override
public void write(DataOutput output) throws IOException {
  // write model type
  WritableUtils.writeString(output, modelType);
  // write learning rate
  output.writeFloat(learningRate);
  // write model path
  if (this.modelPath != null) {
    WritableUtils.writeString(output, modelPath);
  } else {
    WritableUtils.writeString(output, "null");
  }

  // serialize the class
  Class<? extends FloatFeatureTransformer> featureTransformerCls = this.featureTransformer
      .getClass();
  byte[] featureTransformerBytes = SerializationUtils
      .serialize(featureTransformerCls);
  output.writeInt(featureTransformerBytes.length);
  output.write(featureTransformerBytes);
}
 
Example 2
Source File: Server.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Setup response for the IPC Call on Fatal Error from a 
 * client that is using old version of Hadoop.
 * The response is serialized using the previous protocol's response
 * layout.
 * 
 * @param response buffer to serialize the response into
 * @param call {@link Call} to which we are setting up the response
 * @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 setupResponseOldVersionFatal(ByteArrayOutputStream response, 
                           Call call,
                           Writable rv, String errorClass, String error) 
throws IOException {
  final int OLD_VERSION_FATAL_STATUS = -1;
  response.reset();
  DataOutputStream out = new DataOutputStream(response);
  out.writeInt(call.callId);                // write call id
  out.writeInt(OLD_VERSION_FATAL_STATUS);   // write FATAL_STATUS
  WritableUtils.writeString(out, errorClass);
  WritableUtils.writeString(out, error);

  if (call.connection.useWrap) {
    wrapWithSasl(response, call);
  }
  call.setResponse(ByteBuffer.wrap(response.toByteArray()));
}
 
Example 3
Source File: FileSystemCounterGroup.java    From tez with Apache License 2.0 6 votes vote down vote up
/**
 * FileSystemGroup ::= #scheme (scheme #counter (key value)*)*
 */
@Override
public void write(DataOutput out) throws IOException {
  WritableUtils.writeVInt(out, map.size()); // #scheme
  for (Map.Entry<String, Object[]> entry : map.entrySet()) {
    WritableUtils.writeString(out, entry.getKey()); // scheme
    // #counter for the above scheme
    WritableUtils.writeVInt(out, numSetCounters(entry.getValue()));
    for (Object counter : entry.getValue()) {
      if (counter == null) continue;
      FSCounter c = (FSCounter) ((TezCounter)counter).getUnderlyingCounter();
      WritableUtils.writeVInt(out, c.key.ordinal());  // key
      WritableUtils.writeVLong(out, c.getValue());    // value
    }
  }
}
 
Example 4
Source File: ReferenceFragment.java    From Hadoop-BAM with MIT License 5 votes vote down vote up
public void write(DataOutput out) throws IOException
   {
sequence.write(out);

WritableUtils.writeString(out, indexSequence);
WritableUtils.writeVInt(out, position);

   }
 
Example 5
Source File: LouvainNodeState.java    From distributed-graph-analytics with Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
    WritableUtils.writeString(out, community);
    out.writeLong(communitySigmaTotal);
    out.writeLong(internalWeight);
    out.writeLong(changed);
    out.writeLong(nodeWeight);
    out.writeInt(changeHistory.size());
    for (Long i : changeHistory) {
        out.writeLong(i);
    }

}
 
Example 6
Source File: BlockTokenIdentifier.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
  WritableUtils.writeVLong(out, expiryDate);
  WritableUtils.writeVInt(out, keyId);
  WritableUtils.writeString(out, userId);
  WritableUtils.writeString(out, blockPoolId);
  WritableUtils.writeVLong(out, blockId);
  WritableUtils.writeVInt(out, modes.size());
  for (AccessMode aMode : modes) {
    WritableUtils.writeEnum(out, aMode);
  }
}
 
Example 7
Source File: LogBeanWritable.java    From 163-bigdate-note with GNU General Public License v3.0 5 votes vote down vote up
public void write(DataOutput out) throws IOException {
    WritableUtils.writeString(out, activeName);
    WritableUtils.writeString(out, sessionID);
    out.writeLong(timeTag);
    WritableUtils.writeString(out, ip);
    WritableUtils.writeString(out, deviceID);
    WritableUtils.writeString(out, reqUrl);
    WritableUtils.writeString(out, userID);
    WritableUtils.writeString(out, productID);
    WritableUtils.writeString(out, orderID);
}
 
Example 8
Source File: SequencedFragment.java    From Hadoop-BAM with MIT License 5 votes vote down vote up
public void write(DataOutput out) throws IOException
{
	// TODO:  reimplement with a serialization system (e.g. Avro)

	sequence.write(out);
	quality.write(out);

	int presentFlags = 0;
	if (instrument != null) presentFlags |= Instrument_Present;
	if (runNumber != null) presentFlags |= RunNumber_Present;
	if (flowcellId != null) presentFlags |= FlowcellId_Present;
	if (lane != null) presentFlags |= Lane_Present;
	if (tile != null) presentFlags |= Tile_Present;
	if (xpos != null) presentFlags |= Xpos_Present;
	if (ypos != null) presentFlags |= Ypos_Present;
	if (read != null) presentFlags |= Read_Present;
	if (filterPassed != null) presentFlags |= FilterPassed_Present;
	if (controlNumber != null) presentFlags |= ControlNumber_Present;
	if (indexSequence != null) presentFlags |= IndexSequence_Present;

	WritableUtils.writeVInt(out, presentFlags);

	if (instrument != null) WritableUtils.writeString(out, instrument);
	if (runNumber != null) WritableUtils.writeVInt(out, runNumber);
	if (flowcellId != null) WritableUtils.writeString(out, flowcellId);
	if (lane != null) WritableUtils.writeVInt(out, lane);
	if (tile != null) WritableUtils.writeVInt(out, tile);
	if (xpos != null) WritableUtils.writeVInt(out, xpos);
	if (ypos != null) WritableUtils.writeVInt(out, ypos);
	if (read != null) WritableUtils.writeVInt(out, read);
	if (filterPassed != null) WritableUtils.writeVInt(out, filterPassed ? 1 : 0);
	if (controlNumber != null) WritableUtils.writeVInt(out, controlNumber);
	if (indexSequence != null) WritableUtils.writeString(out, indexSequence);
}
 
Example 9
Source File: LouvainMessage.java    From distributed-graph-analytics with Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
    WritableUtils.writeString(out, communityId);
    out.writeLong(communitySigmaTotal);
    out.writeLong(edgeWeight);
    WritableUtils.writeString(out, sourceId);
}
 
Example 10
Source File: TaskCompletionEvent.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public void write(DataOutput out) throws IOException {
  taskId.write(out); 
  WritableUtils.writeVInt(out, idWithinJob);
  out.writeBoolean(isMap);
  WritableUtils.writeEnum(out, status); 
  WritableUtils.writeString(out, taskTrackerHttp);
  WritableUtils.writeVInt(out, taskRunTime);
  WritableUtils.writeVInt(out, eventId);
}
 
Example 11
Source File: TaskTrackerAction.java    From RDFS with Apache License 2.0 5 votes vote down vote up
public void write(DataOutput out) throws IOException {
  WritableUtils.writeEnum(out, actionType);
  String className = "";
  if (extensible == null) {
    WritableUtils.writeString(out, className);
    return;
  }
  className = extensible.getClass().getCanonicalName();
  WritableUtils.writeString(out, className);
  extensible.write(out);
}
 
Example 12
Source File: TaskCompletionEvent.java    From big-c with Apache License 2.0 5 votes vote down vote up
public void write(DataOutput out) throws IOException {
  taskId.write(out); 
  WritableUtils.writeVInt(out, idWithinJob);
  out.writeBoolean(isMap);
  WritableUtils.writeEnum(out, status); 
  WritableUtils.writeString(out, taskTrackerHttp);
  WritableUtils.writeVInt(out, taskRunTime);
  WritableUtils.writeVInt(out, eventId);
}
 
Example 13
Source File: AegCombinedSplit.java    From aegisthus with Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(splits.size());
    for (AegSplit split : splits) {
        WritableUtils.writeString(out, split.getClass().getCanonicalName());
        split.write(out);
    }
}
 
Example 14
Source File: Latitude.java    From datawave with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutput out, boolean reducedResponse) throws IOException {
    writeMetadata(out, reducedResponse);
    
    WritableUtils.writeString(out, this.latitude);
}
 
Example 15
Source File: JobInfo.java    From big-c with Apache License 2.0 4 votes vote down vote up
public void write(DataOutput out) throws IOException {
  id.write(out);
  user.write(out);
  WritableUtils.writeString(out, jobSubmitDir.toString());
}
 
Example 16
Source File: ToNumberFunction.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutput output) throws IOException {
    super.write(output);
    WritableUtils.writeString(output, formatString);
    WritableUtils.writeEnum(output, type);
}
 
Example 17
Source File: RecurrentLayeredNeuralNetwork.java    From incubator-retired-horn with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutput output) throws IOException {
  super.write(output);
  output.writeInt(finalLayerIdx);
  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
}
 
Example 18
Source File: DiacriticContent.java    From datawave with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutput out, boolean reducedResponse) throws IOException {
    writeMetadata(out, reducedResponse);
    
    WritableUtils.writeString(out, content);
}
 
Example 19
Source File: GeoPoint.java    From datawave with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutput out, boolean reducedResponse) throws IOException {
    writeMetadata(out, reducedResponse);
    
    WritableUtils.writeString(out, this.point);
}
 
Example 20
Source File: JobInfo.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public void write(DataOutput out) throws IOException {
  id.write(out);
  user.write(out);
  WritableUtils.writeString(out, jobSubmitDir.toString());
}