Package com.alimama.mdrill.buffer

Source Code of com.alimama.mdrill.buffer.LuceneUtils

package com.alimama.mdrill.buffer;

import java.util.zip.CRC32;

import org.apache.lucene.index.IndexReader;




public class LuceneUtils  {
 
  public static String crcKey(IndexReader r)
  {
    String key= r.getStringCacheKey();
    CRC32 crc32 = new CRC32();
    crc32.update(new String(key).getBytes());
    long crcvalue = crc32.getValue();
   
    StringBuffer buff=new StringBuffer();
    buff.append(abs(key.hashCode()));
    buff.append("_");
    buff.append(abs(crcvalue));
    buff.append("_");
    buff.append(key.length());
    return buff.toString();
  }
 
 
  public static long abs(long num)
  {
    if(num<0)
    {
      return num*-1;
    }
    return num;
  }
}
TOP

Related Classes of com.alimama.mdrill.buffer.LuceneUtils

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.