| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE html |
| PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xml:lang="en-us" lang="en-us"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
| <meta name="DC.Type" content="reference"/> |
| <meta name="DC.Title" content="SELECT Clause"/> |
| <meta name="abstract" content=""/> |
| <meta name="description" content=""/> |
| <meta name="DC.Relation" scheme="URI" content="../reference/oqlsyntax.html"/> |
| <meta name="copyright" content="Copyright (c) 2008, 2010 SAP AG and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html " type="primary"/> |
| <meta name="DC.Rights.Owner" content="Copyright (c) 2008, 2010 SAP AG and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html " type="primary"/> |
| <meta name="DC.Format" content="XHTML"/> |
| <meta name="DC.Identifier" content="ref_oqlsyntaxselect"/> |
| <meta name="DC.Language" content="en-us"/> |
| <link rel="stylesheet" type="text/css" href="../styles/commonltr.css"/> |
| <title>SELECT Clause</title> |
| </head> |
| <body id="ref_oqlsyntaxselect"> |
| |
| |
| <h1 class="title topictitle1">SELECT Clause</h1> |
| |
| |
| |
| |
| |
| <div class="body refbody"><p class="shortdesc"/> |
| |
| <div class="section"> |
| <p class="p"> |
| The SELECT clause determines what to extract from the |
| heap dump. To display objects and be able to browse the |
| outgoing references, use the |
| <span class="keyword cmdname">*</span> |
| symbol: |
| </p> |
| |
| <pre class="pre codeblock">SELECT * FROM java.lang.String</pre> |
| |
| |
| <p class="p"><strong class="ph b">Select specific columns</strong></p> |
| |
| <p class="p"> |
| Alternatively, one can select the fields to be |
| displayed: |
| </p> |
| |
| <pre class="pre codeblock">SELECT toString(s), s.count, s.value FROM java.lang.String s</pre> |
| |
| <p class="p"> |
| The resulting table knows about the underlying object. |
| So you can use the context menu to open further views on |
| the object at hand. Use the @ symbol to access Java |
| attributes and methods of the objects. There are also a |
| number of built-in functions available to extract common |
| information: |
| </p> |
| |
| <pre class="pre codeblock">SELECT toString(s), s.@usedHeapSize, |
| s.@retainedHeapSize FROM java.lang.String s</pre> |
| |
| <p class="p"> |
| The section on |
| <a class="xref" href="propertyaccessors.html"> |
| Property Accessors |
| </a> |
| contains details on the commonly available attributes. |
| </p> |
| |
| <p class="p"><strong class="ph b">Provide column names</strong></p> |
| |
| <p class="p">Use the AS keyword to name the columns:</p> |
| |
| <pre class="pre codeblock">SELECT toString(s) AS Value, |
| s.@usedHeapSize AS "Shallow Size", |
| s.@retainedHeapSize AS "Retained Size" |
| FROM java.lang.String s</pre> |
| |
| <p class="p"> |
| Use the |
| <span class="keyword cmdname">AS RETAINED SET</span> |
| keyword to get the set of objects retained by your |
| selection: |
| </p> |
| |
| <pre class="pre codeblock">SELECT AS RETAINED SET * FROM java.lang.String</pre> |
| |
| <p class="p"><strong class="ph b">Flatten select items into an object list</strong></p> |
| |
| <p class="p"> |
| Use the |
| <span class="keyword cmdname">OBJECTS</span> |
| to interpret the items in the |
| <span class="keyword cmdname">SELECT</span> |
| clause as objects: |
| </p> |
| |
| <pre class="pre codeblock">SELECT OBJECTS dominators(s) FROM java.lang.String s</pre> |
| |
| <p class="p"> |
| The function |
| <span class="keyword cmdname">dominators()</span> |
| returns an array of objects. Therefore the query returns |
| a list of object lists, i.e. arrays. By using the |
| keyword |
| <span class="keyword cmdname">OBJECTS</span> |
| , we force the OQL to reduce this into a single list of |
| objects. |
| </p> |
| |
| <p class="p"><strong class="ph b">Select unique objects</strong></p> |
| |
| <p class="p"> |
| Use the |
| <span class="keyword cmdname">DISTINCT</span> |
| keyword to only select unique objects: |
| </p> |
| |
| <pre class="pre codeblock">SELECT DISTINCT * FROM OBJECTS 0,1,1,2</pre> |
| |
| <p class="p"> |
| Use the |
| <span class="keyword cmdname">DISTINCT OBJECTS</span> |
| keyword to only select unique objects from the result of the selected clause: |
| </p> |
| |
| <pre class="pre codeblock">SELECT DISTINCT OBJECTS classof(s) FROM java.lang.String s</pre> |
| |
| <p class="p"> |
| The function |
| <span class="keyword cmdname">classof</span> |
| returns the class object. Of course, all Strings have |
| the same class. The <span class="keyword cmdname">OBJECTS</span> converts the underlying row with a String object |
| and a displayed value of the class object |
| to the object represented by the result of the <span class="keyword cmdname">classof</span> function. |
| Without the <span class="keyword cmdname">DISTINCT OBJECTS</span> |
| keywords, the query would result in a list with as many |
| rows with the same class as there are Strings. |
| </p> |
| |
| <p class="p"><strong class="ph b">Expressions (experimental, Memory Analyzer 1.4 or later)</strong></p> |
| |
| <p class="p"> |
| Use the expressions for the select item, including string concatenation: |
| </p> |
| |
| <pre class="pre codeblock">SELECT s.@objectId, s.@objectId * 2, "The object ID is "+@objectId FROM OBJECTS 0,1,1,2 s</pre> |
| |
| <p class="p"> |
| With Memory Analyzer 1.4 or later expressions and sub-selects are allowed for select items. More complex |
| expressions may need to be parenthesized. This is currently in the test phase. |
| </p> |
| |
| </div> |
| |
| </div> |
| |
| <div class="related-links"> |
| <div class="familylinks"> |
| <div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../reference/oqlsyntax.html">OQL Syntax</a></div> |
| </div> |
| </div> |
| |
| </body> |
| </html> |