/** * Writes out the shared string table * * @param outputFile the binary output file * @exception IOException */ public void write(File outputFile) { // Thanks to Guenther for contributing the ExtSST implementation portion // of this method int charsLeft = 0; string curString = null; SSTRecord sst = new SSTRecord(totalOccurrences, stringList.Count); ExtendedSSTRecord extsst = new ExtendedSSTRecord(stringList.Count); int bucketSize = extsst.getNumberOfStringsPerBucket(); int stringIndex = 0; // CML: this one is nasty.... IEnumerator iterator = stringList.GetEnumerator(); while (iterator.MoveNext() && charsLeft == 0) { curString = (string)iterator.Current; // offset + header bytes int relativePosition = sst.getOffset() + 4; charsLeft = sst.add(curString); if ((stringIndex % bucketSize) == 0) { extsst.addString(outputFile.getPos(), relativePosition); } stringIndex++; } outputFile.write(sst); if (charsLeft != 0 || iterator.MoveNext()) { // Add the remainder of the string to the continue record SSTContinueRecord cont = createContinueRecord(curString, charsLeft, outputFile); // Carry on looping through the array until all the strings are done do { curString = (string)iterator.Current; int relativePosition = cont.getOffset() + 4; charsLeft = cont.add(curString); if ((stringIndex % bucketSize) == 0) { extsst.addString(outputFile.getPos(), relativePosition); } stringIndex++; if (charsLeft != 0) { outputFile.write(cont); cont = createContinueRecord(curString, charsLeft, outputFile); } }while (iterator.MoveNext()); outputFile.write(cont); } outputFile.write(extsst); }
/** * Writes out the shared string table * * @param outputFile the binary output file * @exception IOException */ public void write(File outputFile) { // Thanks to Guenther for contributing the ExtSST implementation portion // of this method int charsLeft = 0; string curString = null; SSTRecord sst = new SSTRecord(totalOccurrences, stringList.Count); ExtendedSSTRecord extsst = new ExtendedSSTRecord(stringList.Count); int bucketSize = extsst.getNumberOfStringsPerBucket(); int stringIndex = 0; // CML: this one is nasty.... IEnumerator iterator = stringList.GetEnumerator(); while (iterator.MoveNext() && charsLeft == 0) { curString = (string)iterator.Current; // offset + header bytes int relativePosition = sst.getOffset() + 4; charsLeft = sst.add(curString); if ((stringIndex % bucketSize) == 0) extsst.addString(outputFile.getPos(), relativePosition); stringIndex++; } outputFile.write(sst); if (charsLeft != 0 || iterator.MoveNext()) { // Add the remainder of the string to the continue record SSTContinueRecord cont = createContinueRecord(curString,charsLeft,outputFile); // Carry on looping through the array until all the strings are done do { curString = (string)iterator.Current; int relativePosition = cont.getOffset() + 4; charsLeft = cont.add(curString); if ((stringIndex % bucketSize) == 0) extsst.addString(outputFile.getPos(), relativePosition); stringIndex++; if (charsLeft != 0) { outputFile.write(cont); cont = createContinueRecord(curString, charsLeft, outputFile); } } while (iterator.MoveNext()); outputFile.write(cont); } outputFile.write(extsst); }