BlockStrategy中的递归

07-02-05 phenix
在 private Block getBlock(QueryConditonDatakey qcdk) 方法中,有这么一行,

。。。。

//1. if the dataBlock's length is this.blockLength(200),should have more dataBlocks.

if (dataBlock.getCount() == this.blockLength) {

//new datablock, we must support new start and new count

//the new start = old datablock's length + old datablock's start.

int newStartIndex = dataBlock.getStart() + dataBlock.getCount();

int newCount = clientBlock.getCount() - lastCount;

qcdk.setStart(newStartIndex);

qcdk.setCount(newCount);

logger.debug("[JdonFramework] newStartIndex=" + newStartIndex + " newCount=" + newCount);

Block nextBlock = getBlock(qcdk);

logger.debug("[JdonFramework] nextBlock.getCount()=" + nextBlock.getCount());

currentBlock.setCount(currentBlock.getCount() + nextBlock.getCount());

} else {

//2. if not, all datas just be here, clientBlock's count value maybe not correct.

currentBlock.setCount(lastCount);

}

其中 Block nextBlock = getBlock(qcdk);递归有什么用啊?能说说吗?我都快晕了

banq
2007-02-07 10:54
这段我当初做也是够晕的,现在回忆也晕,框架就是将这些不轻松的工作封装起来。

这段是从数据库获取的结果中切分成一个个Block

phenix
2007-02-07 11:47
banq 老师,我可能读懂思路了。

你的思路应该是把一个个相同查询的条件的block(start=0...(n-1)*200 count=200)组合成一个大的block,由不同的KEY映射,小的block是实际存在container里面的,而大的block是抽象的是这样吗?

猜你喜欢