@@ -1127,78 +1127,6 @@ public void testPreparedLongRunning() {
11271127 assertTrue ("Expected last request to pass, but it failed" , lastPassed );
11281128 }
11291129
1130- @ Test
1131- public void testQueryWithSmallLimit () {
1132- final int numMajor = 1 ;
1133- final int numPerMajor = 5 ;
1134- final int recordKB = 2 ;
1135- final int minRead = 1 ;
1136-
1137- /* Load rows to table */
1138- loadRowsToScanTable (numMajor , numPerMajor , recordKB );
1139-
1140- String query ;
1141- QueryRequest req ;
1142- QueryResult ret ;
1143-
1144- /* Update with number-based limit of 1 */
1145- int newRecordKB = 1 ;
1146- String longString = genString ((newRecordKB - 1 ) * 1024 );
1147- query = "update testTable set longString = \" " + longString +
1148- "\" where sid = 0 and id = 0" ;
1149- req = new QueryRequest ().setStatement (query ).setLimit (1 );
1150- ret = handle .query (req );
1151- assertNull (ret .getContinuationKey ());
1152-
1153- /* Update with maxReadKB of 1, expect an IAE */
1154- int expReadKB = minRead + recordKB ;
1155- query = "update testTable set longString = \" " + longString +
1156- "\" where sid = 0 and id = 1" ;
1157- for (int kb = 1 ; kb <= expReadKB ; kb ++) {
1158- req = new QueryRequest ().setStatement (query ).setMaxReadKB (kb );
1159- try {
1160- ret = handle .query (req );
1161- if (kb < expReadKB ) {
1162- fail ("Expected IAE" );
1163- }
1164- } catch (IllegalArgumentException iae ) {
1165- assertTrue ("Expected success with maxReadKB of " + kb +
1166- ": " + iae .getMessage (), kb < expReadKB );
1167- }
1168- }
1169-
1170- /* Update with maxReadKB of 1, 0 row updated */
1171- query = "update testTable set longString = \" " + longString +
1172- "\" where sid = 100 and id = 1" ;
1173- req = new QueryRequest ().setStatement (query ).setMaxReadKB (1 );
1174- ret = handle .query (req );
1175- assertNull (ret .getContinuationKey ());
1176-
1177- /* Query with number limit of 1 */
1178- query = "select * from testTable where sid = 0 and id > 1" ;
1179- int numRows = numMajor * (numPerMajor - 2 );
1180- expReadKB = getExpReadKB (false /* keyOnly */ , recordKB ,
1181- numRows /* numReadRows */ ,
1182- numRows /* numReadKeys */ );
1183- executeQuery (query , false /* keyOnly */ , false /* indexScan */ ,
1184- numRows , expReadKB , 1 /* limit */ , 0 /* maxReadKB */ ,
1185- recordKB );
1186-
1187- /* Query with maxReadKB of 1, expect an IAE */
1188- query = "select * from testTable" ;
1189- req = new QueryRequest ().setStatement (query ).setMaxReadKB (1 );
1190- int numExec = 0 ;
1191- try {
1192- do {
1193- numExec ++;
1194- ret = handle .query (req );
1195- } while (!req .isDone ());
1196- fail ("Expected IAE" );
1197- } catch (IllegalArgumentException iae ) {
1198- assertEquals (2 , numExec );
1199- }
1200- }
1201-
12021130 /**
12031131 * Returns the estimated readKB.
12041132 */
@@ -2025,15 +1953,6 @@ private void executeQuery(String statement,
20251953 queryReq .setConsistency (consistency );
20261954 }
20271955
2028- int expReadUnits = expReadKB ;
2029- int expBatchReadUnits = (sizeLimit > 0 ) ? sizeLimit : READ_KB_LIMIT ;
2030- expBatchReadUnits += (indexScan && !keyOnly ) ? recordKB : minRead ;
2031- expBatchReadUnits += (isDelete ? minRead : 0 );
2032- if (isAbsolute ) {
2033- expBatchReadUnits <<= 1 ;
2034- expReadUnits <<= 1 ;
2035- }
2036-
20371956 int numRows = 0 ;
20381957 int readKB = 0 ;
20391958 int writeKB = 0 ;
@@ -2058,21 +1977,6 @@ private void executeQuery(String statement,
20581977 int wkb = queryRes .getWriteKB ();
20591978 int prepCost = (numBatches == 0 ? getMinQueryCost () : 0 );
20601979
2061- /*
2062- * Make sure we didn't exceed the read limit. The "+ recordKB" is
2063- * needed because at the RNs we allow the limit to be exceeded by
2064- * 1 row, if we have already read the index entry for that row. The
2065- * "+ 1" is needed for DELETE queries, because a row that satisfies
2066- * the DELETE conditions, we read its primary-index once again to
2067- * do the delete.
2068- */
2069-
2070- /* on-prem the limit is not enforced -- this calc may not work */
2071- int effectiveMaxReadKB = (queryReq .getMaxReadKB () == 0 ?
2072- READ_KB_LIMIT : queryReq .getMaxReadKB ());
2073- assert (queryRes .getReadKB () <=
2074- prepCost + effectiveMaxReadKB + recordKB + 1 );
2075-
20761980 if (showResults ) {
20771981 for (int i = 0 ; i < results .size (); ++i ) {
20781982 System .out .println ("Result " + (numRows + i ) + " :" );
@@ -2085,10 +1989,6 @@ private void executeQuery(String statement,
20851989 }
20861990
20871991 numRows += cnt ;
2088-
2089- assertTrue ("Unexpected readUnits, expect <= " +
2090- (expBatchReadUnits + prepCost ) + ", but get " + runits ,
2091- runits <= (expBatchReadUnits + prepCost ));
20921992 readKB += rkb ;
20931993 readUnits += runits ;
20941994 writeKB += wkb ;
@@ -2103,32 +2003,9 @@ private void executeQuery(String statement,
21032003 " Total WriteKB = " + writeKB );
21042004 }
21052005
2106- if (!onprem ) {
2107- assertTrue ("Read KB and Read units should be > 0" ,
2108- readKB > 0 && readUnits > 0 );
2109- }
21102006 assertEquals ("Wrong number of rows returned, expect " + expNumRows +
21112007 ", but get " + numRows , expNumRows , numRows );
21122008
2113- if (expReadKB >= 0 && onprem == false ) {
2114- /*
2115- * When read cost exceeds size limit after reading the key, the
2116- * read cost possible has an additional MIN_READ exceeded per
2117- * batch.
2118- */
2119- int delta = (numBatches - 1 ) * minRead ;
2120- if (isAbsolute ) {
2121- delta <<= 1 ;
2122- }
2123-
2124- expReadUnits += totalPrepCost ;
2125-
2126- assertTrue ("Unexpected read units, exp in range[" +
2127- expReadUnits + ", " + (expReadUnits + delta ) +
2128- "] actual " + readUnits ,
2129- readUnits >= expReadUnits &&
2130- readUnits <= expReadUnits + delta );
2131- }
21322009 }
21332010
21342011 private void executeQuery (String query ,
@@ -2160,7 +2037,6 @@ private void executeQuery(String query,
21602037
21612038 QueryResult queryRes ;
21622039 int numRows = 0 ;
2163- int totalReadKB = 0 ;
21642040
21652041 do {
21662042 queryRes = handle .query (queryReq );
@@ -2176,26 +2052,6 @@ private void executeQuery(String query,
21762052 " ReadUnits = " + queryRes .getReadUnits ());
21772053 }
21782054
2179- /*
2180- * Note: in some rare cases we may get zero readKB with 1 result.
2181- * From Markos:
2182- *
2183- * When we do index/sort based group by, if we reach the read limit
2184- * in the middle of computing a group, we include the partially
2185- * computed group row in the continuation key. When we send the
2186- * continuation key back, we may discover (without reading any
2187- * bytes) that the group was actually fully computed, and we now
2188- * send it back as a result.
2189- *
2190- * So we take this rare case into account by allowing zero readKB
2191- * if the numresults is 1 and we've already accumulated readKBs.
2192- */
2193- if (!onprem &&
2194- (queryRes .getResults ().size () != 1 || totalReadKB == 0 )) {
2195- assertTrue (queryRes .getReadKB () > 0 );
2196- }
2197-
2198- totalReadKB += queryRes .getReadKB ();
21992055 } while (!queryReq .isDone ());
22002056
22012057 assertTrue ("Wrong number of rows returned, expect " + expNumRows +
0 commit comments