Skip to content

Commit aa3f196

Browse files
authored
[DiskBBQ] modernize switch statements in DocIdsWriter (#134657)
1 parent 74ce7bc commit aa3f196

File tree

1 file changed

+12
-34
lines changed

1 file changed

+12
-34
lines changed

server/src/main/java/org/elasticsearch/index/codec/vectors/diskbbq/DocIdsWriter.java

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,12 @@ void writeDocIds(IntToIntFunction docIds, int count, byte encoding, DataOutput o
103103
min = Math.min(min, current);
104104
}
105105
switch (encoding) {
106-
case CONTINUOUS_IDS:
107-
writeContinuousIds(docIds, count, out);
108-
break;
109-
case DELTA_BPV_16:
110-
writeDelta16(docIds, count, min, out);
111-
break;
112-
case BPV_21:
113-
write21(docIds, count, min, out);
114-
break;
115-
case BPV_24:
116-
write24(docIds, count, min, out);
117-
break;
118-
case BPV_32:
119-
write32(docIds, count, min, out);
120-
break;
121-
default:
122-
throw new IOException("Unsupported number of bits per value: " + encoding);
106+
case CONTINUOUS_IDS -> writeContinuousIds(docIds, count, out);
107+
case DELTA_BPV_16 -> writeDelta16(docIds, count, min, out);
108+
case BPV_21 -> write21(docIds, count, min, out);
109+
case BPV_24 -> write24(docIds, count, min, out);
110+
case BPV_32 -> write32(docIds, count, min, out);
111+
default -> throw new IOException("Unsupported number of bits per value: " + encoding);
123112
}
124113
}
125114

@@ -272,23 +261,12 @@ void readInts(IndexInput in, int count, byte encoding, int[] docIDs) throws IOEx
272261
scratch = new int[count];
273262
}
274263
switch (encoding) {
275-
case CONTINUOUS_IDS:
276-
readContinuousIds(in, count, docIDs);
277-
break;
278-
case DELTA_BPV_16:
279-
readDelta16(in, count, docIDs);
280-
break;
281-
case BPV_21:
282-
readInts21(in, count, docIDs);
283-
break;
284-
case BPV_24:
285-
readInts24(in, count, docIDs);
286-
break;
287-
case BPV_32:
288-
readInts32(in, count, docIDs);
289-
break;
290-
default:
291-
throw new IOException("Unsupported number of bits per value: " + encoding);
264+
case CONTINUOUS_IDS -> readContinuousIds(in, count, docIDs);
265+
case DELTA_BPV_16 -> readDelta16(in, count, docIDs);
266+
case BPV_21 -> readInts21(in, count, docIDs);
267+
case BPV_24 -> readInts24(in, count, docIDs);
268+
case BPV_32 -> readInts32(in, count, docIDs);
269+
default -> throw new IOException("Unsupported number of bits per value: " + encoding);
292270
}
293271
}
294272

0 commit comments

Comments
 (0)