From c47cfed0ec0568a4c758ad801d5e11f32b9e05db Mon Sep 17 00:00:00 2001 From: kaijianding Date: Thu, 27 Apr 2017 20:11:07 +0800 Subject: [PATCH] Significantly improve LongEncodingStrategy.AUTO build performance (#4215) * Significantly improve LongEncodingStrategy.AUTO build performance * use numInserted instead of tempIn.available * fix bug --- .../segment/data/IntermediateLongSupplierSerializer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/processing/src/main/java/io/druid/segment/data/IntermediateLongSupplierSerializer.java b/processing/src/main/java/io/druid/segment/data/IntermediateLongSupplierSerializer.java index 3cf761b2b6b..6b459f48916 100644 --- a/processing/src/main/java/io/druid/segment/data/IntermediateLongSupplierSerializer.java +++ b/processing/src/main/java/io/druid/segment/data/IntermediateLongSupplierSerializer.java @@ -131,8 +131,10 @@ public class IntermediateLongSupplierSerializer implements LongSupplierSerialize try (DataInputStream tempIn = new DataInputStream(new BufferedInputStream(ioPeon.makeInputStream(tempFile)))) { delegate.open(); - while (tempIn.available() > 0) { + int available = numInserted; + while (available > 0) { delegate.add(tempIn.readLong()); + available--; } } }