java.io.DataOutput#writeShort ( )源码实例Demo

下面列出了java.io.DataOutput#writeShort ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hadoop   文件: FSImageSerialization.java
/**
 * 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);
}
 
源代码2 项目: hadoop-gpu   文件: HeartbeatResponse.java
public void write(DataOutput out) throws IOException {
  out.writeShort(responseId);
  out.writeInt(heartbeatInterval);
  if (actions == null) {
    WritableUtils.writeVInt(out, 0);
  } else {
    WritableUtils.writeVInt(out, actions.length);
    for (TaskTrackerAction action : actions) {
      WritableUtils.writeEnum(out, action.getActionId());
      action.write(out);
    }
  }
  // Write the job ids of the jobs that were recovered
  out.writeInt(recoveredJobs.size());
  for (JobID id : recoveredJobs) {
    id.write(out);
  }
}
 
源代码3 项目: PalDB   文件: StorageSerialization.java
private static void serializeShort(final DataOutput out, final short val)
    throws IOException {
  if (val == -1) {
    out.write(SHORT_MINUS_1);
  } else if (val == 0) {
    out.write(SHORT_0);
  } else if (val == 1) {
    out.write(SHORT_1);
  } else if (val > 0 && val < 255) {
    out.write(SHORT_255);
    out.write(val);
  } else {
    out.write(SHORT_FULL);
    out.writeShort(val);
  }
}
 
源代码4 项目: vxquery   文件: CastToDateOperation.java
@Override
public void convertDatetime(XSDateTimePointable datetimep, DataOutput dOut) throws SystemException, IOException {
    dOut.write(ValueTag.XS_DATE_TAG);
    dOut.writeShort((short) datetimep.getYear());
    dOut.write((byte) datetimep.getMonth());
    dOut.write((byte) datetimep.getDay());
    dOut.write((byte) datetimep.getTimezoneHour());
    dOut.write((byte) datetimep.getTimezoneMinute());
}
 
源代码5 项目: gemfirexd-oss   文件: GossipData.java
public void toDataPre_GFE_7_5_0_0(DataOutput out) throws IOException {
  out.writeInt(type);
  if (type == GEMFIRE_VERSION) {
    out.writeShort(versionOrdinal);
  } else {
    out.writeUTF(group == null ? "" : group);
    JChannel.getGfFunctions().writeObject(mbr, out);
    JChannel.getGfFunctions().writeObject(mbrs, out);
    //DataSerializer.writeObject(this.locators, out);
    out.writeBoolean(hasDistributedSystem);
    out.writeBoolean(this.floatingCoordinatorDisabled);
    out.writeBoolean(this.networkPartitionDetectionEnabled);
  }
}
 
源代码6 项目: gemfirexd-oss   文件: DataSerializer.java
/**
 * 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 (DEBUG) {
    InternalDataSerializer.logger.info( LocalizedStrings.DEBUG, "Writing Short " + value);
  }

  out.writeShort(value.shortValue());
}
 
源代码7 项目: gemfirexd-oss   文件: DistributedCacheOperation.java
@Override
public void toData(DataOutput out) throws IOException {
  super.toData(out);
  // extra short added for 7.5
  Version version = InternalDataSerializer
          .getVersionForDataStreamOrNull(out);
  if (version == null || Version.GFE_75.compareTo(version) <= 0) {
    short extBits = computeCompressedExtBits((short) 0);
    out.writeShort(extBits);
  }
  DataSerializer.writeString(this.regionPath, out);
  out.writeByte(this.op.ordinal);
  if (this.callbackArg != null) {
    DataSerializer.writeObject(this.callbackArg, out);
  }
  if (this.hasOldValue) {
    out.writeByte(this.oldValueIsObject);
    final byte policy = valueIsToDeserializationPolicy(this.oldValueIsObject);
    final Object vObj;
    final byte[] vBytes;
    if (this.oldValueIsObject == VALUE_IS_BYTES && this.oldValue instanceof byte[]) {
      vObj = null;
      vBytes = (byte[])this.oldValue;
    } else {
      vObj = this.oldValue;
      vBytes = null;
    }
    writeValue(policy, vObj, vBytes, out);
  }
  if (this.filterRouting != null) {
    InternalDataSerializer.invokeToData(this.filterRouting, out);
  }
  if (this.versionTag != null) {
    InternalDataSerializer.invokeToData(this.versionTag,out);
  }
}
 
源代码8 项目: big-c   文件: FSImageSerialization.java
/** Serialize an {@link INodeFileAttributes}. */
public static void writeINodeFileAttributes(INodeFileAttributes file,
    DataOutput out) throws IOException {
  writeLocalName(file, out);
  writePermissionStatus(file, out);
  out.writeLong(file.getModificationTime());
  out.writeLong(file.getAccessTime());

  out.writeShort(file.getFileReplication());
  out.writeLong(file.getPreferredBlockSize());
}
 
