Lucene Boost 精度表
Lucene中索引阶段Boost的值会被存放在.nrm文件中,用16进制打开就能看的到。
每个Boost值最终会被保存于一个Byte中,如果细心的同学就会发现在SetBoost的时候参数类型是float,float是四个字节的,也就是说最后会有精度丢失。
废了方便查询给出代码和0-255对应的float
下面是换算的代码:
public static sbyte FloatToByte315(float f) { int num = BitConverter.ToInt32(BitConverter.GetBytes(f), 0); int num2 = num >> 0x15; if (num2 < 0x180) { if (num > 0) return 1; return 0; } if (num2 >= 640) return -1; return (sbyte) (num2 - 0x180); }
public static float Byte315ToFloat(byte b) { if (b == 0) return 0f; int num = (b & 0xff) << 0x15; num += 0x30000000; return BitConverter.ToSingle(BitConverter.GetBytes(num), 0); }
0
5.820766E-10
6.984919E-10
8.149073E-10
9.313226E-10
1.164153E-09
1.396984E-09
1.629815E-09
1.862645E-09
2.328306E-09
2.793968E-09
3.259629E-09
3.72529E-09
4.656613E-09
5.587935E-09
6.519258E-09
7.450581E-09
9.313226E-09
1.117587E-08
1.303852E-08
1.490116E-08
1.862645E-08
2.235174E-08
2.607703E-08
2.980232E-08
3.72529E-08
4.470348E-08
5.215406E-08
5.960464E-08
7.450581E-08
8.940697E-08
1.043081E-07
1.192093E-07
1.490116E-07
1.788139E-07
2.086163E-07
2.384186E-07
2.980232E-07
3.576279E-07
4.172325E-07
4.768372E-07
5.960464E-07
7.152557E-07
8.34465E-07
9.536743E-07
1.192093E-06
1.430511E-06
1.66893E-06
1.907349E-06
2.384186E-06
2.861023E-06
3.33786E-06
3.814697E-06
4.768372E-06
5.722046E-06
6.67572E-06
7.629395E-06
9.536743E-06
1.144409E-05
1.335144E-05
1.525879E-05
1.907349E-05
2.288818E-05
2.670288E-05
3.051758E-05
3.814697E-05
4.577637E-05
5.340576E-05
6.103516E-05
7.629395E-05
9.155273E-05
0.0001068115
0.0001220703
0.0001525879
0.0001831055
0.000213623
0.0002441406
0.0003051758
0.0003662109
0.0004272461
0.0004882813
0.0006103516
0.0007324219
0.0008544922
0.0009765625
0.001220703
0.001464844
0.001708984
0.001953125
0.002441406
0.002929688
0.003417969
0.00390625
0.004882813
0.005859375
0.006835938
0.0078125
0.009765625
0.01171875
0.01367188
0.015625
0.01953125
0.0234375
0.02734375
0.03125
0.0390625
0.046875
0.0546875
0.0625
0.078125
0.09375
0.109375
0.125
0.15625
0.1875
0.21875
0.25
0.3125
0.375
0.4375
0.5
0.625
0.75
0.875
1
1.25
1.5
1.75
2
2.5
3
3.5
4
5
6
7
8
10
12
14
16
20
24
28
32
40
48
56
64
80
96
112
128
160
192
224
256
320
384
448
512
640
768
896
1024
1280
1536
1792
2048
2560
3072
3584
4096
5120
6144
7168
8192
10240
12288
14336
16384
20480
24576
28672
32768
40960
49152
57344
65536
81920
98304
114688
131072
163840
196608
229376
262144
327680
393216
458752
524288
655360
786432
917504
1048576
1310720
1572864
1835008
2097152
2621440
3145728
3670016
4194304
5242880
6291456
7340032
8388608
1.048576E+07
1.258291E+07
1.468006E+07
1.677722E+07
2.097152E+07
2.516582E+07
2.936013E+07
3.355443E+07
4.194304E+07
5.033165E+07
5.872026E+07
6.710886E+07
8.388608E+07
1.006633E+08
1.174405E+08
1.342177E+08
1.677722E+08
2.013266E+08
2.34881E+08
2.684355E+08
3.355443E+08
4.026532E+08
4.69762E+08
5.368709E+08
6.710886E+08
8.053064E+08
9.395241E+08
1.073742E+09
1.342177E+09
1.610613E+09
1.879048E+09
2.147484E+09
2.684355E+09
3.221225E+09
3.758096E+09
4.294967E+09
5.368709E+09
6.442451E+09
7.516193E+09