arlut.csd.ganymede
Class DBQueryHandler

java.lang.Object
  |
  +--arlut.csd.ganymede.DBQueryHandler

public class DBQueryHandler
extends java.lang.Object

This class is the query processing engine for the Ganymede database. Static methods in this class are used to test a query tree against an individual object in the database.

The GanymedeSession's queryDispatch() method contains most of the query engine's logic (including namespace-indexed query optimization). This class is just responsible for applying a recursive QueryNode tree to a particular object.

See Also:
QueryNode, Query

Field Summary
(package private) static boolean debug
           
 
Constructor Summary
DBQueryHandler()
           
 
Method Summary
private static boolean compareIPs(java.lang.Byte[] param1, java.lang.Byte[] param2)
          IP address values are encoded as byte arrays in the Ganymede server..
private static boolean compareString(arlut.csd.ganymede.QueryDataNode n, java.lang.String string1, java.lang.String string2)
          string1 is the query value provided by the client, string2 is the value we are testing.
private static boolean compareStringArray(arlut.csd.ganymede.QueryDataNode n, java.lang.String queryValue, java.util.Vector values)
           
private static boolean compareStrings(arlut.csd.ganymede.QueryDataNode n, java.lang.String queryValue, java.lang.String value)
           
private static java.lang.Byte[] ipAddrNoPad(java.lang.Byte[] ipaddr)
          This helper method extracts the leading octets from the supplied IP address that are not all zeros.
private static boolean ipBeginsWith(java.lang.Byte[] param1, java.lang.Byte[] param2)
          IP address values are encoded as byte arrays in the Ganymede server..
private static boolean ipEndsWith(java.lang.Byte[] param1, java.lang.Byte[] param2)
          IP address values are encoded as byte arrays in the Ganymede server..
static boolean matches(arlut.csd.ganymede.GanymedeSession session, arlut.csd.ganymede.Query q, arlut.csd.ganymede.DBObject obj)
          This method compares an object with a submitted query, returning true if the object matches the query.
static boolean nodeMatch(arlut.csd.ganymede.GanymedeSession session, arlut.csd.ganymede.QueryNode qN, arlut.csd.ganymede.DBObject obj)
          Recursive static method to compare a Query tree against an object in the database.
private static short s2u(byte b)
          This method maps a u2s-encoded signed byte value to an int value between 0 and 255 inclusive.
private static byte u2s(int x)
          This method maps an int value between 0 and 255 inclusive to a legal signed byte value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

static final boolean debug
See Also:
Constant Field Values
Constructor Detail

DBQueryHandler

public DBQueryHandler()
Method Detail

matches

public static final boolean matches(arlut.csd.ganymede.GanymedeSession session,
                                    arlut.csd.ganymede.Query q,
                                    arlut.csd.ganymede.DBObject obj)
This method compares an object with a submitted query, returning true if the object matches the query.

Parameters:
session - The GanymedeSession performing the query. This parameter is used to access the database to find the object's label if the query contains any clauses matching against the object's label.
q - The Query being compared to this object.
obj - The object being tested.

nodeMatch

public static final boolean nodeMatch(arlut.csd.ganymede.GanymedeSession session,
                                      arlut.csd.ganymede.QueryNode qN,
                                      arlut.csd.ganymede.DBObject obj)
Recursive static method to compare a Query tree against an object in the database.

Parameters:
session - The GanymedeSession performing the query. This parameter is used to access the database to find the object's label if the query contains any clauses matching against the object's label.
qN - The QueryNode being compared to this object.
obj - The object being tested.

compareStrings

private static boolean compareStrings(arlut.csd.ganymede.QueryDataNode n,
                                      java.lang.String queryValue,
                                      java.lang.String value)

compareStringArray

private static boolean compareStringArray(arlut.csd.ganymede.QueryDataNode n,
                                          java.lang.String queryValue,
                                          java.util.Vector values)

compareString

private static boolean compareString(arlut.csd.ganymede.QueryDataNode n,
                                     java.lang.String string1,
                                     java.lang.String string2)
string1 is the query value provided by the client, string2 is the value we are testing.


compareIPs

private static boolean compareIPs(java.lang.Byte[] param1,
                                  java.lang.Byte[] param2)
IP address values are encoded as byte arrays in the Ganymede server.. this method is used to compare two IP address values for equality.


ipBeginsWith

private static boolean ipBeginsWith(java.lang.Byte[] param1,
                                    java.lang.Byte[] param2)
IP address values are encoded as byte arrays in the Ganymede server.. this method is used to compare two IP address values for a prefix relationship.

Returns:
Returns true if param1 begins with param2.

ipEndsWith

private static boolean ipEndsWith(java.lang.Byte[] param1,
                                  java.lang.Byte[] param2)
IP address values are encoded as byte arrays in the Ganymede server.. this method is used to compare two IP address values for a suffix relationship.

Returns:
Returns true if param1 ends with param2.

ipAddrNoPad

private static java.lang.Byte[] ipAddrNoPad(java.lang.Byte[] ipaddr)

This helper method extracts the leading octets from the supplied IP address that are not all zeros. I.e., for the address 129.0.116.0, ipAddrNoPad() would return 129.0.116, where for the address 129.116.0.0, ipAddrNoPad() would return 129.116.

Note that, like all Ganymede code dealing with IP addresses, Ganymede is using the u2s() and s2u() methods here to handle encoded unsigned values in the Java signed byte/Byte type/object.


u2s

private static final byte u2s(int x)

This method maps an int value between 0 and 255 inclusive to a legal signed byte value.


s2u

private static final short s2u(byte b)

This method maps a u2s-encoded signed byte value to an int value between 0 and 255 inclusive.