Log Message: |
DERBY-673 Get rid of the NodeFactory
Patch derby-673-3.
a) Replaced the old init methods in "*Node.java" classes with
constructors. Some logical node types have different "C_NodeType"
values in their nodeType field after construction but still share
the same node class. I have not attempted to increase the number of
node classes to match logical == physical node classes this
once. Actually one class was removed because it unused:
"SQLBooleanConstantNode". "IsNode" is also currently unused but
there is a JIRA to make use of it (DERBY-5973), so I left it in
place.
Boxed argument types were replaced by primitive types except in a
few cases where instanceof was used on them to detect type
overloading; this could be gotten rid of by adding more
constructors.
Since the constructor arguments are now strongly typed, a great
many casts were removed in the process and readability is improved
a lot.
In some cases the old init procedures did computations before
calling "super.init". Since the call to the corresponding super
constructor needs to be the first code in a constructor, I
sometimes had to introduce new private static methods to compute
the correct arguments to send on to the super class constructor,
e.g. "getTypeId" in "UserTypeConstantNode". I think there is some
redundancy here that could be removed in a follow-up patch.
All the non-abstract node classes (still) set their corresponding
"C_NodeType" value; but in many (most?) cases the field is no
longer needed. This could be improved by removing them altogether
and introduced class constants where needed to differentiate
between logical node type mapped to one class. This is already done
halfheartedly to some extent, e.g. enum "Sign" in "IsNullNode".
The old "tools/jar/DBMSnodes.properties" file could be removed
altogether since the node classes are now added automatically due
to dependencies that the compiler can see (no longer constructed by
reflection).
The old nodeFactory method "doJoinOrderOptimization" was moved to
the OptimizerFactory now that the NodeFactory has gone.
b) Added @Override tags to methods that override existing methods (not those
that merely implement an interface)
c) Removed unused imports and sorted import statements for ease of future
maintenance by IDEs
d) Renamed variables that shadowed class members
e) Replaced usage of StringBuffer with StringBuilder
f) Restricted public visibility to package private for all classes, methods and
members in compile/impl unless they needed more visibility according to
actual usage.
g) Made List arguments to node classes use generics in those cases it was
missing.
e) Renamed some node types to make the the type mirror the node class correctly
(there were only very few exceptions to that rule), e.g. LIKE_OPERATOR_NODE
-> LIKE_ESCAPE_OPERATOR_NODE since the class is called
LikeEscapeOperatorNode.
f) Reduced scope of some variables: initialized to null values never used long
before actual usage in code. By moving the declaration closed to usage, the
unnecessary initialization could often be removed.
g) Fixed some spelling errors in comments.
h) Renamed some SQL-related constants (StoredFormatIds, TypeId) from "longint"
" to "bigint" to reflect Derby SQL syntax.
|