import com.google.common.collect.Lists;
import java.util.List;
public class Test {
public static final int PARTITION_SIZE = 1000;
public static void main( String[] args )
{
/* 这里就模拟是业务参数 */
List paramIds = Lists.newArrayList( 1L, 2L, 3L );
/* 进行分隔 */
List > partitionParamIds = Lists.partition( paramIds, PARTITION_SIZE );
List
import com.google.common.collect.Lists;
import java.util.List;
public class Test {
public static void main( String[] args )
{
/* 这里就模拟是业务参数 */
List paramIds = Lists.newArrayList( 1L, 2L, 3L );
List resultList = new CommonDoPartition<>().partitionToQuery( paramIds,
partition - > new ObjectDao().getList( partition ) );
System.out.println( resultList.size() );
}
}
class ObjectDao {
/* 都说了是模拟模拟,不要挑刺了 */
public List getList( List paramIds )
{
List resultList = Lists.newArrayList();
for ( Long paramId : paramIds )
{
resultList.add( paramId );
}
return(resultList);
}
}
这里用到了一个CommonDoPartition类,我们来看下它是怎么实现的
CommonDoPartition.java
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import java.util.List;
import java.util.function.Function;
public class CommonDoPartition {
private final static Logger logger = Logger.getLogger( CommonDoPartition.class );
public static final int PARTITION_SIZE = 1000;
public < T, R > List partitionToQuery( int partitionSize, List all, Function, List > function )
{
if ( CollectionUtils.isEmpty( all ) )
{
logger.warn( "no data to query" );
return(Lists.newArrayList() );
}
List > partitions = Lists.partition( all, partitionSize ); List result = Lists.newArrayList(); for ( List list : partitions )
{
List resultList = function.apply( list ); if ( !CollectionUtils.isEmpty( resultList ) )
{
result.addAll( resultList );
}
}
return(result);
}
public < T, R > List partitionToQuery( List all, Function, List > function )
{
return(this.partitionToQuery( PARTITION_SIZE, all, function ) );
}
}
public void partitionToDo( int partitionSize, List all, Consumer > consumer )
{
if ( CollectionUtils.isEmpty( all ) )
{
logger.warn( "no data to consume" );
return;
}
List > partitions = Lists.partition( all, partitionSize );
for ( List list : partitions )
{
consumer.accept( list );
}
}
public void partitionToDo( List all, Consumer > consumer )
{
this.partitionToDo( PARTITION_SIZE, all, consumer );
}
public < T, R > void partitionToQueryAndDo( int partitionSize, List all, Function, List > function, Consumer > consumer )
{
if ( CollectionUtils.isEmpty( all ) )
{
logger.warn( "no data to consume" );
return;
}
List > partitions = Lists.partition( all, partitionSize );
List resultList;
for ( List list : partitions )
{
resultList = function.apply( list );
consumer.accept( resultList );
}
}
public < T, R > void partitionToQueryAndDo( List all, Function, List > function, Consumer > consumer )
{
this.partitionToQueryAndDo( PARTITION_SIZE, all, function, consumer );
}
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a null object reference
出现以上异常.然后就在baidu上
cmd命令打jar是如下实现:
在运行里输入cmd,利用cmd命令进入到本地的工作盘符。(如我的是D盘下的文件有此路径 D:\workspace\prpall\WEB-INF\classes)
现在是想把D:\workspace\prpall\WEB-INF\classes路径下所有的文件打包成prpall.jar。然后继续如下操作:
cd D: 回车
cd workspace/prpal
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml&q
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.
public class Solution {
public int maximalRectangle(char[][] matrix)
随着RESTful Web Service的流行,测试对外的Service是否满足期望也变的必要的。从Spring 3.2开始Spring了Spring Web测试框架,如果版本低于3.2,请使用spring-test-mvc项目(合并到spring3.2中了)。
Spring MVC测试框架提供了对服务器端和客户端(基于RestTemplate的客户端)提供了支持。
&nbs
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
/*you'll also need to set UIViewControllerBasedStatusBarAppearance to NO in the plist file if you use this method
英文资料:
Thread Dump and Concurrency Locks
Thread dumps are very useful for diagnosing synchronization related problems such as deadlocks on object monitors. Ctrl-\ on Solaris/Linux or Ctrl-B