private void ReadField(StoredFieldVisitor visitor, FieldInfo info, int bits) { int numeric = bits & FIELD_IS_NUMERIC_MASK; if (numeric != 0) { switch (numeric) { case FIELD_IS_NUMERIC_INT: visitor.IntField(info, FieldsStream.ReadInt()); return; case FIELD_IS_NUMERIC_LONG: visitor.LongField(info, FieldsStream.ReadLong()); return; case FIELD_IS_NUMERIC_FLOAT: visitor.FloatField(info, Number.IntBitsToFloat(FieldsStream.ReadInt())); return; case FIELD_IS_NUMERIC_DOUBLE: visitor.DoubleField(info, BitConverter.Int64BitsToDouble(FieldsStream.ReadLong())); return; default: throw new CorruptIndexException("Invalid numeric type: " + numeric.ToString("x")); } } else { int length = FieldsStream.ReadVInt(); var bytes = new byte[length]; FieldsStream.ReadBytes(bytes, 0, length); if ((bits & FIELD_IS_BINARY) != 0) { visitor.BinaryField(info, bytes); } else { visitor.StringField(info, IOUtils.CHARSET_UTF_8.GetString(bytes)); } } }
private static void ReadField(DataInput @in, StoredFieldVisitor visitor, FieldInfo info, int bits) { switch (bits & CompressingStoredFieldsWriter.TYPE_MASK) { case CompressingStoredFieldsWriter.BYTE_ARR: int length = @in.ReadVInt(); var data = new byte[length]; @in.ReadBytes(data, 0, length); visitor.BinaryField(info, data); break; case CompressingStoredFieldsWriter.STRING: length = @in.ReadVInt(); data = new byte[length]; @in.ReadBytes(data, 0, length); visitor.StringField(info, IOUtils.CHARSET_UTF_8.GetString((byte[])(Array)data)); break; case CompressingStoredFieldsWriter.NUMERIC_INT: visitor.IntField(info, @in.ReadInt()); break; case CompressingStoredFieldsWriter.NUMERIC_FLOAT: visitor.FloatField(info, Number.IntBitsToFloat(@in.ReadInt())); break; case CompressingStoredFieldsWriter.NUMERIC_LONG: visitor.LongField(info, @in.ReadLong()); break; case CompressingStoredFieldsWriter.NUMERIC_DOUBLE: visitor.DoubleField(info, BitConverter.Int64BitsToDouble(@in.ReadLong())); break; default: throw new InvalidOperationException("Unknown type flag: " + bits.ToString("x")); } }