Java Code Examples for java.io.DataOutput#writeInt()

The following examples show how to use java.io.DataOutput#writeInt() . 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: XmlStartElementChunk.java    From android-arscblamer with Apache License 2.0 6 votes vote down vote up
@Override
protected void writePayload(DataOutput output, ByteBuffer header, int options)
    throws IOException {
  super.writePayload(output, header, options);
  output.writeInt(namespace);
  output.writeInt(name);
  output.writeShort((short) XmlAttribute.SIZE);  // attribute start
  output.writeShort((short) XmlAttribute.SIZE);
  output.writeShort((short) attributes.size());
  output.writeShort((short) (idIndex + 1));
  output.writeShort((short) (classIndex + 1));
  output.writeShort((short) (styleIndex + 1));
  for (XmlAttribute attribute : attributes) {
    output.write(attribute.toByteArray(options));
  }
}
 
Example 2
Source File: JobStatus.java    From RDFS with Apache License 2.0 5 votes vote down vote up
public synchronized void write(DataOutput out) throws IOException {
  jobid.write(out);
  out.writeFloat(setupProgress);
  out.writeFloat(mapProgress);
  out.writeFloat(reduceProgress);
  out.writeFloat(cleanupProgress);
  out.writeInt(runState);
  out.writeLong(startTime);
  Text.writeString(out, user);
  WritableUtils.writeEnum(out, priority);
  Text.writeString(out, schedulingInfo);
}
 
Example 3
Source File: BridgeServerAdvisor.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
public void toData(DataOutput out) throws IOException {
  super.toData(out);
  DataSerializer.writeStringArray(this.groups, out);
  out.writeInt(maxConnections);
  InternalDataSerializer.invokeToData(initialLoad, out);
  out.writeLong(getLoadPollInterval());
}
 
Example 4
Source File: TVEditorial.java    From sagetv with Apache License 2.0 5 votes vote down vote up
void write(DataOutput out, int flags) throws IOException
{
  super.write(out, flags);
  boolean useLookupIdx = (flags & Wizard.WRITE_OPT_USE_ARRAY_INDICES) != 0;
  out.writeInt(showID);
  out.writeInt((title == null) ? 0 : (useLookupIdx ? title.lookupIdx : title.id));
  out.writeInt((network == null) ? 0 : (useLookupIdx ? network.lookupIdx : network.id));
  out.writeUTF(airdate);
  out.writeUTF(description);
  out.writeUTF(imageURL);
}
 
Example 5
Source File: IndexInfo.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void toData(DataOutput out) throws IOException
{
	out.writeInt(indexListSize);
	out.writeInt(indexMapSize);
	out.writeInt(minSetSize);
	out.writeInt(maxSetSize);
	DataSerializer.writeObject(minSetQueryKey, out);
	DataSerializer.writeObject(maxSetQueryKey, out);
}
 
Example 6
Source File: SerialVersionUIDAdder.java    From Concurnas with MIT License 5 votes vote down vote up
/**
 * Sorts the items in the collection and writes it to the given output stream.
 *
 * @param itemCollection a collection of items.
 * @param dataOutputStream where the items must be written.
 * @param dotted whether package names must use dots, instead of slashes.
 * @exception IOException if an error occurs.
 */
private static void writeItems(
    final Collection<Item> itemCollection,
    final DataOutput dataOutputStream,
    final boolean dotted)
    throws IOException {
  Item[] items = itemCollection.toArray(new Item[0]);
  Arrays.sort(items);
  for (Item item : items) {
    dataOutputStream.writeUTF(item.name);
    dataOutputStream.writeInt(item.access);
    dataOutputStream.writeUTF(dotted ? item.descriptor.replace('/', '.') : item.descriptor);
  }
}
 
Example 7
Source File: jMutRepair_0019_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Millisecond encoding formats:
 *
 * upper two bits  units       field length  approximate range
 * ---------------------------------------------------------------
 * 00              30 minutes  1 byte        +/- 16 hours
 * 01              minutes     4 bytes       +/- 1020 years
 * 10              seconds     5 bytes       +/- 4355 years
 * 11              millis      9 bytes       +/- 292,000,000 years
 *
 * Remaining bits in field form signed offset from 1970-01-01T00:00:00Z.
 */
static void writeMillis(DataOutput out, long millis) throws IOException {
    if (millis % (30 * 60000L) == 0) {
        // Try to write in 30 minute units.
        long units = millis / (30 * 60000L);
        if (((units << (64 - 6)) >> (64 - 6)) == units) {
            // Form 00 (6 bits effective precision)
            out.writeByte((int)(units & 0x3f));
            return;
        }
    }

    if (millis % 60000L == 0) {
        // Try to write minutes.
        long minutes = millis / 60000L;
        if (((minutes << (64 - 30)) >> (64 - 30)) == minutes) {
            // Form 01 (30 bits effective precision)
            out.writeInt(0x40000000 | (int)(minutes & 0x3fffffff));
            return;
        }
    }
    
    if (millis % 1000L == 0) {
        // Try to write seconds.
        long seconds = millis / 1000L;
        if (((seconds << (64 - 38)) >> (64 - 38)) == seconds) {
            // Form 10 (38 bits effective precision)
            out.writeByte(0x80 | (int)((seconds >> 32) & 0x3f));
            out.writeInt((int)(seconds & 0xffffffff));
            return;
        }
    }

    // Write milliseconds either because the additional precision is
    // required or the minutes didn't fit in the field.
    
    // Form 11 (64 bits effective precision, but write as if 70 bits)
    out.writeByte(millis < 0 ? 0xff : 0xc0);
    out.writeLong(millis);
}
 
