01: /*
02:
03: Derby - Class org.apache.derbyTesting.functionTests.util.StatParser
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derbyTesting.functionTests.util;
23:
24: /**
25: * Utilities for parsing runtimestats
26: *
27: * RESOLVE: This class should be internationalized.
28: */
29: public class StatParser {
30: public static String getScanCols(String runTimeStats)
31: throws Throwable {
32: if (runTimeStats == null) {
33: return "The RunTimeStatistics string passed in is null";
34: }
35:
36: int startIndex;
37: int endIndex = 0;
38: int indexIndex;
39:
40: StringBuffer strbuf = new StringBuffer();
41:
42: /*
43: ** We need to know if we used an index
44: */
45: if ((indexIndex = runTimeStats.indexOf("Index Scan ResultSet")) != -1) {
46: int textend = runTimeStats.indexOf("\n", indexIndex);
47: strbuf.append(runTimeStats.substring(indexIndex,
48: textend + 1));
49: } else {
50: strbuf.append("TableScan\n");
51: }
52:
53: int count = 0;
54: while ((startIndex = runTimeStats.indexOf(
55: "Bit set of columns fetched", endIndex)) != -1) {
56: count++;
57: endIndex = runTimeStats.indexOf("}", startIndex);
58: if (endIndex == -1) {
59: endIndex = runTimeStats.indexOf("All", startIndex);
60: if (endIndex == -1) {
61: throw new Throwable(
62: "couldn't find the closing } on "
63: + "columnFetchedBitSet in "
64: + runTimeStats);
65: }
66: endIndex += 5;
67: } else {
68: endIndex++;
69: }
70: strbuf.append(runTimeStats.substring(startIndex, endIndex));
71: strbuf.append("\n");
72: }
73: if (count == 0) {
74: throw new Throwable(
75: "couldn't find string 'Bit set of columns fetched' in :\n"
76: + runTimeStats);
77: }
78:
79: return strbuf.toString();
80: }
81: }
|