Skip to content

Commit 753eb6c

Browse files
misc [vfs]: improve error message formatting AppendOnlyLogOverMMappedFile.read()
+ reduce content length to dump (64 is enough, never used 256) + mark difference between valid(>)/invalid(~) recordIds GitOrigin-RevId: 429469b06c684e251cc1f5a96bbe934a93a20eaf
1 parent cc20719 commit 753eb6c

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

platform/util/storages/src/com/intellij/platform/util/io/storages/appendonlylog/AppendOnlyLogOverMMappedFile.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public final class AppendOnlyLogOverMMappedFile implements AppendOnlyLog, Unmapp
5151
/** How wide region around questionable record to dump for debug diagnostics (see {@link #dumpContentAroundId(long, int, int)}) */
5252
private static final int DEBUG_DUMP_REGION_WIDTH = 256;
5353
/** If record content is larger -- don't print the remaining part in the dump, use '...' instead */
54-
private static final int MAX_RECORD_SIZE_TO_DUMP = getIntProperty("AppendOnlyLogOverMMappedFile.MAX_RECORD_SIZE_TO_DUMP", 256);
54+
private static final int MAX_RECORD_SIZE_TO_DUMP = getIntProperty("AppendOnlyLogOverMMappedFile.MAX_RECORD_SIZE_TO_DUMP", 64);
5555
//@formatter:on
5656

5757
private static final VarHandle INT32_OVER_BYTE_BUFFER = byteBufferViewVarHandle(int[].class, nativeOrder()).withInvokeExactBehavior();
@@ -1074,30 +1074,31 @@ private Pair<String, Boolean> dumpContentAroundId(long aroundRecordId,
10741074
", first unallocated: " + firstUnAllocatedOffset() + ")\n");
10751075
IntRef isIdValid = new IntRef(0);
10761076
forEachRecord((recordId, buffer) -> {
1077-
if (aroundRecordId == recordId) {
1078-
isIdValid.set(1);
1079-
}
1080-
10811077
long recordOffset = recordIdToOffset(recordId);
10821078
int recordSize = buffer.remaining();
10831079

10841080
long nextRecordId = recordOffsetToId(nextRecordOffset(recordOffset, recordSize));
10851081

10861082
//MAYBE RC: only use insideQuestionableRecord? Seems like records around are of little use
1087-
boolean insideQuestionableRecord = (recordId <= aroundRecordId && aroundRecordId <= nextRecordId);
1088-
boolean insideNeighbourRegion = (aroundRecordId - regionWidth <= recordId
1089-
&& recordId <= aroundRecordId + regionWidth);
1083+
boolean exactQuestionableRecord = (recordId == aroundRecordId);
1084+
boolean insideQuestionableRecord = (recordId < aroundRecordId && aroundRecordId < nextRecordId);
1085+
boolean insideNeighbourRegion = (aroundRecordId - regionWidth) <= recordId && recordId <= (aroundRecordId + regionWidth);
10901086

1091-
if (insideQuestionableRecord || insideNeighbourRegion) {
1087+
if (exactQuestionableRecord || insideQuestionableRecord || insideNeighbourRegion) {
10921088
String bufferAsHex = recordSize > maxRecordSizeToDump ?
10931089
IOUtil.toHexString(buffer.limit(buffer.position() + maxRecordSizeToDump).slice()) + " ... " :
10941090
IOUtil.toHexString(buffer.slice());
1095-
sb.append(insideQuestionableRecord ? "*" : "")
1091+
sb.append(exactQuestionableRecord ? ">" : (insideQuestionableRecord ? "~" : " "))
10961092
.append("[id: ").append(recordId).append(']')
10971093
.append("[offset: ").append(recordOffset).append(']')
10981094
.append("[len: ").append(recordSize).append(']')
10991095
.append("[hex: ").append(bufferAsHex).append("]\n");
11001096
}
1097+
1098+
if (exactQuestionableRecord) {
1099+
isIdValid.set(1);
1100+
}
1101+
11011102
return recordId <= aroundRecordId + regionWidth;
11021103
});
11031104
return Pair.pair(sb.toString(), isIdValid.get() == 1);

0 commit comments

Comments
 (0)