//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public void addBinaryField(index.FieldInfo field, Iterable<util.BytesRef> values) throws java.io.IOException public override void addBinaryField(FieldInfo field, IEnumerable <BytesRef> values) { Debug.Assert(fieldSeen(field.name)); Debug.Assert(field.DocValuesType == FieldInfo.DocValuesType.BINARY); int maxLength = 0; foreach (BytesRef value in values) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int length = value == null ? 0 : value.length; int length = value == null ? 0 : value.length; maxLength = Math.Max(maxLength, length); } writeFieldEntry(field, FieldInfo.DocValuesType.BINARY); // write maxLength SimpleTextUtil.write(data, MAXLENGTH); SimpleTextUtil.write(data, Convert.ToString(maxLength), scratch); SimpleTextUtil.WriteNewline(data); int maxBytesLength = Convert.ToString(maxLength).Length; StringBuilder sb = new StringBuilder(); for (int i = 0; i < maxBytesLength; i++) { sb.Append('0'); } // write our pattern for encoding lengths SimpleTextUtil.write(data, PATTERN); SimpleTextUtil.write(data, sb.ToString(), scratch); SimpleTextUtil.WriteNewline(data); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.text.DecimalFormat encoder = new java.text.DecimalFormat(sb.toString(), new java.text.DecimalFormatSymbols(java.util.Locale.ROOT)); DecimalFormat encoder = new DecimalFormat(sb.ToString(), new DecimalFormatSymbols(Locale.ROOT)); int numDocsWritten = 0; foreach (BytesRef value in values) { // write length //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int length = value == null ? 0 : value.length; int length = value == null ? 0 : value.length; SimpleTextUtil.write(data, LENGTH); SimpleTextUtil.write(data, encoder.format(length), scratch); SimpleTextUtil.WriteNewline(data); // write bytes -- don't use SimpleText.write // because it escapes: if (value != null) { data.writeBytes(value.bytes, value.offset, value.length); } // pad to fit for (int i = length; i < maxLength; i++) { data.writeByte((sbyte)' '); } SimpleTextUtil.WriteNewline(data); if (value == null) { SimpleTextUtil.write(data, "F", scratch); } else { SimpleTextUtil.write(data, "T", scratch); } SimpleTextUtil.WriteNewline(data); numDocsWritten++; } Debug.Assert(numDocs == numDocsWritten); }
public override void writeByte(byte b) { _indexOutput.writeByte(b); }