Java Code Examples for java.io.DataOutput#writeLong()
The following examples show how to use
java.io.DataOutput#writeLong() .
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: TestStateStorage.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private static ThrowableComputable<PersistentHashMap<String, Record>, IOException> getComputable(final File file) { return () -> new PersistentHashMap<>(file, EnumeratorStringDescriptor.INSTANCE, new DataExternalizer<Record>() { @Override public void save(@Nonnull DataOutput out, Record value) throws IOException { out.writeInt(value.magnitude); out.writeLong(value.date.getTime()); out.writeLong(value.configurationHash); } @Override public Record read(@Nonnull DataInput in) throws IOException { return new Record(in.readInt(), new Date(in.readLong()), in.readLong()); } }, 4096, CURRENT_VERSION); }
Example 2
Source File: DatanodeInfo.java From RDFS with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ public void write(DataOutput out) throws IOException { super.write(out); //TODO: move it to DatanodeID once DatanodeID is not stored in FSImage out.writeShort(ipcPort); out.writeLong(capacity); out.writeLong(dfsUsed); out.writeLong(remaining); out.writeLong(lastUpdate); out.writeInt(xceiverCount); Text.writeString(out, location); Text.writeString(out, hostName == null? "": hostName); WritableUtils.writeEnum(out, getAdminState()); }
Example 3
Source File: FSImageSerialization.java From hadoop with Apache License 2.0 | 5 votes |
/** 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()); }
Example 4
Source File: JGenProg2017_00122_t.java From coming with MIT License | 5 votes |
/** * 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 5
Source File: CountingBloomFilter.java From big-c with Apache License 2.0 | 5 votes |
@Override public void write(DataOutput out) throws IOException { super.write(out); int sizeInWords = buckets2words(vectorSize); for(int i = 0; i < sizeInWords; i++) { out.writeLong(buckets[i]); } }
Example 6
Source File: Ser.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Writes the state to the stream. * * @param epochSec the epoch seconds, not null * @param out the output stream, not null * @throws IOException if an error occurs */ static void writeEpochSec(long epochSec, DataOutput out) throws IOException { if (epochSec >= -4575744000L && epochSec < 10413792000L && epochSec % 900 == 0) { // quarter hours between 1825 and 2300 int store = (int) ((epochSec + 4575744000L) / 900); out.writeByte((store >>> 16) & 255); out.writeByte((store >>> 8) & 255); out.writeByte(store & 255); } else { out.writeByte(255); out.writeLong(epochSec); } }
Example 7
Source File: GfxdDDLMessage.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
@Override public void toData(final DataOutput out) throws IOException { super.toData(out); DataSerializer.writePrimitiveByte(this.flags, out); out.writeLong(this.connId); out.writeLong(this.id); InternalDataSerializer.invokeToData(this.ddl, out); }
Example 8
Source File: GfxdJarMessage.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
@Override public void toData(DataOutput out) throws IOException { super.toData(out); if (GemFireXDUtils.TraceApplicationJars) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_APP_JARS, "GfxdJarMessage#toData: this.sendBytes " + this.sendBytes + " and jar bytes " + Arrays.toString(this.jar_bytes)); } out.writeLong(this.id); DataSerializer.writeString(this.schemaName, out); DataSerializer.writeString(this.sqlName, out); DataSerializer.writeByte((byte)this.type, out); if (this.type != JAR_REMOVE) { if (this.sendBytes) { if (GemFireXDUtils.TraceApplicationJars) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_APP_JARS, "GfxdJarMessage#toData: writing byte array " + Arrays.toString(this.jar_bytes)); } DataSerializer.writeByteArray(this.jar_bytes, out); } else { if (GemFireXDUtils.TraceApplicationJars) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_APP_JARS, "GfxdJarMessage#toData: sending null jar bytes " + Arrays.toString(this.jar_bytes)); } DataSerializer.writeByteArray(null, out); } DataSerializer.writeLong(this.oldId, out); } }
Example 9
Source File: Ext2Node.java From birt with Eclipse Public License 1.0 | 5 votes |
void write( DataOutput out ) throws IOException { out.writeInt( status ); out.writeLong( length ); out.writeInt( blockCount ); for ( int i = 0; i < DIRECT_BLOCK_COUNT; i++ ) { out.writeInt( directBlocks[i] ); } for ( int i = 0; i < INDIRECT_BLOCK_COUNT; i++ ) { out.writeInt( indirectBlocks[i] ); } }
Example 10
Source File: WireCommandsTest.java From pravega with Apache License 2.0 | 5 votes |
@Override public void writeFields(DataOutput out) throws IOException { out.writeLong(writerId.getMostSignificantBits()); out.writeLong(writerId.getLeastSignificantBits()); out.writeLong(eventNumber); out.writeLong(expectedOffset); event.writeFields(out); }
Example 11
Source File: Cardumen_0069_t.java From coming with MIT License | 5 votes |
/** * 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 12
Source File: FastAssetAccount.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void toData(DataOutput out) throws IOException { out.writeInt(this.acctId); DataSerializer.writeString(this.customerName, out); out.writeDouble(this.netWorth); DataSerializer.writeHashMap((HashMap)this.assets, out); out.writeLong(this.timestamp); if (fineEnabled) { Log.getLogWriter().fine("INVOKED: toData on key " + this.acctId); } }
Example 13
Source File: WireCommands.java From pravega with Apache License 2.0 | 5 votes |
@Override public void writeFields(DataOutput out) throws IOException { out.writeLong(requestId); out.writeUTF(segment); out.writeUTF(delegationToken == null ? "" : delegationToken); out.writeInt(suggestedEntryCount); out.writeInt(continuationToken.readableBytes()); // continuation token length. if (continuationToken.readableBytes() != 0) { continuationToken.getBytes(continuationToken.readerIndex(), (OutputStream) out, continuationToken.readableBytes()); } }
Example 14
Source File: LockInfoSerializer.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void write(DataOutput dataOutput, LockInfo lockInfo) throws IOException { dataOutput.writeInt(lockInfo.port); dataOutput.writeLong(lockInfo.lockId); dataOutput.writeUTF(trimIfNecessary(lockInfo.pid)); dataOutput.writeUTF(trimIfNecessary(lockInfo.operation)); }
Example 15
Source File: PluginWrapper.java From sagetv with Apache License 2.0 | 4 votes |
public void writeToObjectStream(DataOutput dataOut) throws java.io.IOException { dataOut.writeUTF(name == null ? "" : name); dataOut.writeUTF(id == null ? "" : id); dataOut.writeUTF(desc == null ? "" : desc); dataOut.writeUTF(type == null ? "" : type); dataOut.writeInt(screenshotURLs == null ? 0 : screenshotURLs.size()); for (int i = 0; screenshotURLs != null && i < screenshotURLs.size(); i++) dataOut.writeUTF(screenshotURLs.get(i).toString()); dataOut.writeInt(demoVideoURLs == null ? 0 : demoVideoURLs.size()); for (int i = 0; demoVideoURLs != null && i < demoVideoURLs.size(); i++) dataOut.writeUTF(demoVideoURLs.get(i).toString()); dataOut.writeUTF(author == null ? "" : author); dataOut.writeLong(createDate); dataOut.writeLong(modDate); dataOut.writeLong(installDate); dataOut.writeUTF(version == null ? "" : version); dataOut.writeUTF(resPath == null ? "" : resPath); dataOut.writeInt(webpages == null ? 0 : webpages.size()); for (int i = 0; webpages != null && i < webpages.size(); i++) dataOut.writeUTF(webpages.get(i).toString()); dataOut.writeUTF(implClass == null ? "" : implClass); dataOut.writeBoolean(desktopOnly); dataOut.writeBoolean(serverOnly); dataOut.writeBoolean(winOK); dataOut.writeBoolean(linuxOK); dataOut.writeBoolean(macOK); dataOut.writeInt(dependencies == null ? 0 : dependencies.size()); for (int i = 0; dependencies != null && i < dependencies.size(); i++) { Dependency dep = (Dependency) dependencies.get(i); dataOut.writeUTF(dep.id == null ? "" : dep.id); dataOut.writeUTF(dep.minVersion == null ? "" : dep.minVersion); dataOut.writeUTF(dep.maxVersion == null ? "" : dep.maxVersion); dataOut.writeUTF(dep.type == null ? "" : dep.type); } dataOut.writeInt(packages == null ? 0 : packages.size()); for (int i = 0; packages != null && i < packages.size(); i++) { Package pack = (Package) packages.get(i); dataOut.writeUTF(pack.type == null ? "" : pack.type); dataOut.writeUTF(pack.url == null ? "" : pack.url); dataOut.writeUTF(pack.rawMD5 == null ? "" : pack.rawMD5); dataOut.writeBoolean(pack.overwrite); } dataOut.writeInt(state); dataOut.writeInt(installIndex); dataOut.writeInt(stvImports == null ? 0 : stvImports.size()); for (int i = 0; stvImports != null && i < stvImports.size(); i++) dataOut.writeUTF(stvImports.get(i).toString()); dataOut.writeBoolean(beta); dataOut.writeUTF(releaseNotes == null ? "" : releaseNotes); }
Example 16
Source File: WireCommandsTest.java From pravega with Apache License 2.0 | 4 votes |
@Override public void writeFields(DataOutput out) throws IOException { out.writeLong(writerId.getMostSignificantBits()); out.writeLong(writerId.getLeastSignificantBits()); out.writeLong(eventNumber); }
Example 17
Source File: MyObjectDataSerializable.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
@Override public void toData(DataOutput out) throws IOException { out.writeLong(f1); out.writeUTF(f2); }
Example 18
Source File: WireCommands.java From pravega with Apache License 2.0 | 4 votes |
@Override public void writeFields(DataOutput out) throws IOException { out.writeLong(requestId); out.writeUTF(segment); out.writeUTF(serverStackTrace); }
Example 19
Source File: TrackExceptionCodec.java From lavaplayer with Apache License 2.0 | 4 votes |
@Override public void encode(DataOutput out, TrackExceptionMessage message) throws IOException { out.writeLong(message.executorId); ExceptionTools.encodeException(out, message.exception); }
Example 20
Source File: Instant.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
void writeExternal(DataOutput out) throws IOException { out.writeLong(seconds); out.writeInt(nanos); }