public Bits readLiveDocs(Directory dir, SegmentCommitInfo info, IOContext context) throws IOException {assert info.hasDeletions();BytesRefBuilder scratch = new BytesRefBuilder();CharsRefBuilder scratchUTF16 = new CharsRefBuilder();String fileName = IndexFileNames.fileNameFromGeneration(info.info.name, LIVEDOCS_EXTENSION, info.getDelGen());ChecksumIndexInput in = null;boolean success = false;try {in = dir.openChecksumInput(fileName, context);SimpleTextUtil.readLine(in, scratch);assert StringHelper.startsWith(scratch.get(), SIZE);int size = parseIntAt(scratch.get(), SIZE.length, scratchUTF16);BitSet bits = new BitSet(size);SimpleTextUtil.readLine(in, scratch);while (!scratch.get().equals(END)) {assert StringHelper.startsWith(scratch.get(), DOC);int docid = parseIntAt(scratch.get(), DOC.length, scratchUTF16);bits.set(docid);SimpleTextUtil.readLine(in, scratch);}SimpleTextUtil.checkFooter(in);success = true;return new SimpleTextBits(bits, size);} finally {if (success) {IOUtils.close(in);} else {IOUtils.closeWhileHandlingException(in);}}}

public override IBits ReadLiveDocs(Directory dir, SegmentCommitInfo info, IOContext context){Debug.Assert(info.HasDeletions);var scratch = new BytesRef();var scratchUtf16 = new CharsRef();var fileName = IndexFileNames.FileNameFromGeneration(info.Info.Name, LIVEDOCS_EXTENSION, info.DelGen);ChecksumIndexInput input = null;var success = false;try{input = dir.OpenChecksumInput(fileName, context);SimpleTextUtil.ReadLine(input, scratch);Debug.Assert(StringHelper.StartsWith(scratch, SIZE));var size = ParseInt32At(scratch, SIZE.Length, scratchUtf16);var bits = new BitArray(size);SimpleTextUtil.ReadLine(input, scratch);while (!scratch.Equals(END)){Debug.Assert(StringHelper.StartsWith(scratch, DOC));var docid = ParseInt32At(scratch, DOC.Length, scratchUtf16);bits.SafeSet(docid, true);SimpleTextUtil.ReadLine(input, scratch);}SimpleTextUtil.CheckFooter(input);success = true;return new SimpleTextBits(bits, size);}finally{if (success){IOUtils.Dispose(input);}else{IOUtils.DisposeWhileHandlingException(input);}}}
