private Block getBlock ( QueryConditonDatakey qcdk ) { Block clientBlock = new Block ( qcdk . getStart ( ) , qcdk . getCount ( ) ) ; if ( clientBlock . getCount ( ) > this . blockLength ) clientBlock . setCount ( this . blockLength ) ; // create dataBlock get DataBase or cache; List list = getBlockKeys ( qcdk ) ; Block dataBlock = new Block ( qcdk . getBlockStart ( ) , list . size ( ) ) ; int currentStart = clientBlock . getStart ( ) - dataBlock . getStart ( ) ; Block currentBlock = new Block ( currentStart , clientBlock . getCount ( ) ) ; currentBlock . setList ( list ) ; try { // because clientBlock's length maybe not be equals to the // dataBlock's length // we need the last length: // 1.the last block length is great than the clientBlock's // length，the current block's length is the clientBlock's length // 2.the last block length is less than the clientBlock's // length，under this condition, there are two choice. int lastCount = dataBlock . getCount ( ) + dataBlock . getStart ( ) - clientBlock . getStart ( ) ; Debug . logVerbose ( "[JdonFramework] lastCount=" + lastCount , module ) ; // 2 happened if ( lastCount < clientBlock . getCount ( ) ) { // if 2 , two case： // 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 ) ; Debug . logVerbose ( "[JdonFramework] newStartIndex=" + newStartIndex + " newCount=" + newCount , module ) ; Block nextBlock = getBlock ( qcdk ) ; Debug . logVerbose ( "[JdonFramework] nextBlock.getCount()=" + nextBlock . getCount ( ) , module ) ; 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 ) ; } } } catch ( Exception e ) { Debug . logError ( " getBlock error" + e , module ) ; } return currentBlock ; }
get the current block being avaliable to the query condition