static void consecutiveDownSample(int segmentNo, int R,int cacheSizeControl,int memoryPolicy,int sampleNumPerSeg) throws IOException{
		
		File file = new File(outputpath+"/Segment_"+ segmentNo);
		hashRecord = new String[segsize*1024/chunksize];
		uniqueRecord = new int[segsize*1024/chunksize];
		sampledRecord = new int[segsize*1024/chunksize];
		containerTrack = new long[segsize*1024/chunksize];
		cacheSizeControl++;
		if(cacheSizeControl==memoryPolicy ){  //cache size control
				containerRecord.clear();
				cache.clear();
				cacheSizeControl=0;
		}
	
	dedupProcess_v2 dP = new dedupProcess_v2(index,indexSize, M,cache,chunksize, segsize, hashRecord,
			 uniqueRecord,sampledRecord,containerTrack,storageFileFolder,bf, bloomfilterRecord, 
			 file,containerRecord,estimateBase,sampleNumPerSeg,segAmount,consecutiveDedup,R);		
	dP.dedup();
	total += dP.getTotal();
	dup += dP.getDup();
	/*
	 * periodically output statistics (every 'segAmount' segments, we do one time's dedup)
	 */
	if(consecutiveDedup=true && segmentNo%segAmount == 0){	
		nodeQue.add(new Node(total,dup,(double)1/sampleRate,index.size(),(double)dup/total,(double)dup/(index.size()),sampleTotal));
		resultRecord.println();
		resultRecord.println("The culmulative segments are: " + segmentNo +
							"\nCurrent data amount is: "+total+
							"\nThe duplicates are: "+dup+
							"\nThe current data in total is: "+total+
							"\nThe current sampling rate is: " + (double)1/R +
							"\nThe current index size is: " + index.size()+
							"\nThe deduplication rate is : " + (double)dup/total*100 +"%"+
							"\nThe estimated dedup rate is: " + getEstimateRatio()*100 +" %");
		//Then calculate the efficiency
//		resultRecord.println("####The dedup efficiency is: " + (double)dup/(indexEntryNum-index.size())+" dup/wasted entry");	
		resultRecord.println("####The dedup efficiency is: " + (double)dup/(index.size())+" dup/entry slot");	
		resultRecord.println();

	if((double)dup/total < requiredRatio*getEstimateRatio() && R >=migratePara && downsampleWithMigrate == true){
    //resultRecord.println("The current sampleRate: "+sampleRate+" is larger than migratePara "+migratePara);
		resultRecord.println("\nSampling rate: "+(double)1/R+" is too low");
		System.out.println("\nSampling rate: "+(double)1/R+" is too low");
		R = R/migratePara; //The minimum value is 1, so the original value needs to be larger than 2
		sampleRate = R;
		resultRecord.println("\nResampling ... " 
					+"current dedup rate is: "+ (double)dup/total*100+"% ,less than "+requiredRatio+" of estimated rate "+ getEstimateRatio()*100+"% "
					+"The new sampling rate is: " + (double)1/R
					+ "\nThe estimated dedup rate is : " + getEstimateRatio()*100 + "%"
					+"\nCurrent dedup rate is: "+ dup/total*100 + "%"
					+ "\nThe user required dedup rate is: " + requiredRatio*100 + "%");
			
		System.out.println("Resampling ... The new sampling rate is: " + (double)1/R
					+ "\nThe user required dedup rate is: " + requiredRatio*100 + "%");
		resampleProcess(R);	
			
		if(index.size()>=indexEntryNum/2){
			indexEntryNum = (migratePara*indexEntryNum); //increase the index size(add RAM size)
		}//resultRecord.println("\nThe current index entries are "+indexEntryNum+" ,it's " + migrateTrig +" times of original one");
		}
	}
	
	totalChunkNum += dP.getTotalChunkNum();
	dP.storageWrite(); 	//update index and storagefolder

	}