本文整理汇总了Java中com.intellij.util.io.DataInputOutputUtil.writeINT方法的典型用法代码示例。如果您正苦于以下问题:Java DataInputOutputUtil.writeINT方法的具体用法?Java DataInputOutputUtil.writeINT怎么用?Java DataInputOutputUtil.writeINT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.io.DataInputOutputUtil
的用法示例。
在下文中一共展示了DataInputOutputUtil.writeINT方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveToFile
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
private void saveToFile(@NotNull T instance) throws IOException {
FileOutputStream fileOutputStream = new FileOutputStream(myFile, true);
DataOutputStream output = new DataOutputStream(new BufferedOutputStream(fileOutputStream));
try {
if (myFile.length() == 0) {
DataInputOutputUtil.writeTIME(output, FSRecords.getCreationTimestamp());
DataInputOutputUtil.writeINT(output, myVersion);
}
myKeyDescriptor.save(output, instance);
} finally {
try {
output.close();
fileOutputStream.getFD().sync();
} catch (IOException ignore) {}
}
}
示例2: save
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
@Override
public void save(@NotNull DataOutput out, TIntArrayList list) throws IOException {
if (list.size() == 2) {
DataInputOutputUtil.writeINT(out, list.getQuick(0));
DataInputOutputUtil.writeINT(out, list.getQuick(1));
}
else {
DataInputOutputUtil.writeINT(out, -list.size());
int prev = 0;
for (int i = 0, len = list.size(); i < len; i+=2) {
int value = list.getQuick(i);
DataInputOutputUtil.writeINT(out, value - prev);
prev = value;
DataInputOutputUtil.writeINT(out, list.getQuick(i + 1));
}
}
}
示例3: save
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
@Override
public void save(@NotNull final DataOutput out, @NotNull final StubIdList value) throws IOException {
int size = value.size();
if (size == 0) {
DataInputOutputUtil.writeINT(out, Integer.MAX_VALUE);
}
else if (size == 1) {
DataInputOutputUtil.writeINT(out, value.get(0)); // most often case
}
else {
DataInputOutputUtil.writeINT(out, -size);
for(int i = 0; i < size; ++i) {
DataInputOutputUtil.writeINT(out, value.get(i));
}
}
}
示例4: saveTo
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
@Override
public void saveTo(DataOutput out, DataExternalizer<Value> externalizer) throws IOException {
if (needsCompacting()) {
getMergedData().saveTo(out, externalizer);
} else {
final TIntHashSet set = myInvalidated;
if (set != null && set.size() > 0) {
for (int inputId : set.toArray()) {
DataInputOutputUtil.writeINT(out, -inputId); // mark inputId as invalid, to be processed on load in ValueContainerImpl.readFrom
}
}
final ValueContainer<Value> toAppend = getAddedDelta();
if (toAppend != null && toAppend.size() > 0) {
toAppend.saveTo(out, externalizer);
}
}
}
示例5: writeChange
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
public static void writeChange(DataOutput out, Change change) throws IOException {
int id = -1;
Class c = change.getClass();
if (c.equals(CreateFileChange.class)) id = 1;
if (c.equals(CreateDirectoryChange.class)) id = 2;
if (c.equals(ContentChange.class)) id = 3;
if (c.equals(RenameChange.class)) id = 4;
if (c.equals(ROStatusChange.class)) id = 5;
if (c.equals(MoveChange.class)) id = 6;
if (c.equals(DeleteChange.class)) id = 7;
if (c.equals(PutLabelChange.class)) id = 8;
if (c.equals(PutSystemLabelChange.class)) id = 9;
if (id == -1) throw new IOException("unexpected change type: " + c);
DataInputOutputUtil.writeINT(out, id);
change.write(out);
}
示例6: persistAttribute
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
@Override
public void persistAttribute(@NotNull VirtualFile fileOrDir, @NotNull LanguageLevel level) throws IOException {
final DataInputStream iStream = PERSISTENCE.readAttribute(fileOrDir);
if (iStream != null) {
try {
final int oldLevelOrdinal = DataInputOutputUtil.readINT(iStream);
if (oldLevelOrdinal == level.ordinal()) return;
}
finally {
iStream.close();
}
}
final DataOutputStream oStream = PERSISTENCE.writeAttribute(fileOrDir);
DataInputOutputUtil.writeINT(oStream, level.ordinal());
oStream.close();
for (VirtualFile child : fileOrDir.getChildren()) {
if (!child.isDirectory() && StdFileTypes.JAVA.equals(child.getFileType())) {
FileBasedIndex.getInstance().requestReindex(child);
}
}
}
示例7: writeCompressed
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
public static int writeCompressed(DataOutput out, byte[] bytes, int length) throws IOException {
if (length > COMPRESSION_THRESHOLD && ourCanUseSnappy) {
SoftReference<byte[]> reference = spareBufferLocal.get();
byte[] compressedOutputBuffer = reference != null ? reference.get():null;
int maxCompressedSize = 32 + length + length / 6; // snappy.cc#MaxCompressedLength
if (compressedOutputBuffer == null || compressedOutputBuffer.length < maxCompressedSize) {
compressedOutputBuffer = new byte[maxCompressedSize];
spareBufferLocal.set(new SoftReference<byte[]>(compressedOutputBuffer));
}
int compressedSize = Snappy.rawCompress(bytes, 0, length, compressedOutputBuffer, 0);
DataInputOutputUtil.writeINT(out, -compressedSize);
out.write(compressedOutputBuffer, 0, compressedSize);
return compressedSize;
} else {
DataInputOutputUtil.writeINT(out, length);
out.write(bytes, 0, length);
return length;
}
}
示例8: save
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
@Override
public void save(final DataOutput out, @NotNull final StubIdList value) throws IOException {
int size = value.size();
if (size == 0) {
DataInputOutputUtil.writeINT(out, Integer.MAX_VALUE);
}
else if (size == 1) {
DataInputOutputUtil.writeINT(out, value.get(0)); // most often case
}
else {
DataInputOutputUtil.writeINT(out, -size);
for(int i = 0; i < size; ++i) {
DataInputOutputUtil.writeINT(out, value.get(i));
}
}
}
示例9: saveToFile
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
private void saveToFile(@Nonnull T instance) throws IOException {
FileOutputStream fileOutputStream = new FileOutputStream(myFile, true);
DataOutputStream output = new DataOutputStream(new BufferedOutputStream(fileOutputStream));
try {
if (myFile.length() == 0) {
DataInputOutputUtil.writeTIME(output, FSRecords.getCreationTimestamp());
DataInputOutputUtil.writeINT(output, myVersion);
}
myKeyDescriptor.save(output, instance);
} finally {
try {
output.close();
fileOutputStream.getFD().sync();
} catch (IOException ignore) {}
}
}
示例10: writeCompressedWithoutOriginalBufferLength
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
public static int writeCompressedWithoutOriginalBufferLength(@Nonnull DataOutput out, @Nonnull byte[] bytes, int length) throws IOException {
long started = System.nanoTime();
final byte[] compressedOutputBuffer = spareBufferLocal.getBuffer(Snappy.maxCompressedLength(length));
int compressedSize = Snappy.compress(bytes, 0, length, compressedOutputBuffer, 0);
final long time = System.nanoTime() - started;
mySizeAfterCompression.addAndGet(compressedSize);
mySizeBeforeCompression.addAndGet(length);
int requests = myCompressionRequests.incrementAndGet();
long l = myCompressionTime.addAndGet(time);
if (DUMP_COMPRESSION_STATS && requests % 1000 == 0) {
System.out.println("Compressed " + requests + " times, size:" + mySizeBeforeCompression + "->" + mySizeAfterCompression + " for " + (l / 1000000) + "ms");
}
DataInputOutputUtil.writeINT(out, compressedSize);
out.write(compressedOutputBuffer, 0, compressedSize);
return compressedSize;
}
示例11: saveTo
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
@Override
public void saveTo(DataOutput out, DataExternalizer<Value> externalizer) throws IOException {
if (needsCompacting()) {
getMergedData().saveTo(out, externalizer);
} else {
final TIntHashSet set = myInvalidated;
if (set != null && set.size() > 0) {
for (int inputId : set.toArray()) {
DataInputOutputUtil.writeINT(out, -inputId); // mark inputId as invalid, to be processed on load in ValueContainerImpl.readFrom
}
}
final UpdatableValueContainer<Value> toAppend = getAddedDelta();
if (toAppend != null && toAppend.size() > 0) {
toAppend.saveTo(out, externalizer);
}
}
}
示例12: save
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
@Override
public void save(@Nonnull final DataOutput out, @Nonnull final StubIdList value) throws IOException {
int size = value.size();
if (size == 0) {
DataInputOutputUtil.writeINT(out, Integer.MAX_VALUE);
}
else if (size == 1) {
DataInputOutputUtil.writeINT(out, value.get(0)); // most often case
}
else {
DataInputOutputUtil.writeINT(out, -size);
for(int i = 0; i < size; ++i) {
DataInputOutputUtil.writeINT(out, value.get(i));
}
}
}
示例13: doSerialize
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
private void doSerialize(@Nonnull Stub rootStub, @Nonnull StubOutputStream stream) throws IOException {
final ObjectStubSerializer serializer = StubSerializationUtil.getSerializer(rootStub);
if (((ObjectStubBase)rootStub).isDangling()) {
stream.writeByte(0);
}
DataInputOutputUtil.writeINT(stream, getClassId(serializer));
serializer.serialize(rootStub, stream);
final List<? extends Stub> children = rootStub.getChildrenStubs();
final int childrenSize = children.size();
DataInputOutputUtil.writeINT(stream, childrenSize);
for (int i = 0; i < childrenSize; ++i) {
doSerialize(children.get(i), stream);
}
}
示例14: write
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
public void write(DataOutput out) throws IOException {
LocalHistoryLog.LOG.assertTrue(isLocked, "Changeset should be locked");
DataInputOutputUtil.writeLONG(out, myId);
StreamUtil.writeStringOrNull(out, myName);
DataInputOutputUtil.writeTIME(out, myTimestamp);
DataInputOutputUtil.writeINT(out, myChanges.size());
for (Change c : myChanges) {
StreamUtil.writeChange(out, c);
}
}
示例15: save
import com.intellij.util.io.DataInputOutputUtil; //导入方法依赖的package包/类
public static <X> void save(final Collection<X> x, final DataExternalizer<X> e, final DataOutput out) {
try {
DataInputOutputUtil.writeINT(out, x.size());
for (X y : x) {
e.save(out, y);
}
}
catch (IOException c) {
throw new BuildDataCorruptedException(c);
}
}