源代码9 项目: PalDB   文件: StorageSerialization.java
private static void serializeShortArray(final DataOutput out, final short[] val, boolean compress)
    throws IOException {
  if (compress && val.length > 250) {
    out.write(SHORT_ARRAY_C);
    byte[] b = Snappy.compress(val);
    LongPacker.packInt(out, b.length);
    out.write(b);
  } else {
    out.write(SHORT_ARRAY);
    LongPacker.packInt(out, val.length);
    for (short s : val) {
      out.writeShort(s);
    }
  }
}
 
源代码10 项目: vxquery   文件: CastToShortOperation.java
@Override
public void convertString(UTF8StringPointable stringp, DataOutput dOut) throws SystemException, IOException {
    ICharacterIterator charIterator = new UTF8StringCharacterIterator(stringp);
    charIterator.reset();
    long value = 0;
    int c = 0;
    boolean negative = false;
    long limit = -Short.MAX_VALUE;

    // Check the first character.
    c = charIterator.next();
    if (c == Character.valueOf('-') && negativeAllowed) {
        negative = true;
        c = charIterator.next();
        limit = Short.MIN_VALUE;
    }

    // Read the numeric value.
    do {
        if (Character.isDigit(c)) {
            if (value < limit + Character.getNumericValue(c)) {
                throw new SystemException(ErrorCode.FORG0001);
            }
            value = value * 10 - Character.getNumericValue(c);
        } else {
            throw new SystemException(ErrorCode.FORG0001);
        }
    } while ((c = charIterator.next()) != ICharacterIterator.EOS_CHAR);

    dOut.write(returnTag);
    dOut.writeShort((short) (negative ? value : -value));
}
 
源代码11 项目: vxquery   文件: CastToGYearOperation.java
@Override
public void convertString(UTF8StringPointable stringp, DataOutput dOut) throws SystemException, IOException {
    ICharacterIterator charIterator = new UTF8StringCharacterIterator(stringp);
    charIterator.reset();
    int c;
    int index = 0;
    long[] date = new long[3];
    boolean positiveTimezone = false;
    boolean negativeYear = false;

    // Set defaults
    date[1] = DateTime.TIMEZONE_HOUR_NULL;
    date[2] = DateTime.TIMEZONE_MINUTE_NULL;

    while ((c = charIterator.next()) != ICharacterIterator.EOS_CHAR) {
        if (Character.isDigit(c)) {
            // Add the digit to the current numbered index.
            date[index] = date[index] * 10 + Character.getNumericValue(c);
        } else if (c == Character.valueOf('-') && index == 0 && date[index] == 0) {
            // If the first dash does not have a number in front, its a negative year.
            negativeYear = true;
        } else if (c == Character.valueOf('-') || c == Character.valueOf(':')) {
            // The basic case for going to the next number in the series.
            ++index;
            date[index] = 0;
        } else if (c == Character.valueOf('+')) {
            // Moving to the next number and logging this is now a positive timezone offset.
            ++index;
            date[index] = 0;
            positiveTimezone = true;
        } else if (c == Character.valueOf('Z')) {
            // Set the timezone to UTC.
            date[1] = 0;
            date[2] = 0;
        } else {
            // Invalid date format.
            throw new SystemException(ErrorCode.FORG0001);
        }
    }
    // Final touches on year and timezone.
    if (negativeYear) {
        date[0] *= -1;
    }
    if (!positiveTimezone && date[1] != DateTime.TIMEZONE_HOUR_NULL) {
        date[1] *= -1;
    }
    if (!positiveTimezone && date[2] != DateTime.TIMEZONE_MINUTE_NULL) {
        date[2] *= -1;
    }
    if (!DateTime.valid(date[0], 1, 1, 0, 0, 0, date[1], date[2])) {
        throw new SystemException(ErrorCode.FODT0001);
    }

    dOut.write(ValueTag.XS_G_YEAR_TAG);
    dOut.writeShort((short) date[0]);
    dOut.write((byte) 1);
    dOut.write((byte) 1);
    dOut.write((byte) date[1]);
    dOut.write((byte) date[2]);
}
 
