@@ -163,42 +163,54 @@ public void testIndexStats() throws Exception {
163
163
Client client = this .getClient ();
164
164
RegressionSuiteUtil .initializeTPCCDatabase (catalogContext , client );
165
165
166
+ // Get the row count per table per partition
167
+ // We need this so we can check that the indexes have the proper number of entries
168
+ Map <String , Map <Integer , Long >> rowCounts = RegressionSuiteUtil .getRowCountPerPartition (client );
169
+ assertEquals (rowCounts .toString (), catalogContext .getDataTables ().size (), rowCounts .size ());
170
+ // System.err.println(StringUtil.formatMaps(rowCounts));
171
+
172
+ // Loop through each table and make sure that each index reports back at least
173
+ // some amount of data.
166
174
ClientResponse cresponse = RegressionSuiteUtil .getStats (client , SysProcSelector .INDEX );
167
175
assertNotNull (cresponse );
168
176
assertEquals (Status .OK , cresponse .getStatus ());
169
-
170
- // Loop through each table and make sure that each index reports back at least
171
- // some amount of data.
172
177
VoltTable result = cresponse .getResults ()[0 ];
173
178
for (Table tbl : catalogContext .getDataTables ()) {
174
179
if (tbl .getIndexes ().isEmpty ()) continue ;
175
180
181
+ Map <Integer , Long > expected = rowCounts .get (tbl .getName ());
182
+ assertNotNull (tbl .toString (), expected );
183
+
176
184
for (Index idx : tbl .getIndexes ()) {
177
185
result .resetRowPosition ();
178
186
boolean found = false ;
179
187
while (result .advanceRow ()) {
180
188
String idxName = result .getString ("INDEX_NAME" );
181
189
String tblName = result .getString ("TABLE_NAME" );
182
190
String idxType = result .getString ("INDEX_TYPE" );
191
+ int partitionId = (int )result .getLong ("PARTITION_ID" );
183
192
long entryCount = result .getLong ("ENTRY_COUNT" );
184
193
if (tbl .getName ().equalsIgnoreCase (tblName ) && idx .getName ().equalsIgnoreCase (idxName )) {
185
194
long memoryEstimate = result .getLong ("MEMORY_ESTIMATE" );
186
195
//System.err.println(tblName + "------" + entryCount + "-------" + idxName + "------" + idxType + "---------" + memoryEstimate);
187
196
assert (memoryEstimate > 0 ) :
188
197
String .format ("Unexpected zero memory estimate for index %s.%s" , tblName , idxName );
189
198
found = true ;
199
+
200
+ // Check whether the entry count is correct if it's a unique index
201
+ if (idx .getUnique ()) {
202
+ Long expectedCnt = expected .get (partitionId );
203
+ assertNotNull (String .format ("TABLE:%s PARTITION:%d" , tbl .getName (), partitionId ), expectedCnt );
204
+ assertEquals (idx .fullName (), expectedCnt .longValue (), entryCount );
205
+ }
190
206
}
191
207
} // WHILE
192
208
// Make sure that we got all the indexes for the table.
193
- assert (found ) :
194
- String .format ("Did not get index stats for %s.%s" ,
195
- tbl .getName (), idx .getName ());
209
+ assert (found ) : "Did not get index stats for " + idx .fullName ();
196
210
} // FOR
197
-
198
211
} // FOR
199
212
}
200
-
201
-
213
+
202
214
public static Test suite () {
203
215
// the suite made here will all be using the tests from this class
204
216
MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder (TestStatsSuite .class );
0 commit comments