Java Doc for Qualifier.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » iapi » store » access » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derby.iapi.store.access 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.derby.iapi.store.access.Qualifier

All known Subclasses:   org.apache.derby.impl.sql.execute.GenericQualifier,  org.apache.derby.impl.store.access.UTFQualifier,  org.apache.derbyTesting.unitTests.store.QualifierUtil,
Qualifier
public interface Qualifier (Code)

A structure which is used to "qualify" a column. Specifies that the column value in a given column identified by column id is to be compared via a specific operator to a particular DataValueDescriptor value.

The implementation of this interface is provided by the client; the methods of Qualifier are the methods the access code uses to use it.

Arrays of qualifiers are provided to restrict the rows returned by scans. A row is returned from a scan if all qualifications in the array return true.

A qualification returns true if in the following pseudo-code compare_result is true.

 if (qualifier.negateCompareResult())
 {
 compare_result = 
 row[(qualifier.getColumnId())].compare(
 qualifier.getOperator(), 
 qualifier.getOrderable(),
 qualifier.getOrderedNulls(), 
 qualifier.getUnknownRV()) 
 if (qualifier.negateCompareResult())
 {
 compare_result = !(compare_result);
 }
 }
 

Qualifiers are often passed through interfaces as a set of Qualifiers, rather than one at a time, for example see the qualifier argument in TransactionController.openScan().

To make this consistent the following protocols are to be used when passing around sets of Qualifiers.

A single dimensional array is to be used to pass around a set of AND'd qualifiers. Thus qualifier[] argument is to be treated as:

 qualifier[0] AND qualifer[1] ... AND qualifier[qualifer.length - 1]
 

A two dimensional array is to be used to pass around a AND's and OR's in conjunctive normal form. The top slot of the 2 dimensional array is optimized for the more frequent where no OR's are present. The first array slot is always a list of AND's to be treated as described above for single dimensional AND qualifier arrays. The subsequent slots are to be treated as AND'd arrays of OR's. Thus the 2 dimensional array qual[][] argument is to be treated as the following, note if qual.length = 1 then only the first array is valid and it is and an array of AND clauses:

 (qual[0][0] AND qual[0][0] ... AND qual[0][qual[0].length - 1])
 AND
 (qual[1][0] OR  qual[1][1] ... OR  qual[1][qual[1].length - 1])
 AND
 (qual[2][0] OR  qual[2][1] ... OR  qual[2][qual[2].length - 1])
 ...
 AND (qual[qual.length - 1][0] OR  qual[1][1] ... OR  qual[1][2])
 

If any of the array's qual[0].length ... qual[qual.length -1] are 0 length they will be evaluated as TRUE; but they must be not NULL. See Example 4 for encoding of (a or b) that takes advantage of this.

Note that any of the arrays qual[0].length ... qual[qual.length -1] may also be of length 1, thus no guarantee is made the presence of OR predicates if qual.length > 1. See example 1a.

The following give pseudo-code examples of building Qualifier arrays:

Example 1: "a AND b AND c"

 qualifier = new Qualifier[1][3]; // 3 AND clauses
 qualifier[0][0] = a
 qualifier[0][1] = b
 qualifier[0][2] = c
 

Example 1a "a AND b AND c" - less efficient than example 1 but legal

 qualifier = new Qualifier[3]; // 3 AND clauses
 qualifier[0] = new Qualifier[1];
 qualifier[1] = new Qualifier[1];
 qualifier[2] = new Qualifier[1];
 qualifier[0][0] = a
 qualifier[1][0] = b
 qualifier[2][0] = c
 

Example 2: "(f) AND (a OR b) AND (c OR d OR e)" Would be represented by an array that looks like the following:

 qualifier = new Qualifier[3]; // 3 and clauses
 qualifier[0] = new Qualifier[1]; // to be intitialized to f
 qualifier[1] = new Qualifier[2]; // to be initialized to (a OR b)
 qualifier[2] = new Qualifier[3]; // to be initialized to (c OR d OR e)
 qualifier[0][0] = f
 qualifier[1][0] = a
 qualifier[1][1] = b
 qualifier[2][0] = c
 qualifier[2][1] = d
 qualifier[2][2] = e
 

