sparqlGraphLibrary/src/main/java/com/ge/research/semtk/load/IngestionWorkerThread.java
private ArrayList<String> splitIntoQueries(ArrayList<NodeGroup> nodeGroupList) throws Exception {
		ArrayList<String> queryList = null;
		int longestQueryLen = 0;
		int targetMin = (int) (this.optimalQueryChars * 0.75);
		int targetMax = (int) (this.optimalQueryChars * 1.25);
		
		// start with entire list (plus one because loop will decrement)
		this.recommendedBatchSize = nodeGroupList.size() + 1;
		
		// loop through starting at recommendedNumRecords decreasing each time
		// until all queries are small enough
		do {
			this.recommendedBatchSize = this.recommendedBatchSize - 1;
			
			// wipe out queryList
			queryList = new ArrayList<String>();
			int index0 = 0;
			int indexN = Math.min(nodeGroupList.size(), this.recommendedBatchSize);
			longestQueryLen = 0;
			
			// build queryList in chunks of recommendedNumRecords
			while (index0 < nodeGroupList.size()) {
				// build sublist of nodegroups
				ArrayList<NodeGroup> ngSubList = new ArrayList<NodeGroup>();
				for (int i=index0; i < indexN; i++) {
					ngSubList.add(nodeGroupList.get(i));
				}
				
				// generate query and check size
				try {
					String subQuery = NodeGroup.generateCombinedSparqlInsert(ngSubList, this.oInfo, this.endpoint);
					queryList.add(subQuery);
					longestQueryLen = Math.max(longestQueryLen, subQuery.length());
					
				} catch (NothingToInsertException e) {
					// silently skip
				}
				
				// get ready for next iteration
				index0 += this.recommendedBatchSize;
				indexN = Math.min(nodeGroupList.size(), indexN + this.recommendedBatchSize);
			}
			
		} while (longestQueryLen > targetMax && this.recommendedBatchSize > 1);
		
		// check if we found a solution
		if (this.recommendedBatchSize < 2 && longestQueryLen > this.maxQueryChars) {
			throw new Exception("Query is too long: " + longestQueryLen);
		}
		
		if (longestQueryLen < targetMin) {
			this.recommendedBatchSize *= 2;
		}
		
		return queryList;
	}
/**
	 * Use nodeGroupList to generate 1 or more queries that fit in this.maxQueryChars
	 * And set this.recommendedBatchSize
	 * @param nodeGroupList
	 * @return
	 * @throws Exception - including if one nodegroup still can't make a small enough query
	 */
Use nodeGroupList to generate 1 or more queries that fit in this.maxQueryChars
And set this.recommendedBatchSize
@param nodeGroupList
@return
@throws Exception - including if one nodegroup still can't make a small enough query
Use nodeGroupList to generate 1 or more queries that fit in this . maxQueryChars And set this . recommendedBatchSize @param nodeGroupList @return @throws Exception - including if one nodegroup still can ' t make a small enough query
private ArrayList<String> splitIntoQueries(ArrayList<NodeGroup> nodeGroupList) throws Exception {
		ArrayList<String> queryList = null;
		int longestQueryLen = 0;
		int targetMin = (int) (this.optimalQueryChars * 0.75);
		int targetMax = (int) (this.optimalQueryChars * 1.25);
		this.recommendedBatchSize = nodeGroupList.size() + 1;
		do {
			this.recommendedBatchSize = this.recommendedBatchSize - 1;
			queryList = new ArrayList<String>();
			int index0 = 0;
			int indexN = Math.min(nodeGroupList.size(), this.recommendedBatchSize);
			longestQueryLen = 0;
			while (index0 < nodeGroupList.size()) {
				ArrayList<NodeGroup> ngSubList = new ArrayList<NodeGroup>();
				for (int i=index0; i < indexN; i++) {
					ngSubList.add(nodeGroupList.get(i));
				}
				try {
					String subQuery = NodeGroup.generateCombinedSparqlInsert(ngSubList, this.oInfo, this.endpoint);
					queryList.add(subQuery);
					longestQueryLen = Math.max(longestQueryLen, subQuery.length());
				} catch (NothingToInsertException e) {
				}
				index0 += this.recommendedBatchSize;
				indexN = Math.min(nodeGroupList.size(), indexN + this.recommendedBatchSize);
			}
		} while (longestQueryLen > targetMax && this.recommendedBatchSize > 1);
		if (this.recommendedBatchSize < 2 && longestQueryLen > this.maxQueryChars) {
			throw new Exception("Query is too long: " + longestQueryLen);
		}
		if (longestQueryLen < targetMin) {
			this.recommendedBatchSize *= 2;
		}
		return queryList;
	}
private ArrayList < String > splitIntoQueries ( ArrayList < NodeGroup > nodeGroupList ) throws Exception { ArrayList < String > queryList = null ; int longestQueryLen = 0 ; int targetMin = ( int ) ( this . optimalQueryChars * 0.75 ) ; int targetMax = ( int ) ( this . optimalQueryChars * 1.25 ) ; this . recommendedBatchSize = nodeGroupList . size ( ) + 1 ; do { this . recommendedBatchSize = this . recommendedBatchSize - 1 ; queryList = new ArrayList < String > ( ) ; int index0 = 0 ; int indexN = Math . min ( nodeGroupList . size ( ) , this . recommendedBatchSize ) ; longestQueryLen = 0 ; while ( index0 < nodeGroupList . size ( ) ) { ArrayList < NodeGroup > ngSubList = new ArrayList < NodeGroup > ( ) ; for ( int i = index0 ; i < indexN ; i ++ ) { ngSubList . add ( nodeGroupList . get ( i ) ) ; } try { String subQuery = NodeGroup . generateCombinedSparqlInsert ( ngSubList , this . oInfo , this . endpoint ) ; queryList . add ( subQuery ) ; longestQueryLen = Math . max ( longestQueryLen , subQuery . length ( ) ) ; } catch ( NothingToInsertException e ) { } index0 += this . recommendedBatchSize ; indexN = Math . min ( nodeGroupList . size ( ) , indexN + this . recommendedBatchSize ) ; } } while ( longestQueryLen > targetMax && this . recommendedBatchSize > 1 ) ; if ( this . recommendedBatchSize < 2 && longestQueryLen > this . maxQueryChars ) { throw new Exception ( "Query is too long: " + longestQueryLen ) ; } if ( longestQueryLen < targetMin ) { this . recommendedBatchSize *= 2 ; } return queryList ; }
Use nodeGroupList to generate 1 or more queries that fit in this.maxQueryChars
 And set this.recommendedBatchSize
 @param nodeGroupList
 @return
 @throws Exception - including if one nodegroup still can't make a small enough query
Use nodeGroupList to generate 1 or more queries that fit in this . maxQueryChars And set this . recommendedBatchSize @param nodeGroupList @return @throws Exception - including if one nodegroup still can ' t make a small enough query
// start with entire list (plus one because loop will decrement) // loop through starting at recommendedNumRecords decreasing each time // until all queries are small enough // wipe out queryList // build queryList in chunks of recommendedNumRecords // build sublist of nodegroups // generate query and check size // silently skip // get ready for next iteration // check if we found a solution