2012年4月21日

1

json  大括号{}用来描述一组"不同类型的无序键值对集合",方括号[]用来描述一组"相同类型的有序数据集合"。
ajax  通过XmlHttpRequest获取非本页内容
jsonp 是动态添加<script>标签来调用服务器提供的js脚本

 http://developer.51cto.com/art/201105/264791.htm

2

php setcookiee前不能够有var_dump等输出

 

3 发mail

1 打开eclipse plugins\com.genuitec.eclipse.j2eedt.*\data\libraryset\EE_5\javaee.jar,删除其中的mail就好了
2 download jaf-1_1_1.zip(activation.jar),javamail-1.4.5(mail.jar)

posted @ 2012-04-21 17:48 剑迅 阅读(8) 评论(0) 编辑

2012年3月6日

solr source code
1 org.apache.solr.common 基本的类对象
2 org.apache.solr.common.params 存取参数的类,按照参数类型不同分为很多的类,
  (1) AnalysisParams 下有map,ModifiableSolrParams(LinkedHashMap),RequiredSolrParams,SolrQuery
  (2) CommonParams等
3 org.apache.solr.analysis
  (1) tokenizerFactory(BaseTokenizerFactory)可以按照字数(NGramTokenizerFactory)、正则、标签、关键字、
 字符、俄语、树结构(TrieTokenizerFactory)、空格
  (2) BaseCharFilterFactory
  (3) BaseTokenFilterFactory,按照语言种类、停词、元数据(payload)、语音(?DoubleMetaphoneFilterFactory)、
 带连字符的(HyphenatedWordsFilterFactory)、通配符(wildcard)、同义(synonym)
4 org.apache.solr.core
   (1)AbstractSolrEventListener含QuerySenderListener,newSearcher的warm在里面
   (2)core初始化相关 CoreContainer[n个CoreDescriptor];
   SolrCore 包含与搜索相关的
   设置/获取:ResponseHeader、Plugins、booleanQueryMaxClauseCount、getSearcher
   初始化/注册:DeletionPolicy、Listeners、searcher、IndexReader(witer)、Index、HighLighter
   (3)DirectoryFactory,IndexReaderFactory
   (4)索引commmit时间点的保留策略 IndexDeletionPolicyWrapper
   (5)JmxMonitoredMap extends ConcurrentHashMap(高并发多锁的hashmap)
   (6)RequestHandlers (can Read solrconfig.xml and register the appropriate handlers),
 包含LazyRequestHandlerWrapper,让lazyload的requestHandler在第一次调用该requestHandler时才初始化
   (7)SolrResourceLoader包含ClassLoader和getLines
5 org.apache.solr.handler和org.apache.solr.handler.admin
   (1)SnapShooter
   (2)ContentStreamLoader包含xml和csv两种update、delete、read数据的方式,and also can update handler which uses the JavaBin format
   (3)RequestHandlerBase
 SearchHandler(@dismax、相关度排序相关;
     @以组件形式添加各项功能参数及对参数的处理,eg.高亮、facet、mlt、query、stats、debug;
     @shard just the string like 'localhost:8080/complex/';
     @ShardResponse)
 AnalysisRequestHandlerBase(对request的xml进行处理,返回NamedList
        @analyzeTokenStream Analyzes the given TokenStream, collecting the Tokens it produces;
        @convertTokensToNamedLists;
        @AnalysisContext class)
 AnalysisRequestHandler(@processContent for Tokenizing doc;
       @readDoc)
   (4)CoreAdminHandler handleRequestBody为入口,针对各个core的状态进行加载core、重命名core、删除core等
   (5)MoreLikeThisHandler (@getMoreLikeThis mlt.like(lucene function)根据req获取相似度较高的文档集合添加到response中,传入一个doc,首先获取每一个字段的TermFreqVector(即tf),然后将其添加到TermFrequencies中;
  遍历TermFrequencies中所有的term,并取出其tf以及在所有指定字段中最大的df,根据df和当前索引文档数计算idf,然后计算每个term的score=tf*idf,并压入PriorityQueue,
  按照score从大到小取出一定数量的term(maxQueryTerm)进行组建构建一个BooleanQuery,用创建的query进行一次检索,取出得分最高的N篇文档即可。)
   (6)PluginInfoHandler 取出并呈现每个core下加载的QUERY HANDLERS、UPDATE HANDLERS、CACHE、HIGHLIGHTING 等信息
   (7)ReplicationHandler 提供api供slaves从master复制,设置复制的校验、复制前的的变量准备(eg.是否commit、optimize等),以及复制后的相关动作
      (@Adler32 包含校验的拷贝
      @getReplicationDetails showing statistics and progress information
      @FileStream class 带校验和的类)
   (8)ShowFileRequestHandler web方式读取conf文件(设置文件hidden可以控制文件不被访问)
   (9)SpellCheckerRequestHandler 根据空格分割字符串并按照SolrQueryRequest的extendedResults, cmd rebuild,accuracy, suggestionCount, restrictToField, and onlyMorePopular参数来
     选择性增加分割后word的相关信息,eg.词频、suggestion word等
   (10)SystemInfoHandler 包含core,jvm,lucene的systemInfo
   (11)ThreadDumpHandler 线程信息统计current,peak=,daemon
   (12)AdminHandlers 注册所有管理handlers(LukeRequestHandler、SystemInfoHandler、PluginInfoHandler、ThreadDumpHandler、ThreadDumpHandler、ShowFileRequestHandler)
posted @ 2012-03-06 16:41 剑迅 阅读(16) 评论(0) 编辑

2012年3月1日

solr

1 drill data by random,eg.&random_123

 solrQuery.addSortField("random_"+rand.nextInt(1000),SolrQuery.ORDER.desc);

 