Example 3: "(a OR b) AND (c OR d) AND (e OR f)"

 qualifier = new Qualifier[3]; // 3 and clauses
 qualifier = new Qualifier[4]; // 4 and clauses
 qualifier[0] = new Qualifier[1]; // to be intitialized to TRUE
 qualifier[1] = new Qualifier[2]; // to be initialized to (a OR b)
 qualifier[2] = new Qualifier[2]; // to be initialized to (c OR d)
 qualifier[3] = new Qualifier[2]; // to be initialized to (e OR f)
 qualifier[0][0] = TRUE
 qualifier[1][0] = a
 qualifier[1][1] = b
 qualifier[2][0] = c
 qualifier[2][1] = d
 qualifier[3][0] = e
 qualifier[3][1] = f
 

Example 4: "(a OR b)"

 qualifier = new Qualifier[2]; // 2 and clauses
 qualifier[0] = new Qualifier[0]; // 0 length array is TRUE
 qualifier[1] = new Qualifier[2]; // to be initialized to (a OR b)
 qualifier[1][0] = a
 qualifier[1][1] = b
 

See Also:   ScanController
See Also:   TransactionController.openScan
See Also:   
See Also:   DataValueDescriptor.compare


Field Summary
final public static  intCONSTANT
    
final public static  intQUERY_INVARIANT
    
final public static  intSCAN_INVARIANT
    
final public static  intVARIANT
     The DataValueDescriptor can be 1 of 4 types:
  • VARIANT - cannot be cached as its value can vary within a scan
  • SCAN_INVARIANT - can be cached within a scan as its value will not change within a scan
  • QUERY_INVARIANT- can be cached across the life of the query as its value will never change
  • CONSTANT - can be cached across executions.


Method Summary
 voidclearOrderableCache()
     Clear the DataValueDescriptor cache, if one exists.
 intgetColumnId()
     Get the (zero based) id of the column to be qualified.
 intgetOperator()
     Get the operator to use in the comparison.
 DataValueDescriptorgetOrderable()
     Get the value that the column is to be compared to.
 booleangetOrderedNulls()
     Get the getOrderedNulls argument to use in the comparison.
 booleangetUnknownRV()
     Get the getOrderedNulls argument to use in the comparison.
 booleannegateCompareResult()
     Determine if the result from the compare operation should be negated.
 voidreinitialize()
     This method reinitializes all the state of the Qualifier.

Field Detail
CONSTANT
final public static int CONSTANT(Code)



QUERY_INVARIANT
final public static int QUERY_INVARIANT(Code)



SCAN_INVARIANT
final public static int SCAN_INVARIANT(Code)



VARIANT
final public static int VARIANT(Code)
The DataValueDescriptor can be 1 of 4 types:
  • VARIANT - cannot be cached as its value can vary within a scan
  • SCAN_INVARIANT - can be cached within a scan as its value will not change within a scan
  • QUERY_INVARIANT- can be cached across the life of the query as its value will never change
  • CONSTANT - can be cached across executions.

NOTE: the following is guaranteed: VARIANT < SCAN_INVARIANT < QUERY_INVARIANT < CONSTANT






Method Detail
clearOrderableCache
void clearOrderableCache()(Code)
Clear the DataValueDescriptor cache, if one exists. (The DataValueDescriptor can be 1 of 3 types: o VARIANT - cannot be cached as its value can vary within a scan o SCAN_INVARIANT - can be cached within a scan as its value will not change within a scan o QUERY_INVARIANT- can be cached across the life of the query as its value will never change



getColumnId
int getColumnId()(Code)
Get the (zero based) id of the column to be qualified.

This id is the column number of the column in the table, no matter whether a partial column set is being retrieved by the actual fetch. Note that the column being specified in the qualifier must appear in the column list being fetched.




getOperator
int getOperator()(Code)
Get the operator to use in the comparison.
See Also:   DataValueDescriptor.compare



getOrderable
DataValueDescriptor getOrderable() throws StandardException(Code)
Get the value that the column is to be compared to.
exception:
  StandardException - Thrown on error



getOrderedNulls
boolean getOrderedNulls()(Code)
Get the getOrderedNulls argument to use in the comparison.
See Also:   DataValueDescriptor.compare



getUnknownRV
boolean getUnknownRV()(Code)
Get the getOrderedNulls argument to use in the comparison.
See Also:   DataValueDescriptor.compare



negateCompareResult
boolean negateCompareResult()(Code)
Determine if the result from the compare operation should be negated. If true then only rows which fail the compare operation will qualify.
See Also:   DataValueDescriptor.compare



reinitialize
void reinitialize()(Code)
This method reinitializes all the state of the Qualifier. It is used to distinguish between resetting something that is query invariant and something that is constant over every execution of a query. Basically, clearOrderableCache() will only clear out its cache if it is a VARIANT or SCAN_INVARIANT value. However, each time a query is executed, the QUERY_INVARIANT qualifiers need to be reset.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.