当前位置: 首页>>代码示例>>Java>>正文


Java DataOutput.writeShort方法代码示例

本文整理汇总了Java中java.io.DataOutput.writeShort方法的典型用法代码示例。如果您正苦于以下问题:Java DataOutput.writeShort方法的具体用法?Java DataOutput.writeShort怎么用?Java DataOutput.writeShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.DataOutput的用法示例。


在下文中一共展示了DataOutput.writeShort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toData

import java.io.DataOutput; //导入方法依赖的package包/类
/**
 * Send the contents of this instance to the DataOutput Required to be a
 * {@link org.apache.geode.DataSerializable}Note: must be symmetric with
 * {@link #fromData(DataInput)}in what it writes
 */
@Override
public void toData(DataOutput out) throws IOException {
  super.toData(out);
  short compressedShort = 0;
  compressedShort = computeCompressedShort(compressedShort);
  out.writeShort(compressedShort);
  if (this.processorId != 0)
    out.writeInt(this.processorId);
  if (this.txUniqId != TXManagerImpl.NOTX)
    out.writeInt(this.txUniqId);
  if (this.txMemberId != null)
    DataSerializer.writeObject(this.txMemberId, out);
  out.writeInt(this.regionId);
  // extra field post 9.0
  if (InternalDataSerializer.getVersionForDataStream(out).compareTo(Version.GFE_90) >= 0) {
    out.writeBoolean(this.isTransactionDistributed);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:PartitionMessage.java

示例2: writeStatValue

import java.io.DataOutput; //导入方法依赖的package包/类
public static void writeStatValue(byte typeCode, long v, DataOutput dataOut) throws IOException {
  switch (typeCode) {
    case BYTE_CODE:
      dataOut.writeByte((int) v);
      break;
    case SHORT_CODE:
      dataOut.writeShort((int) v);
      break;
    case INT_CODE:
    case FLOAT_CODE:
    case LONG_CODE:
    case DOUBLE_CODE:
      writeCompactValue(v, dataOut);
      break;
    default:
      throw new InternalGemFireException(LocalizedStrings.StatArchiveWriter_UNEXPECTED_TYPE_CODE_0
          .toLocalizedString(Byte.valueOf(typeCode)));
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:20,代码来源:StatArchiveWriter.java

示例3: writeString

import java.io.DataOutput; //导入方法依赖的package包/类
/** Write a UTF-8 encoded string.
 *
 * @see DataOutput#writeUTF(String)
 */
public static int writeString(DataOutput out, String s) throws IOException {
  if (s.length() > 0xffff/3) {         // maybe too long
    LOG.warn("truncating long string: " + s.length()
             + " chars, starting with " + s.substring(0, 20));
    s = s.substring(0, 0xffff/3);
  }

  int len = utf8Length(s);
  if (len > 0xffff)                             // double-check length
    throw new IOException("string too long!");
    
  out.writeShort(len);
  writeChars(out, s, 0, s.length());
  return len;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:UTF8.java

示例4: writeINodeDirectory

import java.io.DataOutput; //导入方法依赖的package包/类
/**
 * Serialize a {@link INodeDirectory}
 * @param node The node to write
 * @param out The {@link DataOutput} where the fields are written
 */
public static void writeINodeDirectory(INodeDirectory node, DataOutput out)
    throws IOException {
  writeLocalName(node, out);
  out.writeLong(node.getId());
  out.writeShort(0);  // replication
  out.writeLong(node.getModificationTime());
  out.writeLong(0);   // access time
  out.writeLong(0);   // preferred block size
  out.writeInt(-1);   // # of blocks

  writeQuota(node.getQuotaCounts(), out);

  if (node.isSnapshottable()) {
    out.writeBoolean(true);
  } else {
    out.writeBoolean(false);
    out.writeBoolean(node.isWithSnapshot());
  }

  writePermissionStatus(node, out);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:FSImageSerialization.java

示例5: toData

import java.io.DataOutput; //导入方法依赖的package包/类
@Override
public void toData(DataOutput out) throws IOException {
  super.toData(out);

  short flags = 0;
  if (this.processorId != 0)
    flags |= HAS_PROCESSOR_ID;
  if (this.txUniqId != TXManagerImpl.NOTX)
    flags |= HAS_TX_ID;
  if (this.txMemberId != null)
    flags |= HAS_TX_MEMBERID;
  if (this.isReExecute)
    flags |= IS_REEXECUTE;
  out.writeShort(flags);
  if (this.processorId != 0)
    out.writeInt(this.processorId);
  if (this.txUniqId != TXManagerImpl.NOTX)
    out.writeInt(this.txUniqId);
  if (this.txMemberId != null) {
    DataSerializer.writeObject(this.txMemberId, out);
  }

  if (this.isFnSerializationReqd) {
    DataSerializer.writeObject(this.functionObject, out);
  } else {
    DataSerializer.writeObject(functionObject.getId(), out);
  }
  DataSerializer.writeObject(this.args, out);
  DataSerializer.writeHashSet((HashSet) this.filter, out);
  DataSerializer.writeString(this.regionPath, out);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:32,代码来源:DistributedRegionFunctionStreamingMessage.java

示例6: writeShort

import java.io.DataOutput; //导入方法依赖的package包/类
/**
 * Writes an instance of <code>Short</code> to a <code>DataOutput</code>.
 *
 * @throws IOException A problem occurs while writing to <code>out</code>
 * @throws NullPointerException if value is null.
 *
 * @see #readShort
 */
public static void writeShort(Short value, DataOutput out) throws IOException {

  InternalDataSerializer.checkOut(out);

  if (logger.isTraceEnabled(LogMarker.SERIALIZER)) {
    logger.trace(LogMarker.SERIALIZER, "Writing Short {}", value);
  }

  out.writeShort(value.shortValue());
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:DataSerializer.java

示例7: write

import java.io.DataOutput; //导入方法依赖的package包/类
@Override
@InterfaceAudience.Private
public void write(DataOutput out) throws IOException {
  out.writeLong(blockSize);
  out.writeInt(bytesPerChecksum);
  out.writeInt(writePacketSize);
  out.writeShort(replication);
  out.writeInt(fileBufferSize);
  WritableUtils.writeEnum(out, checksumType);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:11,代码来源:FsServerDefaults.java

示例8: writeSelectedColumns

import java.io.DataOutput; //导入方法依赖的package包/类
@Override
public void writeSelectedColumns(DataOutput out, InternalRow row, List<Integer> columns)
    throws IOException {
  byte[] value = (byte[]) row.getRawValue();
  if (value == null) {
    out.writeShort(-1);
  } else if (row.getRowShared().isFullRow()) {
    out.writeShort(row.getLength());
    out.write(value, row.getOffset(), row.getLength());
  } else {
    int length = offset;
    int vlColumns = 0;
    final List<Cell> cells = row.getCells();
    Cell cell;
    for (int i = 0; i < columns.size(); i++) {
      cell = cells.get(columns.get(i));
      if (cell.getValueLength() >= 0) {
        length += cell.getValueLength();
        vlColumns += cell.getColumnType().isFixedLength() ? 0 : 1;
      }
    }
    length += (vlColumns * Bytes.SIZEOF_INT);
    out.writeShort(length);
    for (int i = 0; i < columns.size(); i++) {
      cell = cells.get(columns.get(i));
      if (!cell.getColumnType().isFixedLength()) {
        out.writeInt(cell.getValueLength());
      }
      out.write(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:33,代码来源:EncodingB.java

示例9: writeUserDataSerializableHeader

import java.io.DataOutput; //导入方法依赖的package包/类
public static final void writeUserDataSerializableHeader(int classId, DataOutput out)
    throws IOException {
  if (classId <= Byte.MAX_VALUE && classId >= Byte.MIN_VALUE) {
    out.writeByte(USER_DATA_SERIALIZABLE);
    out.writeByte(classId);
  } else if (classId <= Short.MAX_VALUE && classId >= Short.MIN_VALUE) {
    out.writeByte(USER_DATA_SERIALIZABLE_2);
    out.writeShort(classId);
  } else {
    out.writeByte(USER_DATA_SERIALIZABLE_4);
    out.writeInt(classId);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:14,代码来源:InternalDataSerializer.java

示例10: write

import java.io.DataOutput; //导入方法依赖的package包/类
@Override
public void write(DataOutput out) throws IOException {
  out.writeShort(length);
  out.write(bytes, 0, length);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:6,代码来源:UTF8.java

示例11: writeShortArray

import java.io.DataOutput; //导入方法依赖的package包/类
private void writeShortArray(DataOutput out) throws IOException {
  short[] v = (short[]) value;
  for (int i = 0; i < length; i++)
    out.writeShort(v[i]);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:6,代码来源:ArrayPrimitiveWritable.java

示例12: write

import java.io.DataOutput; //导入方法依赖的package包/类
/**
 * Write the actual data contents of the tag, implemented in NBT extension classes
 */
void write(DataOutput output) throws IOException
{
    output.writeShort(this.data);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:8,代码来源:NBTTagShort.java

示例13: write

import java.io.DataOutput; //导入方法依赖的package包/类
@Override
protected void write(final DataOutput output) throws IOException {
  output.writeShort(this.value);
}
 
开发者ID:KyoriPowered,项目名称:nbt,代码行数:5,代码来源:ShortTag.java

示例14: write

import java.io.DataOutput; //导入方法依赖的package包/类
@Override
public void write(DataOutput out) throws IOException {
  out.writeShort(toShort());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:FsPermission.java

示例15: writeOrdinal

import java.io.DataOutput; //导入方法依赖的package包/类
/**
 * Write the given ordinal (result of {@link #ordinal()}) to given {@link DataOutput}. This keeps
 * the serialization of ordinal compatible with previous versions writing a single byte to
 * DataOutput when possible, and a token with 2 bytes if it is large.
 * 
 * @param out the {@link DataOutput} to write the ordinal write to
 * @param ordinal the version to be written
 * @param compressed if true, then use single byte for ordinal < 128, and three bytes for beyond
 *        that, else always use three bytes where the first byte is {@link #TOKEN_ORDINAL}; former
 *        mode is useful for interoperatibility with previous versions while latter to use fixed
 *        size for writing version; typically former will be used for P2P/client-server
 *        communications while latter for persisting to disk; we use the token to ensure that
 *        {@link #readOrdinal(DataInput)} can deal with both compressed/uncompressed cases
 *        seemlessly
 */
public static void writeOrdinal(DataOutput out, short ordinal, boolean compressed)
    throws IOException {
  if (compressed && ordinal <= Byte.MAX_VALUE) {
    out.writeByte(ordinal);
  } else {
    out.writeByte(TOKEN_ORDINAL);
    out.writeShort(ordinal);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:25,代码来源:Version.java


注:本文中的java.io.DataOutput.writeShort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。