源代码12 项目: spliceengine   文件: FormatIdUtil.java
public static void writeFormatIdInteger(DataOutput out, int formatId) throws IOException {
	out.writeShort(formatId);
}
 
源代码13 项目: coming   文件: Elixir_0038_t.java
public void writeTo(DataOutput out) throws IOException {
    int size = iTransitions.length;

    // Create unique string pool.
    Set<String> poolSet = new HashSet<String>();
    for (int i=0; i<size; i++) {
        poolSet.add(iNameKeys[i]);
    }

    int poolSize = poolSet.size();
    if (poolSize > 65535) {
        throw new UnsupportedOperationException("String pool is too large");
    }
    String[] pool = new String[poolSize];
    Iterator<String> it = poolSet.iterator();
    for (int i=0; it.hasNext(); i++) {
        pool[i] = it.next();
    }

    // Write out the pool.
    out.writeShort(poolSize);
    for (int i=0; i<poolSize; i++) {
        out.writeUTF(pool[i]);
    }

    out.writeInt(size);

    for (int i=0; i<size; i++) {
        writeMillis(out, iTransitions[i]);
        writeMillis(out, iWallOffsets[i]);
        writeMillis(out, iStandardOffsets[i]);
        
        // Find pool index and write it out.
        String nameKey = iNameKeys[i];
        for (int j=0; j<poolSize; j++) {
            if (pool[j].equals(nameKey)) {
                if (poolSize < 256) {
                    out.writeByte(j);
                } else {
                    out.writeShort(j);
                }
                break;
            }
        }
    }

    out.writeBoolean(iTailZone != null);
    if (iTailZone != null) {
        iTailZone.writeTo(out);
    }
}
 
源代码14 项目: gemfirexd-oss   文件: FormatIdUtil.java
public static void writeFormatIdInteger(DataOutput out, int formatId) throws IOException {
	out.writeShort(formatId);
}
 
源代码15 项目: coming   文件: jKali_0040_t.java
public void writeTo(DataOutput out) throws IOException {
    int size = iTransitions.length;

    // Create unique string pool.
    Set<String> poolSet = new HashSet<String>();
    for (int i=0; i<size; i++) {
        poolSet.add(iNameKeys[i]);
    }

    int poolSize = poolSet.size();
    if (poolSize > 65535) {
        throw new UnsupportedOperationException("String pool is too large");
    }
    String[] pool = new String[poolSize];
    Iterator<String> it = poolSet.iterator();
    for (int i=0; it.hasNext(); i++) {
        pool[i] = it.next();
    }

    // Write out the pool.
    out.writeShort(poolSize);
    for (int i=0; i<poolSize; i++) {
        out.writeUTF(pool[i]);
    }

    out.writeInt(size);

    for (int i=0; i<size; i++) {
        writeMillis(out, iTransitions[i]);
        writeMillis(out, iWallOffsets[i]);
        writeMillis(out, iStandardOffsets[i]);
        
        // Find pool index and write it out.
        String nameKey = iNameKeys[i];
        for (int j=0; j<poolSize; j++) {
            if (pool[j].equals(nameKey)) {
                if (poolSize < 256) {
                    out.writeByte(j);
                } else {
                    out.writeShort(j);
                }
                break;
            }
        }
    }

    out.writeBoolean(iTailZone != null);
    if (iTailZone != null) {
        iTailZone.writeTo(out);
    }
}
 
