quick answer, Lucene only operates on strings (from a high level perspective)
simon On Fri, Sep 21, 2012 at 11:54 AM, 惠达 王 <wanghuida...@yahoo.cn> wrote: > hi all: > I want to know that why transform numeric to string? > > public static int longToPrefixCoded(final long val, final int shift, > final BytesRef bytes) { > > if (shift>63 || shift<0) > > throw new IllegalArgumentException("Illegal shift value, must be > 0..63"); > > int hash, nChars = (63-shift)/7 + 1; > > bytes.offset = 0; > > bytes.length = nChars+1; > > if (bytes.bytes.length < bytes.length) { > > bytes.grow(NumericUtils.BUF_SIZE_LONG);//11 > > } > > bytes.bytes[0] = (byte) (hash = (SHIFT_START_LONG + shift)); > > long sortableBits = val ^ 0x8000000000000000L; > > sortableBits >>>= shift; > > while (nChars > 0) { > > // Store 7 bits per byte for compatibility > > // with UTF-8 encoding of terms > > bytes.bytes[nChars--] = (byte)(sortableBits & 0x7f); > > sortableBits >>>= 7; > > } > > // calculate hash > > for (int i = 1; i < bytes.length; i++) { > > hash = 31*hash + bytes.bytes[i]; > > } > > return hash; > > } > > > 王惠达 (PHP开发工程师, Sysdev Team) > ------------------------- > 分机:8836 > QQ:429335915 > mobile: 13795449454 > E-mail: williamw...@anjuke.com > 上海市浦东新区陆家嘴环路166号未来资产大厦10楼 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org >