Example 8
Source File: ColGroupUncompressed.java    From systemds with Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
	// write col contents first (w/ meta data)
	_data.write(out);

	// write col indices
	int len = _data.getNumColumns();
	for(int i = 0; i < len; i++)
		out.writeInt(_colIndexes[i]);
}
 
Example 9
Source File: StandardModuleData.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void writeFiles(DataOutput os, Set<File> files) throws IOException {
    if (files == null) {
        os.writeInt(0);
        return;
    }
    os.writeInt(files.size());
    for (File f : files) {
        Stamps.writeRelativePath(f.getPath(), os);
    }
}
 
Example 10
Source File: QuarterPartitionResolver.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void toData(DataOutput out) throws IOException {
  DataSerializer.writeProperties(this.resolveProps, out);
  out.writeInt(this.numBuckets);
  
}
 
Example 11
Source File: LocatedBlocksWithMetaInfo.java    From RDFS with Apache License 2.0 4 votes vote down vote up
public void write(DataOutput out) throws IOException {
  out.writeInt(this.namespaceid);
  out.writeInt(this.methodFingerPrint);
  super.write(out);
}
 
Example 12
Source File: IntWritable.java    From DataVec with Apache License 2.0 4 votes vote down vote up
public void write(DataOutput out) throws IOException {
    out.writeInt(value);
}
 
Example 13
Source File: InstantiatorPropogationDUnitTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void toData(DataOutput out) throws IOException {
  out.writeInt(this.field1);
}
 
Example 14
Source File: TestMRInputSplitDistributor.java    From tez with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
  out.writeInt(identifier);
}
 
Example 15
Source File: BloomFilterSerializer.java    From ambry with Apache License 2.0 4 votes vote down vote up
public void serialize(BloomFilter bf, DataOutput out) throws IOException {
  out.writeInt(bf.hashCount);
  bf.bitset.serialize(out);
}
 
Example 16
Source File: Period.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
void writeExternal(DataOutput out) throws IOException {
    out.writeInt(years);
    out.writeInt(months);
    out.writeInt(days);
}
 
Example 17
Source File: Period.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
void writeExternal(DataOutput out) throws IOException {
    out.writeInt(years);
    out.writeInt(months);
    out.writeInt(days);
}
 
Example 18
Source File: ZoneRules.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes the state of the transition rule to the stream.
 *
 * @param rule  the transition rule, not null
 * @param out  the output stream, not null
 * @throws IOException if an error occurs
 */
static void writeRule(ZoneOffsetTransitionRule rule, DataOutput out) throws IOException {
    int month = rule.month;
    byte dom = rule.dom;
    int dow = rule.dow;
    LocalTime time = rule.time;
    boolean timeEndOfDay = rule.timeEndOfDay;
    TimeDefinition timeDefinition = rule.timeDefinition;
    ZoneOffset standardOffset = rule.standardOffset;
    ZoneOffset offsetBefore = rule.offsetBefore;
    ZoneOffset offsetAfter = rule.offsetAfter;

    int timeSecs = (timeEndOfDay ? 86400 : time.toSecondOfDay());
    int stdOffset = standardOffset.getTotalSeconds();
    int beforeDiff = offsetBefore.getTotalSeconds() - stdOffset;
    int afterDiff = offsetAfter.getTotalSeconds() - stdOffset;
    int timeByte = (timeSecs % 3600 == 0 ? (timeEndOfDay ? 24 : time.getHour()) : 31);
    int stdOffsetByte = (stdOffset % 900 == 0 ? stdOffset / 900 + 128 : 255);
    int beforeByte = (beforeDiff == 0 || beforeDiff == 1800 || beforeDiff == 3600 ? beforeDiff / 1800 : 3);
    int afterByte = (afterDiff == 0 || afterDiff == 1800 || afterDiff == 3600 ? afterDiff / 1800 : 3);
    int dowByte = (dow == -1 ? 0 : dow);
    int b = (month << 28) +                     // 4 bytes
            ((dom + 32) << 22) +                // 6 bytes
            (dowByte << 19) +                   // 3 bytes
            (timeByte << 14) +                  // 5 bytes
            (timeDefinition.ordinal() << 12) +  // 2 bytes
            (stdOffsetByte << 4) +              // 8 bytes
            (beforeByte << 2) +                 // 2 bytes
            afterByte;                          // 2 bytes
    out.writeInt(b);
    if (timeByte == 31) {
        out.writeInt(timeSecs);
    }
    if (stdOffsetByte == 255) {
        out.writeInt(stdOffset);
    }
    if (beforeByte == 3) {
        out.writeInt(offsetBefore.getTotalSeconds());
    }
    if (afterByte == 3) {
        out.writeInt(offsetAfter.getTotalSeconds());
    }
}
 
Example 19
Source File: BinaryWritable.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutput output) throws IOException {
  output.writeInt(binary.length());
  binary.writeTo(output);
}
 
Example 20
Source File: EvictionAttributesImpl.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void toData(DataOutput out) throws IOException {
  out.writeInt(this.maximum);
  DataSerializer.writeObject(this.action, out);
  DataSerializer.writeObject(this.algorithm, out);
}