源代码16 项目: coming   文件: jKali_0051_t.java
public void writeTo(DataOutput out) throws IOException {
    int size = iTransitions.length;

    // Create unique string pool.
    Set<String> poolSet = new HashSet<String>();
    for (int i=0; i<size; i++) {
        poolSet.add(iNameKeys[i]);
    }

    int poolSize = poolSet.size();
    if (poolSize > 65535) {
        throw new UnsupportedOperationException("String pool is too large");
    }
    String[] pool = new String[poolSize];
    Iterator<String> it = poolSet.iterator();
    for (int i=0; it.hasNext(); i++) {
        pool[i] = it.next();
    }

    // Write out the pool.
    out.writeShort(poolSize);
    for (int i=0; i<poolSize; i++) {
        out.writeUTF(pool[i]);
    }

    out.writeInt(size);

    for (int i=0; i<size; i++) {
        writeMillis(out, iTransitions[i]);
        writeMillis(out, iWallOffsets[i]);
        writeMillis(out, iStandardOffsets[i]);
        
        // Find pool index and write it out.
        String nameKey = iNameKeys[i];
        for (int j=0; j<poolSize; j++) {
            if (pool[j].equals(nameKey)) {
                if (poolSize < 256) {
                    out.writeByte(j);
                } else {
                    out.writeShort(j);
                }
                break;
            }
        }
    }

    out.writeBoolean(iTailZone != null);
    if (iTailZone != null) {
        iTailZone.writeTo(out);
    }
}
 
源代码17 项目: deeplearning4j   文件: LongWritable.java
@Override
public void writeType(DataOutput out) throws IOException {
    out.writeShort(WritableType.Long.typeIdx());
}
 
源代码18 项目: coming   文件: Arja_00110_s.java
public void writeTo(DataOutput out) throws IOException {
    int size = iTransitions.length;

    // Create unique string pool.
    Set<String> poolSet = new HashSet<String>();
    for (int i=0; i<size; i++) {
        poolSet.add(iNameKeys[i]);
    }

    int poolSize = poolSet.size();
    if (poolSize > 65535) {
        throw new UnsupportedOperationException("String pool is too large");
    }
    String[] pool = new String[poolSize];
    Iterator<String> it = poolSet.iterator();
    for (int i=0; it.hasNext(); i++) {
        pool[i] = it.next();
    }

    // Write out the pool.
    out.writeShort(poolSize);
    for (int i=0; i<poolSize; i++) {
        out.writeUTF(pool[i]);
    }

    out.writeInt(size);

    for (int i=0; i<size; i++) {
        writeMillis(out, iTransitions[i]);
        writeMillis(out, iWallOffsets[i]);
        writeMillis(out, iStandardOffsets[i]);
        
        // Find pool index and write it out.
        String nameKey = iNameKeys[i];
        for (int j=0; j<poolSize; j++) {
            if (pool[j].equals(nameKey)) {
                if (poolSize < 256) {
                    out.writeByte(j);
                } else {
                    out.writeShort(j);
                }
                break;
            }
        }
    }

    out.writeBoolean(iTailZone != null);
    if (iTailZone != null) {
        iTailZone.writeTo(out);
    }
}
 
源代码19 项目: deeplearning4j   文件: ImageWritable.java
@Override
public void writeType(DataOutput out) throws IOException {
    out.writeShort(WritableType.Image.typeIdx());
}
 
源代码20 项目: JDKSourceCode1.8   文件: UID.java
/**
 * Marshals a binary representation of this <code>UID</code> to
 * a <code>DataOutput</code> instance.
 *
 * <p>Specifically, this method first invokes the given stream's
 * {@link DataOutput#writeInt(int)} method with this <code>UID</code>'s
 * <code>unique</code> value, then it invokes the stream's
 * {@link DataOutput#writeLong(long)} method with this <code>UID</code>'s
 * <code>time</code> value, and then it invokes the stream's
 * {@link DataOutput#writeShort(int)} method with this <code>UID</code>'s
 * <code>count</code> value.
 *
 * @param   out the <code>DataOutput</code> instance to write
 * this <code>UID</code> to
 *
 * @throws  IOException if an I/O error occurs while performing
 * this operation
 */
public void write(DataOutput out) throws IOException {
    out.writeInt(unique);
    out.writeLong(time);
    out.writeShort(count);
}