18 using Lucene.Net.Support;
20 namespace Lucene.Net.Analysis.Payloads
25 public static class PayloadHelper
27 public static byte[] EncodeFloat(
float payload)
29 return EncodeFloat(payload,
new byte[4], 0);
32 public static byte[] EncodeFloat(
float payload, byte[] data,
int offset)
37 public static byte[] EncodeInt(
int payload)
39 return EncodeInt(payload,
new byte[4], 0);
42 public static byte[] EncodeInt(
int payload, byte[] data,
int offset)
44 data[offset] = (byte) (payload >> 24);
45 data[offset + 1] = (byte) (payload >> 16);
46 data[offset + 2] = (byte) (payload >> 8);
47 data[offset + 3] = (byte) payload;
57 public static float DecodeFloat(byte[] bytes)
59 return DecodeFloat(bytes, 0);
69 public static float DecodeFloat(byte[] bytes,
int offset)
74 public static int DecodeInt(byte[] bytes,
int offset)
76 return ((bytes[offset] & 0xFF) << 24) | ((bytes[offset + 1] & 0xFF) << 16)
77 | ((bytes[offset + 2] & 0xFF) << 8) | (bytes[offset + 3] & 0xFF);