2  search id not equal to 222

 eg.-id:222

 

3 deleteById(List<String> ids) in solrj

  we should delete anything by id As much as possible,using deleteByQuery function may occur some problem.

 

4 to get facet result we need to set facet and facet.field,also rows=0 is needed

 

5 if you use dismax to search,you should use q="val" instead of q="title:val"

 

6 highlight  params : &hl=true&hl.fl=title

 

7 show score params :&fl=score ,useful  score will  spread out before us when you search some words

 

8 delete url

   update/?stream.body=<delete><id>mm</id></delete>&stream.contentType=text/xml;charset=utf-8&commit=true

 

9 clear update docs

  after we commit docs,we need to use "this.docs.clear()"  to clear the queue stored docs

 

10 optimize

  optimizing one time per day is a good choice

 

11 get all the data which field value's length >0

   q=fieldName:["" To *]

 

12 use underline' can replace the default operator

   SolrQuery.setParam("q.op", "OR");

json util

     we often use net.sf.json and org.json.simple to help us do explaining,on use we found some string cannot  be decoded well by  net.sf.json ,

so  org.json.simple is good complement .After import org.json we may use JSONParser to change string to JSONObject.

  For importing  net.sf.json,we may change list object to JSONArray,and decode json text to json object 

and then use a function(JSONObject.toBean(jsonObj,className)) to convert jsonObj to class object

    

posted @ 2012-03-01 14:10 剑迅 阅读(16) 评论(0) 编辑

2012年2月18日

单点登录

 1 可以使用一些现有开源的SSO服务器

 2 在多个项目间使用统一的加解密,在项目之间传递ticket,然后在过滤器中判断,通过则将相关值保存至session

 

读写分离

 最好是使用aop编程吧,在spring中配置一下,再简单写点代码就OK了

 

大数据量的处理注意点

 1 需要在写之前读的,可以先全部读出来,然后再一次写入,不要读写读写的重复循环

 2 都说用基于jdbc的PreparedStatement和Batch来实现一次N条数据的插入,但使用时发现确实需要将session和batch的缓存及参数定时清理才会好些

 

   Connection conn=session.connection();

   conn.setAutoCommit(false);
   PreparedStatement ps1=conn.prepareStatement(sql);
   
   for(IpAddress2 ipObj:modelList){
    ps1.setString(4, bb);
    ps1.setString(5, dd);    
    ps1.addBatch();
    if(i%5000==0){
     ps1.executeBatch();
     conn.commit();
     ps1.clearBatch();
    }
   }
   ps1.executeBatch();
   conn.commit();
   conn.close();

 

加解密
不能够将“=”一并作为内容加密,否则会出现乱码

 

Hibernate
findByExample: 
1.不支持主键 
2.不支持关联 
3.不支持NULL 

 

不同环境取路径

与系统有关的默认名称分隔符。
windows系统上 此字段被初始化为包含系统属性 file.separator 值的第一个字符。
在 UNIX 系统上,此字段的值为 '/';在 Microsoft Windows 系统上,它为 '\\'。
获取路径eg.
URL is = clazz.getClassLoader().getResource(clazz.getName());
String path = is.getFile();
path = StringUtils.replace(path, "%20", " ");  
if(“\\".equals(File.separator)){
 path = StringUtils.removeStart(path, "/");
}

 

posted @ 2012-02-18 17:11 剑迅 阅读(16) 评论(0) 编辑

2011年11月11日

We need to import  struts2-spring-plugin-2.1.8.1.jar for combining struts and spring ,import mysql-connector-java-5.1.18-bin.jar for hibernate

and delete cglib.jar for com.springsource.net.sf.cglib-2.2.0.jar which contains cglib.jar and asm.jar

posted @ 2011-11-11 10:09 剑迅 阅读(2) 评论(0) 编辑

2011年10月9日

摘要: Steps are as follows:1 cp all nutch conf(only one single nutch instance should be setup) to hadoop conf2 put urls and /nutch-1.3.job(jar) to cloud3 use the crawl command with reference files on the cloud阅读全文
posted @ 2011-10-09 17:47 剑迅 阅读(18) 评论(0) 编辑

2011年8月11日

摘要: 1 Nutch common is 'bin/nutch crawl <urlDir> [-dir d] [-threads n] [-depth i] [-topN] ', nutch will generate segment foreach depth,and topN means each layer will collect topN urls. Generally each layer has one single segment,it depends onmaxNumSegments(1 is the default value) in Generat阅读全文
posted @ 2011-08-11 17:41 剑迅 阅读(22) 评论(0) 编辑

2011年7月29日

摘要: hadoop-0.20.2hbase-0.20.6hive-0.6.0-binpig-0.7.0zookeeper-3.2.2nutch-1.3lucene-3.1.0apache-solr-3.1.0阅读全文
posted @ 2011-07-29 16:38 剑迅 阅读(17) 评论(0) 编辑

2011年7月25日

摘要: 1 setup path cannot exist blank2 remove environment variable of individual tomcat,because I downloaded geronimo zip files binded with tomcat3 change some port number4 replace localhost with my hostname , then we may access geronimo web console with ipaddress5 to develop with geronimo eclips plugin,s阅读全文
posted @ 2011-07-25 17:00 剑迅 阅读(9) 评论(0) 编辑

2011年6月28日

摘要: 1 eclipse Installed JREs should use jdk not jre2 when renew a server,we should choose the jdk for jres3 if we want to access apache root page,we should double-click the server,choose "takes control of Tomcat" in the "Server Locations" part and set Deploy path with "webapps&q阅读全文
posted @ 2011-06-28 12:01 剑迅 阅读(57) 评论(0) 编辑