5c9078c4286bdfec0fa9d39de2802151a5ac69a8
braney
  Thu Sep 28 09:07:58 2023 -0700
when calculating zoom levels, don't seek on the input if it's already at
the beginning of the file.  Refs #32293

diff --git src/lib/bbiWrite.c src/lib/bbiWrite.c
index f6eb8af..374f920 100644
--- src/lib/bbiWrite.c
+++ src/lib/bbiWrite.c
@@ -385,30 +385,31 @@
 verbose(2, "initialReduction %d, initialReducedCount = %d\n", 
     initialReduction, initialReducedCount);
 
 /* Force there to always be at least one zoom.  It may waste a little space on small
  * files, but it makes files more uniform, and avoids special case code for calculating
  * overall file summary. */
 if (initialReduction == 0)
     {
     initialReduction = resScales[0];
     initialReducedCount = resSizes[0];
     }
 
 /* Call routine to make the initial zoom level and also a bit of work towards further levels. */
 struct lm *lm = lmInit(0);
 int zoomIncrement = bbiResIncrement;
+if (lf->lineIx != 0) // only seek on the input if it's not already at the beginning
     lineFileRewind(lf);
 struct bbiSummary *rezoomedList = writeReducedOnceReturnReducedTwice(usageList, fieldCount,
 	lf, initialReduction, initialReducedCount,
 	zoomIncrement, blockSize, itemsPerSlot, doCompress, lm, 
 	f, &zoomDataOffsets[0], &zoomIndexOffsets[0], totalSum);
 verboseTime(2, "writeReducedOnceReturnReducedTwice");
 zoomAmounts[0] = initialReduction;
 int zoomLevels = 1;
 
 /* Loop around to do any additional levels of zoom. */
 int zoomCount = initialReducedCount;
 int reduction = initialReduction * zoomIncrement;
 while (zoomLevels < bbiMaxZoomLevels)
     {
     int rezoomCount = slCount(rezoomedList);