@@ -1127,78 +1127,6 @@ public void testPreparedLongRunning() {
1127
1127
assertTrue ("Expected last request to pass, but it failed" , lastPassed );
1128
1128
}
1129
1129
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
-
1202
1130
/**
1203
1131
* Returns the estimated readKB.
1204
1132
*/
@@ -2025,15 +1953,6 @@ private void executeQuery(String statement,
2025
1953
queryReq .setConsistency (consistency );
2026
1954
}
2027
1955
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
-
2037
1956
int numRows = 0 ;
2038
1957
int readKB = 0 ;
2039
1958
int writeKB = 0 ;
@@ -2058,21 +1977,6 @@ private void executeQuery(String statement,
2058
1977
int wkb = queryRes .getWriteKB ();
2059
1978
int prepCost = (numBatches == 0 ? getMinQueryCost () : 0 );
2060
1979
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
-
2076
1980
if (showResults ) {
2077
1981
for (int i = 0 ; i < results .size (); ++i ) {
2078
1982
System .out .println ("Result " + (numRows + i ) + " :" );
@@ -2085,10 +1989,6 @@ private void executeQuery(String statement,
2085
1989
}
2086
1990
2087
1991
numRows += cnt ;
2088
-
2089
- assertTrue ("Unexpected readUnits, expect <= " +
2090
- (expBatchReadUnits + prepCost ) + ", but get " + runits ,
2091
- runits <= (expBatchReadUnits + prepCost ));
2092
1992
readKB += rkb ;
2093
1993
readUnits += runits ;
2094
1994
writeKB += wkb ;
@@ -2103,32 +2003,9 @@ private void executeQuery(String statement,
2103
2003
" Total WriteKB = " + writeKB );
2104
2004
}
2105
2005
2106
- if (!onprem ) {
2107
- assertTrue ("Read KB and Read units should be > 0" ,
2108
- readKB > 0 && readUnits > 0 );
2109
- }
2110
2006
assertEquals ("Wrong number of rows returned, expect " + expNumRows +
2111
2007
", but get " + numRows , expNumRows , numRows );
2112
2008
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
- }
2132
2009
}
2133
2010
2134
2011
private void executeQuery (String query ,
@@ -2160,7 +2037,6 @@ private void executeQuery(String query,
2160
2037
2161
2038
QueryResult queryRes ;
2162
2039
int numRows = 0 ;
2163
- int totalReadKB = 0 ;
2164
2040
2165
2041
do {
2166
2042
queryRes = handle .query (queryReq );
@@ -2176,26 +2052,6 @@ private void executeQuery(String query,
2176
2052
" ReadUnits = " + queryRes .getReadUnits ());
2177
2053
}
2178
2054
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 ();
2199
2055
} while (!queryReq .isDone ());
2200
2056
2201
2057
assertTrue ("Wrong number of rows returned, expect " + expNumRows +
0 commit comments