teiid SVN: r802 - in trunk/adminshell/src/main: java/bsh and 3 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-04-20 12:16:47 -0400 (Mon, 20 Apr 2009)
New Revision: 802
Added:
trunk/adminshell/src/main/java/bsh/
trunk/adminshell/src/main/java/bsh/Interpreter.java
Modified:
trunk/adminshell/src/main/java/com/metamatrix/script/shell/JConsole.java
trunk/adminshell/src/main/java/com/metamatrix/script/shell/MMAdmin.java
trunk/adminshell/src/main/java/com/metamatrix/script/shell/ReaderInterceptor.java
trunk/adminshell/src/main/resources/commands/makeWorkspace.bsh
trunk/adminshell/src/main/resources/commands/mparse.bsh
trunk/adminshell/src/main/resources/commands/printBanner.bsh
trunk/adminshell/src/main/resources/scripts/adminapi.bsh
trunk/adminshell/src/main/resources/scripts/serveradmin.bsh
trunk/adminshell/src/main/resources/scripts/util.bsh
Log:
TEIID-157, TEIID-224, TEIID-398: Added a short text, describing the help when the tool is started in the interactive mode, fixed the NPE, removed the "printStackTraces" to cut out the verbose traces, made "help" and "exit" work with out function format.
Added: trunk/adminshell/src/main/java/bsh/Interpreter.java
===================================================================
--- trunk/adminshell/src/main/java/bsh/Interpreter.java (rev 0)
+++ trunk/adminshell/src/main/java/bsh/Interpreter.java 2009-04-20 16:16:47 UTC (rev 802)
@@ -0,0 +1,1250 @@
+/*****************************************************************************
+ * *
+ * This file is part of the BeanShell Java Scripting distribution. *
+ * Documentation and updates may be found at http://www.beanshell.org/ *
+ * *
+ * Sun Public License Notice: *
+ * *
+ * The contents of this file are subject to the Sun Public License Version *
+ * 1.0 (the "License"); you may not use this file except in compliance with *
+ * the License. A copy of the License is available at http://www.sun.com *
+ * *
+ * The Original Code is BeanShell. The Initial Developer of the Original *
+ * Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright *
+ * (C) 2000. All Rights Reserved. *
+ * *
+ * GNU Public License Notice: *
+ * *
+ * Alternatively, the contents of this file may be used under the terms of *
+ * the GNU Lesser General Public License (the "LGPL"), in which case the *
+ * provisions of LGPL are applicable instead of those above. If you wish to *
+ * allow use of your version of this file only under the terms of the LGPL *
+ * and not to allow others to use your version of this file under the SPL, *
+ * indicate your decision by deleting the provisions above and replace *
+ * them with the notice and other provisions required by the LGPL. If you *
+ * do not delete the provisions above, a recipient may use your version of *
+ * this file under either the SPL or the LGPL. *
+ * *
+ * Patrick Niemeyer (pat(a)pat.net) *
+ * Author of Learning Java, O'Reilly & Associates *
+ * http://www.pat.net/~pat/ *
+ * *
+ *****************************************************************************/
+
+package bsh;
+
+import java.util.Vector;
+import java.io.*;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ The BeanShell script interpreter.
+
+ An instance of Interpreter can be used to source scripts and evaluate
+ statements or expressions.
+ <p>
+ Here are some examples:
+
+ <p><blockquote><pre>
+ Interpeter bsh = new Interpreter();
+
+ // Evaluate statements and expressions
+ bsh.eval("foo=Math.sin(0.5)");
+ bsh.eval("bar=foo*5; bar=Math.cos(bar);");
+ bsh.eval("for(i=0; i<10; i++) { print(\"hello\"); }");
+ // same as above using java syntax and apis only
+ bsh.eval("for(int i=0; i<10; i++) { System.out.println(\"hello\"); }");
+
+ // Source from files or streams
+ bsh.source("myscript.bsh"); // or bsh.eval("source(\"myscript.bsh\")");
+
+ // Use set() and get() to pass objects in and out of variables
+ bsh.set( "date", new Date() );
+ Date date = (Date)bsh.get( "date" );
+ // This would also work:
+ Date date = (Date)bsh.eval( "date" );
+
+ bsh.eval("year = date.getYear()");
+ Integer year = (Integer)bsh.get("year"); // primitives use wrappers
+
+ // With Java1.3+ scripts can implement arbitrary interfaces...
+ // Script an awt event handler (or source it from a file, more likely)
+ bsh.eval( "actionPerformed( e ) { print( e ); }");
+ // Get a reference to the script object (implementing the interface)
+ ActionListener scriptedHandler =
+ (ActionListener)bsh.eval("return (ActionListener)this");
+ // Use the scripted event handler normally...
+ new JButton.addActionListener( script );
+ </pre></blockquote>
+ <p>
+
+ In the above examples we showed a single interpreter instance, however
+ you may wish to use many instances, depending on the application and how
+ you structure your scripts. Interpreter instances are very light weight
+ to create, however if you are going to execute the same script repeatedly
+ and require maximum performance you should consider scripting the code as
+ a method and invoking the scripted method each time on the same interpreter
+ instance (using eval()).
+ <p>
+
+ See the BeanShell User's Manual for more information.
+
+ PrintStackTrace were removed from run method, from original version.
+*/
+public class Interpreter
+ implements Runnable, ConsoleInterface,Serializable
+{
+ /* --- Begin static members --- */
+
+ public static final String VERSION = "2.0b5";
+ /*
+ Debug utils are static so that they are reachable by code that doesn't
+ necessarily have an interpreter reference (e.g. tracing in utils).
+ In the future we may want to allow debug/trace to be turned on on
+ a per interpreter basis, in which case we'll need to use the parent
+ reference in some way to determine the scope of the command that
+ turns it on or off.
+ */
+ public static boolean DEBUG, TRACE, LOCALSCOPING;
+
+ // This should be per instance
+ transient static PrintStream debug;
+ static String systemLineSeparator = "\n"; // default
+
+ static {
+ staticInit();
+ }
+
+ /** Shared system object visible under bsh.system */
+ static This sharedObject;
+
+ /**
+ Strict Java mode
+ @see #setStrictJava( boolean )
+ */
+ private boolean strictJava = false;
+
+ /* --- End static members --- */
+
+ /* --- Instance data --- */
+
+ transient Parser parser;
+ NameSpace globalNameSpace;
+ transient Reader in;
+ transient PrintStream out;
+ transient PrintStream err;
+ ConsoleInterface console;
+
+ /** If this interpeter is a child of another, the parent */
+ Interpreter parent;
+
+ /** The name of the file or other source that this interpreter is reading */
+ String sourceFileInfo;
+
+ /** by default in interactive mode System.exit() on EOF */
+ private boolean exitOnEOF = true;
+
+ protected boolean
+ evalOnly, // Interpreter has no input stream, use eval() only
+ interactive; // Interpreter has a user, print prompts, etc.
+
+ /** Control the verbose printing of results for the show() command. */
+ private boolean showResults;
+
+ /* --- End instance data --- */
+
+ /**
+ The main constructor.
+ All constructors should now pass through here.
+
+ @param namespace If namespace is non-null then this interpreter's
+ root namespace will be set to the one provided. If it is null a new
+ one will be created for it.
+ @param parent The parent interpreter if this interpreter is a child
+ of another. May be null. Children share a BshClassManager with
+ their parent instance.
+ @param sourceFileInfo An informative string holding the filename
+ or other description of the source from which this interpreter is
+ reading... used for debugging. May be null.
+ */
+ public Interpreter(
+ Reader in, PrintStream out, PrintStream err,
+ boolean interactive, NameSpace namespace,
+ Interpreter parent, String sourceFileInfo )
+ {
+ //System.out.println("New Interpreter: "+this +", sourcefile = "+sourceFileInfo );
+ parser = new Parser( in );
+ long t1=System.currentTimeMillis();
+ this.in = in;
+ this.out = out;
+ this.err = err;
+ this.interactive = interactive;
+ debug = err;
+ this.parent = parent;
+ if ( parent != null )
+ setStrictJava( parent.getStrictJava() );
+ this.sourceFileInfo = sourceFileInfo;
+
+ BshClassManager bcm = BshClassManager.createClassManager( this );
+ if ( namespace == null )
+ this.globalNameSpace = new NameSpace( bcm, "global");
+ else
+ this.globalNameSpace = namespace;
+
+ // now done in NameSpace automatically when root
+ // The classes which are imported by default
+ //globalNameSpace.loadDefaultImports();
+
+ /*
+ Create the root "bsh" system object if it doesn't exist.
+ */
+ if ( ! ( getu("bsh") instanceof bsh.This ) )
+ initRootSystemObject();
+
+ if ( interactive )
+ loadRCFiles();
+
+ long t2=System.currentTimeMillis();
+ if ( Interpreter.DEBUG )
+ Interpreter.debug("Time to initialize interpreter: "+(t2-t1));
+ }
+
+ public Interpreter(
+ Reader in, PrintStream out, PrintStream err,
+ boolean interactive, NameSpace namespace)
+ {
+ this( in, out, err, interactive, namespace, null, null );
+ }
+
+ public Interpreter(
+ Reader in, PrintStream out, PrintStream err, boolean interactive)
+ {
+ this(in, out, err, interactive, null);
+ }
+
+ /**
+ Construct a new interactive interpreter attached to the specified
+ console using the specified parent namespace.
+ */
+ public Interpreter(ConsoleInterface console, NameSpace globalNameSpace) {
+
+ this( console.getIn(), console.getOut(), console.getErr(),
+ true, globalNameSpace );
+
+ setConsole( console );
+ }
+
+ /**
+ Construct a new interactive interpreter attached to the specified
+ console.
+ */
+ public Interpreter(ConsoleInterface console) {
+ this(console, null);
+ }
+
+ /**
+ Create an interpreter for evaluation only.
+ */
+ public Interpreter()
+ {
+ this( new StringReader(""),
+ System.out, System.err, false, null );
+ evalOnly = true;
+ setu( "bsh.evalOnly", Primitive.TRUE );
+ }
+
+ // End constructors
+
+ /**
+ Attach a console
+ Note: this method is incomplete.
+ */
+ public void setConsole( ConsoleInterface console ) {
+ this.console = console;
+ setu( "bsh.console", console );
+ // redundant with constructor
+ setOut( console.getOut() );
+ setErr( console.getErr() );
+ // need to set the input stream - reinit the parser?
+ }
+
+ private void initRootSystemObject()
+ {
+ BshClassManager bcm = getClassManager();
+ // bsh
+ setu("bsh", new NameSpace( bcm, "Bsh Object" ).getThis( this ) );
+
+ // init the static shared sharedObject if it's not there yet
+ if ( sharedObject == null )
+ sharedObject = new NameSpace(
+ bcm, "Bsh Shared System Object" ).getThis( this );
+ // bsh.system
+ setu( "bsh.system", sharedObject );
+ setu( "bsh.shared", sharedObject ); // alias
+
+ // bsh.help
+ This helpText = new NameSpace(
+ bcm, "Bsh Command Help Text" ).getThis( this );
+ setu( "bsh.help", helpText );
+
+ // bsh.cwd
+ try {
+ setu( "bsh.cwd", System.getProperty("user.dir") );
+ } catch ( SecurityException e ) {
+ // applets can't see sys props
+ setu( "bsh.cwd", "." );
+ }
+
+ // bsh.interactive
+ setu( "bsh.interactive", interactive ? Primitive.TRUE : Primitive.FALSE );
+ // bsh.evalOnly
+ setu( "bsh.evalOnly", evalOnly ? Primitive.TRUE : Primitive.FALSE );
+ }
+
+ /**
+ Set the global namespace for this interpreter.
+ <p>
+
+ Note: This is here for completeness. If you're using this a lot
+ it may be an indication that you are doing more work than you have
+ to. For example, caching the interpreter instance rather than the
+ namespace should not add a significant overhead. No state other
+ than the debug status is stored in the interpreter.
+ <p>
+
+ All features of the namespace can also be accessed using the
+ interpreter via eval() and the script variable 'this.namespace'
+ (or global.namespace as necessary).
+ */
+ public void setNameSpace( NameSpace globalNameSpace ) {
+ this.globalNameSpace = globalNameSpace;
+ }
+
+ /**
+ Get the global namespace of this interpreter.
+ <p>
+
+ Note: This is here for completeness. If you're using this a lot
+ it may be an indication that you are doing more work than you have
+ to. For example, caching the interpreter instance rather than the
+ namespace should not add a significant overhead. No state other than
+ the debug status is stored in the interpreter.
+ <p>
+
+ All features of the namespace can also be accessed using the
+ interpreter via eval() and the script variable 'this.namespace'
+ (or global.namespace as necessary).
+ */
+ public NameSpace getNameSpace() {
+ return globalNameSpace;
+ }
+
+ /**
+ Run the text only interpreter on the command line or specify a file.
+ */
+ public static void main( String [] args )
+ {
+ if ( args.length > 0 ) {
+ String filename = args[0];
+
+ String [] bshArgs;
+ if ( args.length > 1 ) {
+ bshArgs = new String [ args.length -1 ];
+ System.arraycopy( args, 1, bshArgs, 0, args.length-1 );
+ } else
+ bshArgs = new String [0];
+
+ Interpreter interpreter = new Interpreter();
+ //System.out.println("run i = "+interpreter);
+ interpreter.setu( "bsh.args", bshArgs );
+ try {
+ Object result =
+ interpreter.source( filename, interpreter.globalNameSpace );
+ if ( result instanceof Class )
+ try {
+ invokeMain( (Class)result, bshArgs );
+ } catch ( Exception e )
+ {
+ Object o = e;
+ if ( e instanceof InvocationTargetException )
+ o = ((InvocationTargetException)e)
+ .getTargetException();
+ System.err.println(
+ "Class: "+result+" main method threw exception:"+o);
+ }
+ } catch ( FileNotFoundException e ) {
+ System.out.println("File not found: "+e);
+ } catch ( TargetError e ) {
+ System.out.println("Script threw exception: "+e);
+ if ( e.inNativeCode() )
+ e.printStackTrace( DEBUG, System.err );
+ } catch ( EvalError e ) {
+ System.out.println("Evaluation Error: "+e);
+ } catch ( IOException e ) {
+ System.out.println("I/O Error: "+e);
+ }
+ } else
+ {
+ // Workaround for JDK bug 4071281, where system.in.available()
+ // returns too large a value. This bug has been fixed in JDK 1.2.
+ InputStream src;
+ if ( System.getProperty("os.name").startsWith("Windows")
+ && System.getProperty("java.version").startsWith("1.1."))
+ {
+ src = new FilterInputStream(System.in) {
+ public int available() throws IOException {
+ return 0;
+ }
+ };
+ }
+ else
+ src = System.in;
+
+ Reader in = new CommandLineReader( new InputStreamReader(src));
+ Interpreter interpreter =
+ new Interpreter( in, System.out, System.err, true );
+ interpreter.run();
+ }
+ }
+
+ public static void invokeMain( Class clas, String [] args )
+ throws Exception
+ {
+ Method main = Reflect.resolveJavaMethod(
+ null/*BshClassManager*/, clas, "main",
+ new Class [] { String [].class }, true/*onlyStatic*/ );
+ if ( main != null )
+ main.invoke( null, new Object [] { args } );
+ }
+
+ /**
+ Run interactively. (printing prompts, etc.)
+ */
+ public void run()
+ {
+ if(evalOnly)
+ throw new RuntimeException("bsh Interpreter: No stream");
+
+ /*
+ We'll print our banner using eval(String) in order to
+ exercise the parser and get the basic expression classes loaded...
+ This ameliorates the delay after typing the first statement.
+ */
+ if ( interactive )
+ try {
+ eval("printBanner();");
+ } catch ( EvalError e ) {
+ println(
+ "BeanShell "+VERSION+" - by Pat Niemeyer (pat(a)pat.net)");
+ }
+
+ // init the callstack.
+ CallStack callstack = new CallStack( globalNameSpace );
+
+ boolean eof = false;
+ while( !eof )
+ {
+ try
+ {
+ // try to sync up the console
+ System.out.flush();
+ System.err.flush();
+ Thread.yield(); // this helps a little
+
+ if ( interactive )
+ print( getBshPrompt() );
+
+ eof = Line();
+
+ if( get_jjtree().nodeArity() > 0 ) // number of child nodes
+ {
+ SimpleNode node = (SimpleNode)(get_jjtree().rootNode());
+
+ if(DEBUG)
+ node.dump(">");
+
+ Object ret = node.eval( callstack, this );
+
+ // sanity check during development
+ if ( callstack.depth() > 1 )
+ throw new InterpreterError(
+ "Callstack growing: "+callstack);
+
+ if(ret instanceof ReturnControl)
+ ret = ((ReturnControl)ret).value;
+
+ if( ret != Primitive.VOID )
+ {
+ setu("$_", ret);
+ if ( showResults )
+ println("<" + ret + ">");
+ }
+ }
+ }
+ catch(ParseException e)
+ {
+ error("Parser Error: " + e.getMessage(DEBUG));
+ if ( DEBUG )
+ e.printStackTrace();
+ if(!interactive)
+ eof = true;
+
+ parser.reInitInput(in);
+ }
+ catch(InterpreterError e)
+ {
+ error("Internal Error: " + e.getMessage());
+ if(!interactive)
+ eof = true;
+ }
+ catch(TargetError e)
+ {
+ error("// Uncaught Exception: " + e );
+ if(!interactive)
+ eof = true;
+ setu("$_e", e.getTarget());
+ }
+ catch (EvalError e)
+ {
+ if ( interactive )
+ error( "EvalError: "+e.toString() );
+ else
+ error( "EvalError: "+e.getMessage() );
+
+ if(DEBUG)
+ e.printStackTrace();
+
+ if(!interactive)
+ eof = true;
+ }
+ catch(Exception e)
+ {
+ error("Unknown error: " + e);
+ if ( DEBUG )
+ e.printStackTrace();
+ if(!interactive)
+ eof = true;
+ }
+ catch(TokenMgrError e)
+ {
+ error("Error parsing input: " + e);
+
+ /*
+ We get stuck in infinite loops here when unicode escapes
+ fail. Must re-init the char stream reader
+ (ASCII_UCodeESC_CharStream.java)
+ */
+ parser.reInitTokenInput( in );
+
+ if(!interactive)
+ eof = true;
+ }
+ finally
+ {
+ get_jjtree().reset();
+ // reinit the callstack
+ if ( callstack.depth() > 1 ) {
+ callstack.clear();
+ callstack.push( globalNameSpace );
+ }
+ }
+ }
+
+ if ( interactive && exitOnEOF )
+ System.exit(0);
+ }
+
+ // begin source and eval
+
+ /**
+ Read text from fileName and eval it.
+ */
+ public Object source( String filename, NameSpace nameSpace )
+ throws FileNotFoundException, IOException, EvalError
+ {
+ File file = pathToFile( filename );
+ if ( Interpreter.DEBUG ) debug("Sourcing file: "+file);
+ Reader sourceIn = new BufferedReader( new FileReader(file) );
+ try {
+ return eval( sourceIn, nameSpace, filename );
+ } finally {
+ sourceIn.close();
+ }
+ }
+
+ /**
+ Read text from fileName and eval it.
+ Convenience method. Use the global namespace.
+ */
+ public Object source( String filename )
+ throws FileNotFoundException, IOException, EvalError
+ {
+ return source( filename, globalNameSpace );
+ }
+
+ /**
+ Spawn a non-interactive local interpreter to evaluate text in the
+ specified namespace.
+
+ Return value is the evaluated object (or corresponding primitive
+ wrapper).
+
+ @param sourceFileInfo is for information purposes only. It is used to
+ display error messages (and in the future may be made available to
+ the script).
+ @throws EvalError on script problems
+ @throws TargetError on unhandled exceptions from the script
+ */
+ /*
+ Note: we need a form of eval that passes the callstack through...
+ */
+ /*
+ Can't this be combined with run() ?
+ run seems to have stuff in it for interactive vs. non-interactive...
+ compare them side by side and see what they do differently, aside from the
+ exception handling.
+ */
+
+ public Object eval(
+ Reader in, NameSpace nameSpace, String sourceFileInfo
+ /*, CallStack callstack */ )
+ throws EvalError
+ {
+ Object retVal = null;
+ if ( Interpreter.DEBUG ) debug("eval: nameSpace = "+nameSpace);
+
+ /*
+ Create non-interactive local interpreter for this namespace
+ with source from the input stream and out/err same as
+ this interpreter.
+ */
+ Interpreter localInterpreter =
+ new Interpreter(
+ in, out, err, false, nameSpace, this, sourceFileInfo );
+
+ CallStack callstack = new CallStack( nameSpace );
+
+ boolean eof = false;
+ while(!eof)
+ {
+ SimpleNode node = null;
+ try
+ {
+ eof = localInterpreter.Line();
+ if (localInterpreter.get_jjtree().nodeArity() > 0)
+ {
+ node = (SimpleNode)localInterpreter.get_jjtree().rootNode();
+ // quick filter for when we're running as a compiler only
+ if ( getSaveClasses()
+ && !(node instanceof BSHClassDeclaration)
+ && !(node instanceof BSHImportDeclaration )
+ && !(node instanceof BSHPackageDeclaration )
+ )
+ continue;
+
+ // nodes remember from where they were sourced
+ node.setSourceFile( sourceFileInfo );
+
+ if ( TRACE )
+ println( "// " +node.getText() );
+
+ retVal = node.eval( callstack, localInterpreter );
+
+ // sanity check during development
+ if ( callstack.depth() > 1 )
+ throw new InterpreterError(
+ "Callstack growing: "+callstack);
+
+ if ( retVal instanceof ReturnControl ) {
+ retVal = ((ReturnControl)retVal).value;
+ break; // non-interactive, return control now
+ }
+
+ if ( localInterpreter.showResults
+ && retVal != Primitive.VOID )
+ println("<" + retVal + ">");
+ }
+ } catch(ParseException e) {
+ /*
+ throw new EvalError(
+ "Sourced file: "+sourceFileInfo+" parser Error: "
+ + e.getMessage( DEBUG ), node, callstack );
+ */
+ if ( DEBUG )
+ // show extra "expecting..." info
+ error( e.getMessage(DEBUG) );
+
+ // add the source file info and throw again
+ e.setErrorSourceFile( sourceFileInfo );
+ throw e;
+
+ } catch ( InterpreterError e ) {
+ e.printStackTrace();
+ throw new EvalError(
+ "Sourced file: "+sourceFileInfo+" internal Error: "
+ + e.getMessage(), node, callstack);
+ } catch ( TargetError e ) {
+ // failsafe, set the Line as the origin of the error.
+ if ( e.getNode()==null )
+ e.setNode( node );
+ e.reThrow("Sourced file: "+sourceFileInfo);
+ } catch ( EvalError e) {
+ if ( DEBUG)
+ e.printStackTrace();
+ // failsafe, set the Line as the origin of the error.
+ if ( e.getNode()==null )
+ e.setNode( node );
+ e.reThrow( "Sourced file: "+sourceFileInfo );
+ } catch ( Exception e) {
+ if ( DEBUG)
+ e.printStackTrace();
+ throw new EvalError(
+ "Sourced file: "+sourceFileInfo+" unknown error: "
+ + e.getMessage(), node, callstack);
+ } catch(TokenMgrError e) {
+ throw new EvalError(
+ "Sourced file: "+sourceFileInfo+" Token Parsing Error: "
+ + e.getMessage(), node, callstack );
+ } finally {
+ localInterpreter.get_jjtree().reset();
+
+ // reinit the callstack
+ if ( callstack.depth() > 1 ) {
+ callstack.clear();
+ callstack.push( nameSpace );
+ }
+ }
+ }
+ return Primitive.unwrap( retVal );
+ }
+
+ /**
+ Evaluate the inputstream in this interpreter's global namespace.
+ */
+ public Object eval( Reader in ) throws EvalError
+ {
+ return eval( in, globalNameSpace, "eval stream" );
+ }
+
+ /**
+ Evaluate the string in this interpreter's global namespace.
+ */
+ public Object eval( String statements ) throws EvalError {
+ if ( Interpreter.DEBUG ) debug("eval(String): "+statements);
+ return eval(statements, globalNameSpace);
+ }
+
+ /**
+ Evaluate the string in the specified namespace.
+ */
+ public Object eval( String statements, NameSpace nameSpace )
+ throws EvalError
+ {
+
+ String s = ( statements.endsWith(";") ? statements : statements+";" );
+ return eval(
+ new StringReader(s), nameSpace,
+ "inline evaluation of: ``"+ showEvalString(s)+"''" );
+ }
+
+ private String showEvalString( String s ) {
+ s = s.replace('\n', ' ');
+ s = s.replace('\r', ' ');
+ if ( s.length() > 80 )
+ s = s.substring( 0, 80 ) + " . . . ";
+ return s;
+ }
+
+ // end source and eval
+
+ /**
+ Print an error message in a standard format on the output stream
+ associated with this interpreter. On the GUI console this will appear
+ in red, etc.
+ */
+ public final void error( Object o ) {
+ if ( console != null )
+ console.error( "// Error: " + o +"\n" );
+ else {
+ err.println("// Error: " + o );
+ err.flush();
+ }
+ }
+
+ // ConsoleInterface
+ // The interpreter reflexively implements the console interface that it
+ // uses. Should clean this up by using an inner class to implement the
+ // console for us.
+
+ /**
+ Get the input stream associated with this interpreter.
+ This may be be stdin or the GUI console.
+ */
+ public Reader getIn() { return in; }
+
+ /**
+ Get the outptut stream associated with this interpreter.
+ This may be be stdout or the GUI console.
+ */
+ public PrintStream getOut() { return out; }
+
+ /**
+ Get the error output stream associated with this interpreter.
+ This may be be stderr or the GUI console.
+ */
+ public PrintStream getErr() { return err; }
+
+ public final void println( Object o )
+ {
+ print( String.valueOf(o) + systemLineSeparator );
+ }
+
+ public final void print( Object o )
+ {
+ if (console != null) {
+ console.print(o);
+ } else {
+ out.print(o);
+ out.flush();
+ }
+ }
+
+ // End ConsoleInterface
+
+ /**
+ Print a debug message on debug stream associated with this interpreter
+ only if debugging is turned on.
+ */
+ public final static void debug(String s)
+ {
+ if ( DEBUG )
+ debug.println("// Debug: " + s);
+ }
+
+ /*
+ Primary interpreter set and get variable methods
+ Note: These are squeltching errors... should they?
+ */
+
+ /**
+ Get the value of the name.
+ name may be any value. e.g. a variable or field
+ */
+ public Object get( String name ) throws EvalError
+ {
+ try {
+ Object ret = globalNameSpace.get( name, this );
+ return Primitive.unwrap( ret );
+ } catch ( UtilEvalError e ) {
+ throw e.toEvalError( SimpleNode.JAVACODE, new CallStack() );
+ }
+ }
+
+ /**
+ Unchecked get for internal use
+ */
+ Object getu( String name ) {
+ try {
+ return get( name );
+ } catch ( EvalError e ) {
+ throw new InterpreterError("set: "+e);
+ }
+ }
+
+ /**
+ Assign the value to the name.
+ name may evaluate to anything assignable. e.g. a variable or field.
+ */
+ public void set( String name, Object value )
+ throws EvalError
+ {
+ // map null to Primtive.NULL coming in...
+ if ( value == null )
+ value = Primitive.NULL;
+
+ CallStack callstack = new CallStack();
+ try {
+ if ( Name.isCompound( name ) )
+ {
+ LHS lhs = globalNameSpace.getNameResolver( name ).toLHS(
+ callstack, this );
+ lhs.assign( value, false );
+ } else // optimization for common case
+ globalNameSpace.setVariable( name, value, false );
+ } catch ( UtilEvalError e ) {
+ throw e.toEvalError( SimpleNode.JAVACODE, callstack );
+ }
+ }
+
+ /**
+ Unchecked set for internal use
+ */
+ void setu(String name, Object value) {
+ try {
+ set(name, value);
+ } catch ( EvalError e ) {
+ throw new InterpreterError("set: "+e);
+ }
+ }
+
+ public void set(String name, long value) throws EvalError {
+ set(name, new Primitive(value));
+ }
+ public void set(String name, int value) throws EvalError {
+ set(name, new Primitive(value));
+ }
+ public void set(String name, double value) throws EvalError {
+ set(name, new Primitive(value));
+ }
+ public void set(String name, float value) throws EvalError {
+ set(name, new Primitive(value));
+ }
+ public void set(String name, boolean value) throws EvalError {
+ set(name, value ? Primitive.TRUE : Primitive.FALSE);
+ }
+
+ /**
+ Unassign the variable name.
+ Name should evaluate to a variable.
+ */
+ public void unset( String name )
+ throws EvalError
+ {
+ /*
+ We jump through some hoops here to handle arbitrary cases like
+ unset("bsh.foo");
+ */
+ CallStack callstack = new CallStack();
+ try {
+ LHS lhs = globalNameSpace.getNameResolver( name ).toLHS(
+ callstack, this );
+
+ if ( lhs.type != LHS.VARIABLE )
+ throw new EvalError("Can't unset, not a variable: "+name,
+ SimpleNode.JAVACODE, new CallStack() );
+
+ //lhs.assign( null, false );
+ lhs.nameSpace.unsetVariable( name );
+ } catch ( UtilEvalError e ) {
+ throw new EvalError( e.getMessage(),
+ SimpleNode.JAVACODE, new CallStack() );
+ }
+ }
+
+ // end primary set and get methods
+
+ /**
+ Get a reference to the interpreter (global namespace), cast
+ to the specified interface type. Assuming the appropriate
+ methods of the interface are defined in the interpreter, then you may
+ use this interface from Java, just like any other Java object.
+ <p>
+
+ For example:
+ <pre>
+ Interpreter interpreter = new Interpreter();
+ // define a method called run()
+ interpreter.eval("run() { ... }");
+
+ // Fetch a reference to the interpreter as a Runnable
+ Runnable runnable =
+ (Runnable)interpreter.getInterface( Runnable.class );
+ </pre>
+ <p>
+
+ Note that the interpreter does *not* require that any or all of the
+ methods of the interface be defined at the time the interface is
+ generated. However if you attempt to invoke one that is not defined
+ you will get a runtime exception.
+ <p>
+
+ Note also that this convenience method has exactly the same effect as
+ evaluating the script:
+ <pre>
+ (Type)this;
+ </pre>
+ <p>
+
+ For example, the following is identical to the previous example:
+ <p>
+
+ <pre>
+ // Fetch a reference to the interpreter as a Runnable
+ Runnable runnable =
+ (Runnable)interpreter.eval( "(Runnable)this" );
+ </pre>
+ <p>
+
+ <em>Version requirement</em> Although standard Java interface types
+ are always available, to be used with arbitrary interfaces this
+ feature requires that you are using Java 1.3 or greater.
+ <p>
+
+ @throws EvalError if the interface cannot be generated because the
+ version of Java does not support the proxy mechanism.
+ */
+ public Object getInterface( Class interf ) throws EvalError
+ {
+ try {
+ return globalNameSpace.getThis( this ).getInterface( interf );
+ } catch ( UtilEvalError e ) {
+ throw e.toEvalError( SimpleNode.JAVACODE, new CallStack() );
+ }
+ }
+
+ /* Methods for interacting with Parser */
+
+ private JJTParserState get_jjtree() {
+ return parser.jjtree;
+ }
+
+ private JavaCharStream get_jj_input_stream() {
+ return parser.jj_input_stream;
+ }
+
+ private boolean Line() throws ParseException {
+ return parser.Line();
+ }
+
+ /* End methods for interacting with Parser */
+
+ void loadRCFiles() {
+ try {
+ String rcfile =
+ // Default is c:\windows under win98, $HOME under Unix
+ System.getProperty("user.home") + File.separator + ".bshrc";
+ source( rcfile, globalNameSpace );
+ } catch ( Exception e ) {
+ // squeltch security exception, filenotfoundexception
+ if ( Interpreter.DEBUG ) debug("Could not find rc file: "+e);
+ }
+ }
+
+ /**
+ Localize a path to the file name based on the bsh.cwd interpreter
+ working directory.
+ */
+ public File pathToFile( String fileName )
+ throws IOException
+ {
+ File file = new File( fileName );
+
+ // if relative, fix up to bsh.cwd
+ if ( !file.isAbsolute() ) {
+ String cwd = (String)getu("bsh.cwd");
+ file = new File( cwd + File.separator + fileName );
+ }
+
+ // The canonical file name is also absolute.
+ // No need for getAbsolutePath() here...
+ return new File( file.getCanonicalPath() );
+ }
+
+ public static void redirectOutputToFile( String filename )
+ {
+ try {
+ PrintStream pout = new PrintStream(
+ new FileOutputStream( filename ) );
+ System.setOut( pout );
+ System.setErr( pout );
+ } catch ( IOException e ) {
+ System.err.println("Can't redirect output to file: "+filename );
+ }
+ }
+
+ /**
+ Set an external class loader to be used as the base classloader
+ for BeanShell. The base classloader is used for all classloading
+ unless/until the addClasspath()/setClasspath()/reloadClasses()
+ commands are called to modify the interpreter's classpath. At that
+ time the new paths /updated paths are added on top of the base
+ classloader.
+ <p>
+
+ BeanShell will use this at the same point it would otherwise use the
+ plain Class.forName().
+ i.e. if no explicit classpath management is done from the script
+ (addClassPath(), setClassPath(), reloadClasses()) then BeanShell will
+ only use the supplied classloader. If additional classpath management
+ is done then BeanShell will perform that in addition to the supplied
+ external classloader.
+ However BeanShell is not currently able to reload
+ classes supplied through the external classloader.
+ <p>
+
+ @see BshClassManager#setClassLoader( ClassLoader )
+ */
+ public void setClassLoader( ClassLoader externalCL ) {
+ getClassManager().setClassLoader( externalCL );
+ }
+
+ /**
+ Get the class manager associated with this interpreter
+ (the BshClassManager of this interpreter's global namespace).
+ This is primarily a convenience method.
+ */
+ public BshClassManager getClassManager()
+ {
+ return getNameSpace().getClassManager();
+ }
+
+ /**
+ Set strict Java mode on or off.
+ This mode attempts to make BeanShell syntax behave as Java
+ syntax, eliminating conveniences like loose variables, etc.
+ When enabled, variables are required to be declared or initialized
+ before use and method arguments are reqired to have types.
+ <p>
+
+ This mode will become more strict in a future release when
+ classes are interpreted and there is an alternative to scripting
+ objects as method closures.
+ */
+ public void setStrictJava( boolean b ) {
+ this.strictJava = b;
+ }
+
+ /**
+ @see #setStrictJava( boolean )
+ */
+ public boolean getStrictJava() {
+ return this.strictJava;
+ }
+
+ static void staticInit()
+ {
+ /*
+ Apparently in some environments you can't catch the security exception
+ at all... e.g. as an applet in IE ... will probably have to work
+ around
+ */
+ try {
+ systemLineSeparator = System.getProperty("line.separator");
+ debug = System.err;
+ DEBUG = Boolean.getBoolean("debug");
+ TRACE = Boolean.getBoolean("trace");
+ LOCALSCOPING = Boolean.getBoolean("localscoping");
+ String outfilename = System.getProperty("outfile");
+ if ( outfilename != null )
+ redirectOutputToFile( outfilename );
+ } catch ( SecurityException e ) {
+ System.err.println("Could not init static:"+e);
+ } catch ( Exception e ) {
+ System.err.println("Could not init static(2):"+e);
+ } catch ( Throwable e ) {
+ System.err.println("Could not init static(3):"+e);
+ }
+ }
+
+ /**
+ Specify the source of the text from which this interpreter is reading.
+ Note: there is a difference between what file the interrpeter is
+ sourcing and from what file a method was originally parsed. One
+ file may call a method sourced from another file. See SimpleNode
+ for origination file info.
+ @see bsh.SimpleNode#getSourceFile()
+ */
+ public String getSourceFileInfo() {
+ if ( sourceFileInfo != null )
+ return sourceFileInfo;
+ else
+ return "<unknown source>";
+ }
+
+ /**
+ Get the parent Interpreter of this interpreter, if any.
+ Currently this relationship implies the following:
+ 1) Parent and child share a BshClassManager
+ 2) Children indicate the parent's source file information in error
+ reporting.
+ When created as part of a source() / eval() the child also shares
+ the parent's namespace. But that is not necessary in general.
+ */
+ public Interpreter getParent() {
+ return parent;
+ }
+
+ public void setOut( PrintStream out ) {
+ this.out = out;
+ }
+ public void setErr( PrintStream err ) {
+ this.err = err;
+ }
+
+ /**
+ De-serialization setup.
+ Default out and err streams to stdout, stderr if they are null.
+ */
+ private void readObject(ObjectInputStream stream)
+ throws java.io.IOException, ClassNotFoundException
+ {
+ stream.defaultReadObject();
+
+ // set transient fields
+ if ( console != null ) {
+ setOut( console.getOut() );
+ setErr( console.getErr() );
+ } else {
+ setOut( System.out );
+ setErr( System.err );
+ }
+ }
+
+ /**
+ Get the prompt string defined by the getBshPrompt() method in the
+ global namespace. This may be from the getBshPrompt() command or may
+ be defined by the user as with any other method.
+ Defaults to "bsh % " if the method is not defined or there is an error.
+ */
+ private String getBshPrompt()
+ {
+ try {
+ return (String)eval("getBshPrompt()");
+ } catch ( Exception e ) {
+ return "bsh % ";
+ }
+ }
+
+ /**
+ Specify whether, in interactive mode, the interpreter exits Java upon
+ end of input. If true, when in interactive mode the interpreter will
+ issue a System.exit(0) upon eof. If false the interpreter no
+ System.exit() will be done.
+ <p/>
+ Note: if you wish to cause an EOF externally you can try closing the
+ input stream. This is not guaranteed to work in older versions of Java
+ due to Java limitations, but should work in newer JDK/JREs. (That was
+ the motivation for the Java NIO package).
+ */
+ public void setExitOnEOF( boolean value ) {
+ exitOnEOF = value; // ug
+ }
+
+ /**
+ Turn on/off the verbose printing of results as for the show()
+ command.
+ If this interpreter has a parent the call is delegated.
+ See the BeanShell show() command.
+ */
+ public void setShowResults( boolean showResults ) {
+ this.showResults = showResults;
+ }
+ /**
+ Show on/off verbose printing status for the show() command.
+ See the BeanShell show() command.
+ If this interpreter has a parent the call is delegated.
+ */
+ public boolean getShowResults() {
+ return showResults;
+ }
+
+ public static String getSaveClassesDir() {
+ return System.getProperty("saveClasses");
+ }
+
+ public static boolean getSaveClasses() {
+ return getSaveClassesDir() != null;
+ }
+}
+
Property changes on: trunk/adminshell/src/main/java/bsh/Interpreter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/adminshell/src/main/java/com/metamatrix/script/shell/JConsole.java
===================================================================
--- trunk/adminshell/src/main/java/com/metamatrix/script/shell/JConsole.java 2009-04-20 14:57:25 UTC (rev 801)
+++ trunk/adminshell/src/main/java/com/metamatrix/script/shell/JConsole.java 2009-04-20 16:16:47 UTC (rev 802)
@@ -1,24 +1,35 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
+/*****************************************************************************
+ * *
+ * This file is part of the BeanShell Java Scripting distribution. *
+ * Documentation and updates may be found at http://www.beanshell.org/ *
+ * *
+ * Sun Public License Notice: *
+ * *
+ * The contents of this file are subject to the Sun Public License Version *
+ * 1.0 (the "License"); you may not use this file except in compliance with *
+ * the License. A copy of the License is available at http://www.sun.com *
+ * *
+ * The Original Code is BeanShell. The Initial Developer of the Original *
+ * Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright *
+ * (C) 2000. All Rights Reserved. *
+ * *
+ * GNU Public License Notice: *
+ * *
+ * Alternatively, the contents of this file may be used under the terms of *
+ * the GNU Lesser General Public License (the "LGPL"), in which case the *
+ * provisions of LGPL are applicable instead of those above. If you wish to *
+ * allow use of your version of this file only under the terms of the LGPL *
+ * and not to allow others to use your version of this file under the SPL, *
+ * indicate your decision by deleting the provisions above and replace *
+ * them with the notice and other provisions required by the LGPL. If you *
+ * do not delete the provisions above, a recipient may use your version of *
+ * this file under either the SPL or the LGPL. *
+ * *
+ * Patrick Niemeyer (pat(a)pat.net) *
+ * Author of Learning Java, O'Reilly & Associates *
+ * http://www.pat.net/~pat/ *
+ * *
+ *****************************************************************************/
package com.metamatrix.script.shell;
Modified: trunk/adminshell/src/main/java/com/metamatrix/script/shell/MMAdmin.java
===================================================================
--- trunk/adminshell/src/main/java/com/metamatrix/script/shell/MMAdmin.java 2009-04-20 14:57:25 UTC (rev 801)
+++ trunk/adminshell/src/main/java/com/metamatrix/script/shell/MMAdmin.java 2009-04-20 16:16:47 UTC (rev 802)
@@ -35,9 +35,6 @@
* Invokes the BeanShell window, specifically designed for the metamatrix purposes.
* The difference with this shell is, it will plug in a customer parser on top the
* BeanShell, and load up all the MetaMatrix commands.
- *
- * @author Ramesh Reddy
- * @since 4.3
*/
public class MMAdmin {
@@ -62,7 +59,7 @@
p.setInterpreter(interpreter);
if (Capabilities.haveSwing() && gui) {
- bsh.util.Util.startSplashScreen();
+ //bsh.util.Util.startSplashScreen();
interpreter.eval("desktop()"); //$NON-NLS-1$
} else {
interpreter.run();
Modified: trunk/adminshell/src/main/java/com/metamatrix/script/shell/ReaderInterceptor.java
===================================================================
--- trunk/adminshell/src/main/java/com/metamatrix/script/shell/ReaderInterceptor.java 2009-04-20 14:57:25 UTC (rev 801)
+++ trunk/adminshell/src/main/java/com/metamatrix/script/shell/ReaderInterceptor.java 2009-04-20 16:16:47 UTC (rev 802)
@@ -43,8 +43,6 @@
* on the bean shell command line, and we can intercept and issue right beanshell
* command to execute the same.
*
- * @author Ramesh Reddy
- * @since 4.3
*/
public class ReaderInterceptor extends Reader {
private BufferedReader in = null; // Stream to Sniff
@@ -99,9 +97,11 @@
}
}
- if (line.endsWith(";")) { //$NON-NLS-1$
- currentStr = parser.convert(sb.toString().trim());
+ currentStr = parser.convert(sb.toString().trim());
+
+ if (currentStr.endsWith(";")) { //$NON-NLS-1$
if (logger != null && !currentStr.equals(";")) { //$NON-NLS-1$
+ currentStr += "\n"; //$NON-NLS-1$
logger.write(currentStr);
logger.write(System.getProperty("line.separator")); //$NON-NLS-1$
logger.flush();
Modified: trunk/adminshell/src/main/resources/commands/makeWorkspace.bsh
===================================================================
--- trunk/adminshell/src/main/resources/commands/makeWorkspace.bsh 2009-04-20 14:57:25 UTC (rev 801)
+++ trunk/adminshell/src/main/resources/commands/makeWorkspace.bsh 2009-04-20 16:16:47 UTC (rev 802)
@@ -12,9 +12,9 @@
import javax.swing.*;
import bsh.Interpreter;
import bsh.BshClassManager;
-import test.metamatrix.script.shell.JConsole;
+import com.metamatrix.script.shell.JConsole;
import bsh.util.NameCompletionTable;
-import test.metamatrix.script.shell.*;
+import com.metamatrix.script.shell.*;
makeWorkspace( String name )
{
Modified: trunk/adminshell/src/main/resources/commands/mparse.bsh
===================================================================
--- trunk/adminshell/src/main/resources/commands/mparse.bsh 2009-04-20 14:57:25 UTC (rev 801)
+++ trunk/adminshell/src/main/resources/commands/mparse.bsh 2009-04-20 16:16:47 UTC (rev 802)
@@ -6,10 +6,25 @@
// the same string to be sent to bsh.
String orig_str = mmstr.trim();
String str = orig_str.toLowerCase();
+ boolean record = false;
- if (str.matches("(select|insert|delete|update|exec|execute|create|drop)\\W.+")){
- mmstr="execute(\""+orig_str.substring(0,orig_str.length()-1)+"\");\n";
+ if (str.endsWith(";") && str.matches("(select|insert|delete|update|exec|execute|create|drop)\\W.+")){
+ mmstr="execute(\""+orig_str.substring(0,orig_str.length()-1)+"\");";
+ record = true;
}
- record(mmstr+"\n");
- return mmstr+"\n";
+ else if (str.matches("(help|exit|dir|pwd)\\(?\\)?")) {
+ idx = str.indexOf("(");
+ if (idx == -1) {
+ mmstr = str+"();";
+ }
+ else {
+ mmstr = str+";";
+ }
+ record=true;
+ }
+ if(record) {
+ record(mmstr+"\n");
+ return mmstr;
+ }
+ return str;
}
\ No newline at end of file
Modified: trunk/adminshell/src/main/resources/commands/printBanner.bsh
===================================================================
--- trunk/adminshell/src/main/resources/commands/printBanner.bsh 2009-04-20 14:57:25 UTC (rev 801)
+++ trunk/adminshell/src/main/resources/commands/printBanner.bsh 2009-04-20 16:16:47 UTC (rev 802)
@@ -18,12 +18,18 @@
this.jconsole = bsh.console;
jconsole.println(
new ImageIcon( getResource("/bsh/util/lib/small_bean_shell.gif")) );
- jconsole.print("MetaMatrix Admin Scripting Environment",
+ jconsole.print("Teiid Admin Shell",
new Font("SansSerif", Font.BOLD, 12),
new Color(20,100,20) );
jconsole.println();
- } else
- print("MetaMatrix Admin Scripting Environment");
-
+ } else {
+ print("**********************************************************************");
+ print(" You are running Admin Shell in interactive mode. To see all ");
+ print(" the commands available type 'help();' or 'exit();' to exit the shell.");
+ print(" Note: Every comand MUST end with semi-colon [;] and are ");
+ print(" always in form 'command([param]*?);'");
+ print("**********************************************************************");
+ print(" ");
+ }
}
Modified: trunk/adminshell/src/main/resources/scripts/adminapi.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/adminapi.bsh 2009-04-20 14:57:25 UTC (rev 801)
+++ trunk/adminshell/src/main/resources/scripts/adminapi.bsh 2009-04-20 16:16:47 UTC (rev 802)
@@ -91,7 +91,13 @@
void exportVDB(String name, String vdbVersion, String fileName){
debug("Exporting VDB " + name + " version " + vdbVersion + " to file " + fileName);
checkAdmin();
- ObjectConverterUtil.write(currentContext().internalAdmin.exportVDB(name, vdbVersion), fileName);
+ contents = currentContext().internalAdmin.exportVDB(name, vdbVersion);
+ if (contents != null) {
+ ObjectConverterUtil.write(contents, fileName);
+ }
+ else {
+ throw new AdminProcessingException("VDB with name "+ name + " is not found to export");
+ }
}
@@ -224,7 +230,13 @@
void exportConnectorBinding(String bindingName, String fileName){
debug("Exporting Connector Binding " + bindingName + " to file " + fileName);
checkAdmin();
- ObjectConverterUtil.write(currentContext().internalAdmin.exportConnectorBinding(bindingName), fileName);
+ contents = currentContext().internalAdmin.exportConnectorBinding(bindingName);
+ if (contents) {
+ ObjectConverterUtil.write(contents, fileName);
+ }
+ else {
+ throw new AdminProcessingException("Connector Binding "+ bindingName + " not found for exporting");
+ }
}
/**
@@ -321,8 +333,17 @@
*/
void exportExtensionModule(String sourceName, String fileName) {
debug("exporting extension module: "+sourceName);
- checkAdmin();
- ObjectConverterUtil.write(currentContext().internalAdmin.exportExtensionModule(sourceName), fileName);
+ checkAdmin();
+
+ contents = currentContext().internalAdmin.exportExtensionModule(sourceName);
+
+ if (contents) {
+ ObjectConverterUtil.write(contents, fileName);
+ }
+ else {
+ throw new AdminProcessingException("Extension Module "+ sourceName + " not found for exporting");
+ }
+
}
/**
@@ -435,7 +456,14 @@
void exportConnectorType(String connectorTypeIdentifier, String fileName) {
debug("Exporting Connector Type " + connectorTypeIdentifier + " to file " + fileName);
checkAdmin();
- ObjectConverterUtil.write(currentContext().internalAdmin.exportConnectorType(connectorTypeIdentifier), fileName);
+
+ contents = currentContext().internalAdmin.exportConnectorType(connectorTypeIdentifier);
+ if (contents != null) {
+ ObjectConverterUtil.write(contents, fileName);
+ }
+ else {
+ throw new AdminProcessingException("Connector type with name "+ connectorTypeIdentifier + " is not found to export");
+ }
}
/**
@@ -453,7 +481,16 @@
void exportConnectorArchive(String connectorTypeIdentifier, String fileName) {
debug("Exporting Connector Archive " + connectorTypeIdentifier + " to file " + fileName);
checkAdmin();
- ObjectConverterUtil.write(currentContext().internalAdmin.exportConnectorArchive(connectorTypeIdentifier), fileName);
+
+ contents = currentContext().internalAdmin.exportConnectorArchive(connectorTypeIdentifier);
+
+ if (contents != null) {
+ ObjectConverterUtil.write(contents, fileName);
+ }
+ else {
+ throw new AdminProcessingException("Connector type with name "+ connectorTypeIdentifier + " is not found to export");
+ }
+
}
//** property methods******************************************************************
@@ -553,7 +590,14 @@
void exportConfiguration(String fileName) {
debug("Exporting System configuration to file " + fileName);
checkAdmin();
- ObjectConverterUtil.write(currentContext().internalAdmin.exportConfiguration(), fileName);
+ contents = currentContext().internalAdmin.exportConfiguration();
+ if (contents != null) {
+ ObjectConverterUtil.write(contents, fileName);
+ }
+ else {
+ throw new AdminProcessingException("Configuration is not found for export");
+ }
+
}
/**
Modified: trunk/adminshell/src/main/resources/scripts/serveradmin.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/serveradmin.bsh 2009-04-20 14:57:25 UTC (rev 801)
+++ trunk/adminshell/src/main/resources/scripts/serveradmin.bsh 2009-04-20 16:16:47 UTC (rev 802)
@@ -333,9 +333,16 @@
* if there's a system error.
* @since 4.3
*/
-void exportLogs(String filename) {
+void exportLogs(String fileName) {
checkAdmin();
- ObjectConverterUtil.write(currentContext().internalAdmin.exportLogs(), filename);
+ contents = currentContext().internalAdmin.exportLogs();
+ if (contents != null) {
+ ObjectConverterUtil.write(contents, fileName);
+ }
+ else {
+ throw new AdminProcessingException("Log file is not found for exporting");
+ }
+
}
@@ -591,9 +598,15 @@
* @return - char[] stream containing the XML contents of the roles.
* @throws AdminException
*/
-void exportDataRoles(String vdbName, String vdbVersion, String filename) {
+void exportDataRoles(String vdbName, String vdbVersion, String fileName) {
checkAdmin();
- ObjectConverterUtil.write(currentContext().internalAdmin.exportDataRoles(vdbName, vdbVersion), filename);
+ contents = currentContext().internalAdmin.exportDataRoles(vdbName, vdbVersion);
+ if (contents != null) {
+ ObjectConverterUtil.write(contents, fileName);
+ }
+ else {
+ throw new AdminProcessingException("Data roles not found for VDB "+ vdbName + " with version "+ vdbVersion);
+ }
}
Modified: trunk/adminshell/src/main/resources/scripts/util.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/util.bsh 2009-04-20 14:57:25 UTC (rev 801)
+++ trunk/adminshell/src/main/resources/scripts/util.bsh 2009-04-20 16:16:47 UTC (rev 802)
@@ -6,7 +6,7 @@
getBshPrompt() {
if (currentContext().internalPrompt == void || currentContext().internalPrompt == null) {
- return "mmadmin $ ";
+ return "admin $ ";
}
return currentContext().internalPrompt;
}
15 years, 8 months
teiid SVN: r801 - in trunk/engine/src: main/java/com/metamatrix/common/buffer/impl and 17 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-20 10:57:25 -0400 (Mon, 20 Apr 2009)
New Revision: 801
Added:
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/TupleSourceImpl.java
trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ContextReference.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentCriteriaProcessor.java
Removed:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentSourceState.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/IndexedTupleSourceIterator.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/TupleSourceIterator.java
trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorProvider.java
Modified:
trunk/engine/src/main/java/com/metamatrix/common/buffer/IndexedTupleSource.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanProcedures.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecSqlInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchIterator.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentCriteriaProcessor.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureAccessNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureCriteriaProcessor.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProjectNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentSelectNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentValueSource.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/LimitNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectIntoNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryProcessorUtility.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/TupleSourceValueIterator.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/AbstractSetCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/DependentSetCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ExistsCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SubqueryCompareCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SubquerySetCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java
trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ScalarSubquery.java
trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorSource.java
trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluateExpressionVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestCriteriaEvaluator.java
trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentSelectNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java
trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestDependentSetCriteria.java
Log:
TEIID-508 TEIID-507 fixed the handling of dependent criteria and changed dependentsets and subqueries to not require direct setting of value iterators. this allows for process plans to avoid language object cloning for anything other than pushdown.
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/IndexedTupleSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/IndexedTupleSource.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/IndexedTupleSource.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -23,23 +23,37 @@
package com.metamatrix.common.buffer;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+public interface IndexedTupleSource extends TupleSource {
-/**
- * @since 4.2
- */
-public interface IndexedTupleSource extends
- TupleSource {
+ /**
+ * @return true if there are more tuples
+ * @throws MetaMatrixComponentException
+ * @throws MetaMatrixProcessingException
+ */
+ boolean hasNext() throws MetaMatrixComponentException, MetaMatrixProcessingException;
-
- /**
- * Returns the index of the current tuple in the tuple source.
- */
- int getCurrentTupleIndex();
-
- /**
- * Set the current index of the tuple source. Allows the user of the tuple source to
- * set the row that is retrieved.
- */
- void setCurrentTupleIndex(int index) throws MetaMatrixComponentException;
+ /**
+ * Save the current position that can be restored with a call to {@link #reset()}
+ */
+ void mark();
+
+ /**
+ * Restore the previous mark and set the mark back to the first position.
+ */
+ void reset();
+
+ /**
+ * Set the tuple source position
+ * @param position
+ */
+ void setPosition(int position);
+
+ /**
+ * Get the current position. The position is 1 based and reports the position of the
+ * tuple that will be retrieved with a call to {@link TupleSource#nextTuple()}
+ * @return
+ */
+ int getCurrentIndex();
}
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,7 +22,6 @@
package com.metamatrix.common.buffer.impl;
-import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -37,10 +36,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BlockedOnMemoryException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.IndexedTupleSource;
import com.metamatrix.common.buffer.LobTupleBatch;
@@ -395,7 +391,7 @@
TupleSourceInfo info = getTupleSourceInfo(tupleSourceID, true);
int batchSize = this.config.getProcessorBatchSize();
- return new TupleSourceImpl(tupleSourceID, info.getTupleSchema(), batchSize);
+ return new TupleSourceImpl(this, tupleSourceID, info.getTupleSchema(), batchSize);
}
/**
@@ -893,110 +889,6 @@
return info;
}
- private class TupleSourceImpl implements IndexedTupleSource {
- private TupleSourceID tupleSourceID;
- private List schema;
- private int batchSize;
- private WeakReference currentBatch;
- private int currentRow = 1;
-
- TupleSourceImpl(TupleSourceID tupleSourceID, List schema, int batchSize){
- this.tupleSourceID = tupleSourceID;
- this.schema = schema;
- this.batchSize = batchSize;
- }
-
- public List getSchema(){
- return this.schema;
- }
-
- public List nextTuple()
- throws MetaMatrixComponentException{
- TupleBatch batch = getBatch();
- if(batch.getRowCount() == 0) {
- // Check if last
- try {
- TupleSourceStatus status = getStatus(this.tupleSourceID);
- if(status == TupleSourceStatus.FULL) {
- unpinCurrentBatch();
- return null;
- }
- throw BlockedException.INSTANCE;
- } catch(TupleSourceNotFoundException e) {
- throw new ComponentNotFoundException(e, e.getMessage());
- }
- }
-
- return batch.getTuple(currentRow++);
- }
-
- public void closeSource()
- throws MetaMatrixComponentException{
- // Reset to same state as newly-instantiated TupleSourceImpl
- unpinCurrentBatch();
- this.currentRow = 1;
- //TODO: this is not quite correct wrt the javadoc, close does
- //not need to ensure that we are back at the beginning
- }
-
- public int getCurrentTupleIndex() {
- return currentRow;
- }
-
- public void setCurrentTupleIndex(int index) {
- currentRow = index;
- }
-
- private TupleBatch getCurrentBatch() {
- if (currentBatch != null) {
- return (TupleBatch)currentBatch.get();
- }
- return null;
- }
-
- private void unpinCurrentBatch()
- throws MetaMatrixComponentException {
- TupleBatch batch = getCurrentBatch();
- if(batch != null ) {
- try {
- unpinTupleBatch(this.tupleSourceID, batch.getBeginRow(), batch.getEndRow());
- } catch (TupleSourceNotFoundException e) {
- throw new MetaMatrixComponentException(e);
- } finally {
- currentBatch = null;
- }
- }
- }
-
- // Retrieves the necessary batch based on the currentRow
- private TupleBatch getBatch()
- throws MetaMatrixComponentException{
- TupleBatch batch = getCurrentBatch();
- if (batch != null) {
- if (currentRow < batch.getEndRow() && currentRow > batch.getBeginRow()) {
- return batch;
- }
- unpinCurrentBatch();
- }
-
- try{
- batch = pinTupleBatch(this.tupleSourceID, currentRow, (currentRow + batchSize -1));
- currentBatch = new WeakReference(batch);
- } catch (MemoryNotAvailableException e) {
- /* Defect 18499 - ProcessWorker doesn't know how to handle MemoryNotAvailableException properly,
- * and this should always be converted to a BlockedOnMemoryException during processing so that
- * the work can be requeued.
- */
- throw BlockedOnMemoryException.INSTANCE;
- } catch(MetaMatrixComponentException e) {
- throw e;
- } catch(TupleSourceNotFoundException e){
- throw new MetaMatrixComponentException(e);
- }
- return batch;
- }
- }
-
/**
* @see com.metamatrix.common.buffer.BufferManager#stop()
*/
Added: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/TupleSourceImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/TupleSourceImpl.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/TupleSourceImpl.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -0,0 +1,190 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.buffer.impl;
+
+import java.lang.ref.WeakReference;
+import java.util.List;
+
+import com.metamatrix.api.exception.ComponentNotFoundException;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.BlockedOnMemoryException;
+import com.metamatrix.common.buffer.IndexedTupleSource;
+import com.metamatrix.common.buffer.MemoryNotAvailableException;
+import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.common.buffer.TupleSourceID;
+import com.metamatrix.common.buffer.TupleSourceNotFoundException;
+import com.metamatrix.common.buffer.BufferManager.TupleSourceStatus;
+
+class TupleSourceImpl implements IndexedTupleSource {
+ private final BufferManagerImpl bufferManagerImpl;
+ private TupleSourceID tupleSourceID;
+ private List<?> schema;
+ private int batchSize;
+ private WeakReference<TupleBatch> currentBatch;
+ private int currentRow = 1;
+ private int mark = 1;
+ private List<?> currentTuple;
+
+ TupleSourceImpl(BufferManagerImpl bufferManagerImpl, TupleSourceID tupleSourceID, List schema, int batchSize){
+ this.bufferManagerImpl = bufferManagerImpl;
+ this.tupleSourceID = tupleSourceID;
+ this.schema = schema;
+ this.batchSize = batchSize;
+ }
+
+ @Override
+ public int getCurrentIndex() {
+ return this.currentRow;
+ }
+
+ @Override
+ public List getSchema(){
+ return this.schema;
+ }
+
+ @Override
+ public List<?> nextTuple()
+ throws MetaMatrixComponentException{
+ List<?> result = null;
+ if (currentTuple != null){
+ result = currentTuple;
+ currentTuple = null;
+ } else {
+ result = getCurrentTuple();
+ }
+ if (result != null) {
+ currentRow++;
+ }
+ return result;
+ }
+
+ private List getCurrentTuple() throws MetaMatrixComponentException,
+ BlockedException, ComponentNotFoundException {
+ TupleBatch batch = getBatch();
+ if(batch.getRowCount() == 0) {
+ // Check if last
+ try {
+ TupleSourceStatus status = this.bufferManagerImpl.getStatus(this.tupleSourceID);
+ if(status == TupleSourceStatus.FULL) {
+ unpinCurrentBatch();
+ return null;
+ }
+ throw BlockedException.INSTANCE;
+ } catch(TupleSourceNotFoundException e) {
+ throw new ComponentNotFoundException(e, e.getMessage());
+ }
+ }
+
+ return batch.getTuple(currentRow);
+ }
+
+ @Override
+ public void closeSource()
+ throws MetaMatrixComponentException{
+ // Reset to same state as newly-instantiated TupleSourceImpl
+ unpinCurrentBatch();
+ mark = 1;
+ reset();
+ //TODO: this is not quite correct wrt the javadoc, close does
+ //not need to ensure that we are back at the beginning
+ }
+
+ private TupleBatch getCurrentBatch() {
+ if (currentBatch != null) {
+ return currentBatch.get();
+ }
+ return null;
+ }
+
+ private void unpinCurrentBatch()
+ throws MetaMatrixComponentException {
+ TupleBatch batch = getCurrentBatch();
+ if(batch != null ) {
+ try {
+ this.bufferManagerImpl.unpinTupleBatch(this.tupleSourceID, batch.getBeginRow(), batch.getEndRow());
+ } catch (TupleSourceNotFoundException e) {
+ throw new MetaMatrixComponentException(e);
+ } finally {
+ currentBatch = null;
+ }
+ }
+ }
+
+ // Retrieves the necessary batch based on the currentRow
+ private TupleBatch getBatch()
+ throws MetaMatrixComponentException{
+ TupleBatch batch = getCurrentBatch();
+ if (batch != null) {
+ if (currentRow < batch.getEndRow() && currentRow > batch.getBeginRow()) {
+ return batch;
+ }
+ unpinCurrentBatch();
+ }
+
+ try{
+ batch = this.bufferManagerImpl.pinTupleBatch(this.tupleSourceID, currentRow, (currentRow + batchSize -1));
+ currentBatch = new WeakReference<TupleBatch>(batch);
+ } catch (MemoryNotAvailableException e) {
+ /* Defect 18499 - ProcessWorker doesn't know how to handle MemoryNotAvailableException properly,
+ * and this should always be converted to a BlockedOnMemoryException during processing so that
+ * the work can be requeued.
+ */
+ throw BlockedOnMemoryException.INSTANCE;
+ } catch(MetaMatrixComponentException e) {
+ throw e;
+ } catch(TupleSourceNotFoundException e){
+ throw new MetaMatrixComponentException(e);
+ }
+ return batch;
+ }
+
+ @Override
+ public boolean hasNext() throws MetaMatrixComponentException {
+ if (this.currentTuple != null) {
+ return true;
+ }
+
+ this.currentTuple = getCurrentTuple();
+ return this.currentTuple != null;
+ }
+
+ @Override
+ public void reset() {
+ this.setPosition(mark);
+ this.mark = 1;
+ }
+
+ @Override
+ public void mark() {
+ this.mark = currentRow;
+ }
+
+ @Override
+ public void setPosition(int position) {
+ if (this.currentRow != position) {
+ this.currentRow = position;
+ this.currentTuple = null;
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/TupleSourceImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -45,7 +45,9 @@
import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.function.FunctionLibraryManager;
import com.metamatrix.query.function.metadata.FunctionMethod;
+import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.lang.AbstractSetCriteria;
+import com.metamatrix.query.sql.lang.CollectionValueIterator;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.CompoundCriteria;
import com.metamatrix.query.sql.lang.Criteria;
@@ -53,11 +55,12 @@
import com.metamatrix.query.sql.lang.IsNullCriteria;
import com.metamatrix.query.sql.lang.MatchCriteria;
import com.metamatrix.query.sql.lang.NotCriteria;
+import com.metamatrix.query.sql.lang.SetCriteria;
import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.CaseExpression;
import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.ContextReference;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.ExpressionSymbol;
import com.metamatrix.query.sql.symbol.Function;
@@ -308,7 +311,14 @@
return null;
}
Boolean result = Boolean.FALSE;
- ValueIterator valueIter = criteria.getValueIterator();
+
+ ValueIterator valueIter = null;
+ if (criteria instanceof SetCriteria) {
+ valueIter = new CollectionValueIterator(((SetCriteria)criteria).getValues());
+ } else {
+ ContextReference ref = (ContextReference)criteria;
+ valueIter = getContext(criteria).getValueIterator(ref);
+ }
while(valueIter.hasNext()) {
Object possibleValue = valueIter.next();
Object value = null;
@@ -378,7 +388,7 @@
result = Boolean.TRUE;
}
- ValueIterator valueIter = criteria.getValueIterator();
+ ValueIterator valueIter = getContext(criteria).getValueIterator(criteria);
while(valueIter.hasNext()) {
Object value = valueIter.next();
@@ -461,7 +471,7 @@
public boolean evaluate(ExistsCriteria criteria, List tuple)
throws BlockedException, MetaMatrixComponentException {
- ValueIterator valueIter = criteria.getValueIterator();
+ ValueIterator valueIter = getContext(criteria).getValueIterator(criteria);
if(valueIter.hasNext()) {
return true;
}
@@ -497,12 +507,7 @@
return internalEvaluate(expr, tuple);
}
- if (expression instanceof ElementSymbol && this.context != null && this.context.getVariableContext() != null
- && this.context.getVariableContext().containsVariable((ElementSymbol)expression)) {
- return this.context.getVariableContext().getValue((ElementSymbol)expression);
- }
- // instead of assuming null, throw an exception. a problem in planning has occurred
- throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, expression, "No value was available")); //$NON-NLS-1$
+ return getContext(expression).getFromContext(expression);
}
if(expression instanceof Constant) {
return ((Constant) expression).getValue();
@@ -514,6 +519,9 @@
return evaluate((SearchedCaseExpression) expression, tuple);
} else if(expression instanceof Reference) {
Reference ref = (Reference)expression;
+ if (ref.isPositional() && ref.getExpression() == null) {
+ return getContext(ref).getVariableContext().getGlobalValue(ref.getContextSymbol());
+ }
return internalEvaluate(ref.getExpression(), tuple);
} else if(expression instanceof ScalarSubquery) {
return evaluate((ScalarSubquery) expression, tuple);
@@ -607,9 +615,9 @@
private Object evaluate(ScalarSubquery scalarSubquery, List tuple)
throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
-
+
Object result = null;
- ValueIterator valueIter = scalarSubquery.getValueIterator();
+ ValueIterator valueIter = getContext(scalarSubquery).getValueIterator(scalarSubquery);
if(valueIter.hasNext()) {
result = valueIter.next();
if(valueIter.hasNext()) {
@@ -619,6 +627,13 @@
}
}
return result;
- }
-
+ }
+
+ private CommandContext getContext(LanguageObject expression) throws MetaMatrixComponentException {
+ if (context == null) {
+ throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, expression, "No value was available")); //$NON-NLS-1$
+ }
+ return context;
+ }
+
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,6 +22,7 @@
package com.metamatrix.query.optimizer.relational;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -51,7 +52,6 @@
import com.metamatrix.query.processor.relational.DependentProcedureExecutionNode;
import com.metamatrix.query.processor.relational.DependentProjectNode;
import com.metamatrix.query.processor.relational.DependentSelectNode;
-import com.metamatrix.query.processor.relational.DependentValueSource;
import com.metamatrix.query.processor.relational.DupRemoveNode;
import com.metamatrix.query.processor.relational.GroupingNode;
import com.metamatrix.query.processor.relational.JoinNode;
@@ -66,6 +66,7 @@
import com.metamatrix.query.processor.relational.RelationalPlan;
import com.metamatrix.query.processor.relational.SelectNode;
import com.metamatrix.query.processor.relational.SortNode;
+import com.metamatrix.query.processor.relational.SubqueryProcessorUtility;
import com.metamatrix.query.processor.relational.UnionAllNode;
import com.metamatrix.query.processor.relational.MergeJoinStrategy.SortOption;
import com.metamatrix.query.resolver.util.ResolverUtil;
@@ -75,7 +76,9 @@
import com.metamatrix.query.sql.lang.JoinType;
import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.StoredProcedure;
+import com.metamatrix.query.sql.lang.SubqueryContainer;
import com.metamatrix.query.sql.lang.SetQuery.Operation;
+import com.metamatrix.query.sql.symbol.ContextReference;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
@@ -188,17 +191,15 @@
} else {
List symbols = (List) node.getProperty(NodeConstants.Info.PROJECT_COLS);
- // This project node has one or more subqueries
- List subqueries = node.getSubqueryContainers();
- if (subqueries.isEmpty()){
- ProjectNode pnode = new ProjectNode(getID());
- processNode = pnode;
+ SubqueryProcessorUtility spu = createSubqueryProcessor(node);
+ if (spu == null) {
+ ProjectNode pnode = new ProjectNode(getID());
+ processNode = pnode;
} else {
- SymbolMap correlatedReferences = (SymbolMap)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
- DependentProjectNode pnode = new DependentProjectNode(getID(), correlatedReferences);
-
+ DependentProjectNode pnode = new DependentProjectNode(getID(), spu);
processNode = pnode;
}
+
((ProjectNode)processNode).setSelectSymbols(symbols);
}
break;
@@ -229,7 +230,7 @@
processNode = jnode;
- DependentValueSource depValueSource = (DependentValueSource) node.getProperty(NodeConstants.Info.DEPENDENT_VALUE_SOURCE);
+ String depValueSource = (String) node.getProperty(NodeConstants.Info.DEPENDENT_VALUE_SOURCE);
jnode.setDependentValueSource(depValueSource);
break;
@@ -322,20 +323,16 @@
case NodeConstants.Types.SELECT:
Criteria crit = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
- List subCrits = node.getSubqueryContainers();
- if (subCrits.isEmpty()){
+ SubqueryProcessorUtility spu = createSubqueryProcessor(node);
+
+ if (spu == null){
// This is a normal select node
SelectNode selnode = new SelectNode(getID());
selnode.setCriteria(crit);
-
processNode = selnode;
} else {
- // This select node has one or more subqueries
- SymbolMap correlatedReferences = (SymbolMap)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
-
- DependentSelectNode selnode = new DependentSelectNode(getID(), correlatedReferences);
+ DependentSelectNode selnode = new DependentSelectNode(getID(), spu);
selnode.setCriteria(crit);
-
processNode = selnode;
}
possiblyDependentObject = crit;
@@ -423,6 +420,21 @@
return processNode;
}
+ private SubqueryProcessorUtility createSubqueryProcessor(PlanNode node) {
+ List<SubqueryContainer> subqueries = node.getSubqueryContainers();
+ if (subqueries.isEmpty()){
+ return null;
+ }
+ SymbolMap correlatedReferences = (SymbolMap)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
+ List<ProcessorPlan> plans = new ArrayList<ProcessorPlan>(subqueries.size());
+ List<String> contextReferences = new ArrayList<String>(subqueries.size());
+ for (SubqueryContainer subqueryContainer : subqueries) {
+ plans.add(subqueryContainer.getCommand().getProcessorPlan());
+ contextReferences.add(((ContextReference)subqueryContainer).getContextSymbol());
+ }
+ return new SubqueryProcessorUtility(plans, contextReferences, correlatedReferences);
+ }
+
private RelationalNode correctProjectionForTempTable(PlanNode node,
AccessNode aNode,
LanguageObject possiblyDependentObject) throws QueryMetadataException,
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -85,7 +85,7 @@
JOIN_STRATEGY, // JoinStrategyType
LEFT_EXPRESSIONS, // List <SingleElementSymbol>
RIGHT_EXPRESSIONS, // List <SingleElementSymbol>
- DEPENDENT_VALUE_SOURCE, // DependentValueSource for supplying multiple value iterators to remote nodes
+ DEPENDENT_VALUE_SOURCE, // String
NON_EQUI_JOIN_CRITERIA, // List <CompareCriteria>
SORT_LEFT, // Boolean
SORT_RIGHT, // Boolean
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -27,6 +27,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
@@ -42,14 +43,12 @@
import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.processor.relational.DependentValueSource;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.DependentSetCriteria;
import com.metamatrix.query.sql.lang.JoinType;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.util.ValueIteratorSource;
import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.util.LogConstants;
@@ -58,6 +57,8 @@
* Finds nodes that can be turned into dependent joins
*/
public final class RuleChooseDependent implements OptimizerRule {
+
+ private static AtomicInteger ID = new AtomicInteger();
private static class CandidateJoin {
PlanNode joinNode;
@@ -305,11 +306,11 @@
return false;
}
+ String id = "$dsc/id" + ID.getAndIncrement(); //$NON-NLS-1$
// Create DependentValueSource and set on the independent side as this will feed the values
- DependentValueSource valueIterSrc = new DependentValueSource();
- joinNode.setProperty(NodeConstants.Info.DEPENDENT_VALUE_SOURCE, valueIterSrc);
+ joinNode.setProperty(NodeConstants.Info.DEPENDENT_VALUE_SOURCE, id);
- List crits = getDependentCriteriaNodes(valueIterSrc, independentExpressions, dependentExpressions);
+ List crits = getDependentCriteriaNodes(id, independentExpressions, dependentExpressions);
PlanNode newRoot = sourceNode;
@@ -331,8 +332,7 @@
* @return
* @since 4.3
*/
- private List getDependentCriteriaNodes( ValueIteratorSource iterSrc,
- List independentExpressions,
+ private List getDependentCriteriaNodes(String id, List independentExpressions,
List dependentExpressions) {
List result = new LinkedList();
@@ -343,9 +343,8 @@
while(depIter.hasNext()) {
Expression depExpr = (Expression) depIter.next();
Expression indepExpr = (Expression) indepIter.next();
- DependentSetCriteria crit = new DependentSetCriteria(SymbolMap.getExpression(depExpr));
+ DependentSetCriteria crit = new DependentSetCriteria(SymbolMap.getExpression(depExpr), id);
crit.setValueExpression(indepExpr);
- crit.setValueIteratorSource(iterSrc);
PlanNode selectNode = GenerateCanonical.createSelectNode(crit, false);
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanProcedures.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanProcedures.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanProcedures.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -44,15 +44,12 @@
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.DependentSetCriteria;
import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
import com.metamatrix.query.sql.lang.SPParameter;
import com.metamatrix.query.sql.lang.SetCriteria;
import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.Reference;
@@ -162,40 +159,25 @@
LanguageVisitor visitor = new LanguageVisitor() {
public void visit(CompareCriteria compCrit){
- if(compCrit.getOperator() != CompareCriteria.EQ){
- return;
- }
- if (checkForInput(compCrit.getLeftExpression()) && !checkForAnyInput(compCrit.getRightExpression())) {
+ if (compCrit.getOperator() == CompareCriteria.EQ && checkForInput(compCrit.getLeftExpression()) && !checkForAnyInput(compCrit.getRightExpression())) {
addInputNode((Reference)compCrit.getLeftExpression());
}
}
- public void visit(NotCriteria obj) {
- setAbort(true);
- }
-
- public void visit(CompoundCriteria obj) {
- setAbort(true);
- }
-
private void addInputNode(Reference param) {
params.add(param.getExpression());
conjuncts.add(crit);
NodeEditor.removeChildNode(currentNode.getParent(), currentNode);
- setAbort(true);
}
public void visit(IsNullCriteria isNull){
- if (isNull.isNegated()) {
- return;
- }
- if (checkForInput(isNull.getExpression())) {
+ if (!isNull.isNegated() && checkForInput(isNull.getExpression())) {
addInputNode((Reference)isNull.getExpression());
}
}
public void visit(SetCriteria obj) {
- if (checkForInput(obj.getExpression()) && !checkForAnyInput(obj.getValues())) {
+ if (!obj.isNegated() && checkForInput(obj.getExpression()) && !checkForAnyInput(obj.getValues())) {
addInputNode((Reference)obj.getExpression());
}
}
@@ -234,8 +216,7 @@
}
};
-
- PreOrderNavigator.doVisit(crit, visitor);
+ crit.acceptVisitor(visitor);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -260,12 +260,10 @@
satisfyAccessPatterns(critNode, currentNode);
- if (critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET)
- && CapabilitiesUtil.getMaxInCriteriaSize(RuleRaiseAccess.getModelIDFromAccess(currentNode, metadata), metadata, capFinder) > 0) {
+ if (critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET)) {
//once a dependent crit node is pushed, don't bother pushing it further into the command
//dependent access node will use this as an assumption for where dependent sets can appear in the command
critNode.setProperty(NodeConstants.Info.IS_PUSHED, Boolean.TRUE);
-
currentNode.setProperty(NodeConstants.Info.IS_DEPENDENT_SET, Boolean.TRUE);
return currentNode.getFirstChild();
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -103,10 +103,8 @@
protected void cloneState(AbstractAssignmentInstruction clone) {
- clone.setVariable((ElementSymbol)getVariable().clone());
- if (expression != null) {
- clone.setExpression((Expression)getExpression().clone());
- }
+ clone.setVariable(this.variable);
+ clone.setExpression(this.expression);
if (processPlan != null) {
clone.setProcessPlan((ProcessorPlan)getProcessPlan().clone());
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecSqlInstruction.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecSqlInstruction.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -97,12 +97,7 @@
* Returns a deep clone
*/
public Object clone(){
- GroupSymbol clonedIntoGroup = null;
- if(this.intoGroup != null){
- clonedIntoGroup = (GroupSymbol)intoGroup.clone();
- }
-
- ExecSqlInstruction clone = new ExecSqlInstruction((ProcessorPlan)commandPlan.clone(), clonedIntoGroup);
+ ExecSqlInstruction clone = new ExecSqlInstruction((ProcessorPlan)commandPlan.clone(), intoGroup);
return clone;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -123,13 +123,12 @@
* Returns a deep clone
*/
public Object clone(){
- Criteria cloneCriteria = (Criteria) this.condition.clone();
Program cloneIf = (Program) this.ifProgram.clone();
Program cloneElse = null;
if(elseProgram != null) {
cloneElse = (Program) this.elseProgram.clone();
}
- IfInstruction clone = new IfInstruction(cloneCriteria, cloneIf, cloneElse);
+ IfInstruction clone = new IfInstruction(this.condition, cloneIf, cloneElse);
return clone;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -61,7 +61,7 @@
* Returns a deep clone
*/
public Object clone(){
- return new WhileInstruction((Program)this.whileProgram.clone(), (Criteria)this.condition.clone());
+ return new WhileInstruction((Program)this.whileProgram.clone(), this.condition);
}
public String toString() {
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -211,7 +211,7 @@
target.modelName = source.modelName;
target.connectorBindingId = source.connectorBindingId;
target.shouldEvaluate = source.shouldEvaluate;
- target.command = (Command)source.command.clone();
+ target.command = source.command;
}
/*
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchIterator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchIterator.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchIterator.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -27,10 +27,12 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.common.buffer.IndexedTupleSource;
import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
final class BatchIterator implements
- TupleSourceIterator {
+ IndexedTupleSource {
private final RelationalNode source;
@@ -65,9 +67,20 @@
}
return true;
}
-
- public List next() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+
+ @Override
+ public void closeSource() throws MetaMatrixComponentException {
+
+ }
+
+ @Override
+ public List<SingleElementSymbol> getSchema() {
+ return source.getElements();
+ }
+
+ @Override
+ public List<?> nextTuple() throws MetaMatrixComponentException,
+ MetaMatrixProcessingException {
if (currentTuple == null && !hasNext()) {
throw new NoSuchElementException();
}
@@ -84,6 +97,7 @@
//does nothing
}
+ @Override
public int getCurrentIndex() {
return currentRow;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -182,11 +182,7 @@
* @since 4.2
*/
public Object clone() {
- List clonedCommands = new ArrayList(updateCommands.size());
- for (int i = 0; i < updateCommands.size(); i++) {
- clonedCommands.add(((Command)updateCommands.get(i)).clone());
- }
- BatchedUpdateNode clonedNode = new BatchedUpdateNode(getID(), clonedCommands, contexts, shouldEvaluate, modelName);
+ BatchedUpdateNode clonedNode = new BatchedUpdateNode(getID(), updateCommands, contexts, shouldEvaluate, modelName);
super.copy(this, clonedNode);
return clonedNode;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentCriteriaProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentCriteriaProcessor.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentCriteriaProcessor.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -23,201 +23,209 @@
package com.metamatrix.query.processor.relational;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
-import com.metamatrix.query.processor.relational.DependentSourceState.SetState;
+import com.metamatrix.query.eval.Evaluator;
+import com.metamatrix.query.rewriter.QueryRewriter;
import com.metamatrix.query.sql.lang.AbstractSetCriteria;
import com.metamatrix.query.sql.lang.CollectionValueIterator;
+import com.metamatrix.query.sql.lang.CompareCriteria;
+import com.metamatrix.query.sql.lang.CompoundCriteria;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.DependentSetCriteria;
import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.lang.SetCriteria;
+import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.sql.util.ValueIteratorSource;
public class DependentCriteriaProcessor {
+
+ public static class SetState {
- class TupleState implements DependentSourceState {
+ Collection<Object> replacement = new LinkedHashSet<Object>();
- private SortUtility sortUtility;
- private TupleSourceID outputID;
- private List dependentSetStates;
- private DependentValueSource valueSource = new DependentValueSource();
+ Expression valueExpression;
- public TupleState(List sortSymbols,
- TupleSource ts,
- TupleSourceID tsID) throws MetaMatrixComponentException {
+ ValueIterator valueIterator;
- List sortDirection = new ArrayList(sortSymbols.size());
+ Object nextValue;
- for (int i = 0; i < sortSymbols.size(); i++) {
- sortDirection.add(Boolean.valueOf(OrderBy.ASC));
- }
+ boolean isNull;
+ }
- this.sortUtility = new SortUtility(tsID, ts.getSchema(), sortSymbols, sortDirection, true, dependentNode.getBufferManager(),
- dependentNode.getConnectionID());
+ class TupleState {
+
+ private SortUtility sortUtility;
+ private DependentValueSource dvs;
+ private List<SetState> dependentSetStates = new LinkedList<SetState>();
+ private String valueSource;
+
+ public TupleState(String source) {
+ this.valueSource = source;
}
public void sort() throws BlockedException,
MetaMatrixComponentException {
- if (outputID == null) {
- outputID = sortUtility.sort();
+ if (dvs == null) {
+ if (sortUtility == null) {
+ List<Expression> sortSymbols = new ArrayList<Expression>(dependentSetStates.size());
+ List<Boolean> sortDirection = new ArrayList<Boolean>(sortSymbols.size());
+ for (int i = 0; i < dependentSetStates.size(); i++) {
+ sortDirection.add(Boolean.valueOf(OrderBy.ASC));
+ sortSymbols.add(dependentSetStates.get(i).valueExpression);
+ }
+ DependentValueSource originalVs = (DependentValueSource)dependentNode.getContext().getVariableContext().getGlobalValue(valueSource);
+ TupleSource ts;
+ try {
+ ts = dependentNode.getBufferManager().getTupleSource(originalVs.getTupleSourceID());
+ } catch (TupleSourceNotFoundException e) {
+ throw new MetaMatrixComponentException(e);
+ }
+ this.sortUtility = new SortUtility(originalVs.getTupleSourceID(), ts.getSchema(), sortSymbols, sortDirection, true, dependentNode.getBufferManager(),
+ dependentNode.getConnectionID());
+ }
+ dvs = new DependentValueSource(sortUtility.sort(), dependentNode.getBufferManager());
+ for (SetState setState : dependentSetStates) {
+ setState.valueIterator = dvs.getValueIterator(setState.valueExpression);
+ }
}
}
public void close() throws MetaMatrixComponentException {
- if (outputID != null) {
+ if (dvs != null) {
+ sortUtility = null;
try {
- dependentNode.getBufferManager().removeTupleSource(outputID);
+ dependentNode.getBufferManager().removeTupleSource(dvs.getTupleSourceID());
} catch (TupleSourceNotFoundException e) {
- throw new MetaMatrixComponentException(e, e.getMessage());
}
- outputID = null;
+ dvs = null;
}
}
-
- public ValueIterator getValueIterator(SetState setState) {
- return valueSource.getValueIterator(setState.valueExpression);
- }
-
- public void connectValueSource() throws MetaMatrixComponentException {
- try {
- valueSource.setTupleSource(dependentNode.getBufferManager().getTupleSource(outputID), outputID);
- } catch (TupleSourceNotFoundException err) {
- throw new MetaMatrixComponentException(err);
- }
- }
-
- public List getDepedentSetStates() {
+
+ public List<SetState> getDepedentSetStates() {
return dependentSetStates;
}
-
- public void setDependentSetStates(List states) {
- this.dependentSetStates = states;
- }
- }
-
- private final static class FixedState implements DependentSourceState {
- private List dependentSetStates;
- private Collection values;
-
- public FixedState(SetCriteria crit) {
- this.values = new ArrayList(crit.getValues());
- }
-
- public void sort() throws BlockedException,
- MetaMatrixComponentException {
- //do nothing, it should already be sorted
- }
-
- public void close() throws MetaMatrixComponentException {
- //do nothing
- }
-
- public ValueIterator getValueIterator(SetState setState) {
- return new CollectionValueIterator(values);
- }
-
- public void connectValueSource() throws MetaMatrixComponentException {
- //do nothing
- }
-
- public List getDepedentSetStates() {
- return dependentSetStates;
- }
-
- public void setDependentSetStates(List states) {
- this.dependentSetStates = states;
- }
}
-
- private final static class SimpleValueIteratorSource implements
- ValueIteratorSource {
-
- private Collection values;
-
- public SimpleValueIteratorSource(Collection values) {
- this.values = values;
- }
-
- public ValueIterator getValueIterator(Expression valueExpression) {
- return new CollectionValueIterator(values);
- }
-
- public boolean isReady() {
- return true;
- }
- }
-
- private static final int INITIAL = 1;
+
private static final int SORT = 2;
private static final int SET_PROCESSING = 3;
+ //constructor state
private int maxSetSize;
-
- // processing state
private RelationalNode dependentNode;
private Criteria dependentCrit;
- private int phase = INITIAL;
- private List sources;
- private LinkedHashMap dependentState;
- private LinkedList restartIndexes;
- private int currentIterator;
+
+ //initialization state
+ private List<Criteria> queryCriteria;
+ private Map<Integer, SetState> setStates = new HashMap<Integer, SetState>();
+ private LinkedHashMap<String, TupleState> dependentState = new LinkedHashMap<String, TupleState>();
+ private List<List<SetState>> sources = new ArrayList<List<SetState>>();
+
+ // processing state
+ private int phase = SORT;
+ private LinkedList<Integer> restartIndexes = new LinkedList<Integer>();
+ private int currentIndex;
private boolean hasNextCommand;
+
- public DependentCriteriaProcessor(int maxSetSize, RelationalNode dependentNode, Criteria dependentCriteria) {
+ public DependentCriteriaProcessor(int maxSetSize, RelationalNode dependentNode, Criteria dependentCriteria) throws ExpressionEvaluationException, MetaMatrixComponentException {
this.maxSetSize = maxSetSize;
this.dependentNode = dependentNode;
this.dependentCrit = dependentCriteria;
+ queryCriteria = Criteria.separateCriteriaByAnd(dependentCrit);
+
+ for (int i = 0; i < queryCriteria.size(); i++) {
+ Criteria criteria = queryCriteria.get(i);
+ if (!(criteria instanceof AbstractSetCriteria)) {
+ continue;
+ }
+
+ if (criteria instanceof SetCriteria) {
+ SetCriteria setCriteria = (SetCriteria)criteria;
+ if (setCriteria.isNegated() || setCriteria.getNumberOfValues() <= maxSetSize) {
+ continue;
+ }
+ SetState state = new SetState();
+ setStates.put(i, state);
+ Evaluator evaluator = new Evaluator(Collections.emptyMap(), dependentNode.getDataManager(), dependentNode.getContext());
+ LinkedHashSet<Object> values = new LinkedHashSet<Object>();
+ for (Expression expr : (Collection<Expression>)setCriteria.getValues()) {
+ values.add(evaluator.evaluate(expr, null));
+ }
+ state.valueIterator = new CollectionValueIterator(values);
+ sources.add(Arrays.asList(state));
+ } else if (criteria instanceof DependentSetCriteria) {
+ DependentSetCriteria dsc = (DependentSetCriteria)criteria;
+ String source = dsc.getContextSymbol();
+
+ SetState state = new SetState();
+ setStates.put(i, state);
+ state.valueExpression = dsc.getValueExpression();
+ TupleState ts = dependentState.get(source);
+ if (ts == null) {
+ ts = new TupleState(source);
+ dependentState.put(source, ts);
+ sources.add(ts.getDepedentSetStates());
+ }
+ ts.getDepedentSetStates().add(state);
+ }
+ }
}
public void close() throws MetaMatrixComponentException {
if (dependentState != null) {
- for (int i = 0; i < sources.size(); i++) {
- DependentSourceState dss = (DependentSourceState)dependentState.get(sources.get(i));
- dss.close();
- }
+ for (TupleState state : dependentState.values()) {
+ state.close();
+ }
}
}
- public void reset() {
- dependentState = null;
- phase = INITIAL;
- }
-
public Criteria prepareCriteria() throws MetaMatrixComponentException {
- if (phase == INITIAL) {
- initializeDependentState();
-
- phase = SORT;
- }
-
if (phase == SORT) {
- sortDependentSources();
+ for (TupleState state : dependentState.values()) {
+ state.sort();
+ }
phase = SET_PROCESSING;
}
- if (!dependentState.isEmpty()) {
- replaceDependentValueIterators();
+ replaceDependentValueIterators();
+
+ LinkedList<Criteria> crits = new LinkedList<Criteria>();
+
+ for (int i = 0; i < queryCriteria.size(); i++) {
+ SetState state = this.setStates.get(i);
+ if (state == null) {
+ crits.add((Criteria)queryCriteria.get(i).clone());
+ } else {
+ Criteria crit = replaceDependentCriteria((AbstractSetCriteria)queryCriteria.get(i), state);
+ if (crit == QueryRewriter.FALSE_CRITERIA) {
+ return QueryRewriter.FALSE_CRITERIA;
+ }
+ crits.add(crit);
+ }
}
- Criteria result = (Criteria)dependentCrit.clone();
-
- return result;
+ if (crits.size() == 1) {
+ return crits.get(0);
+ }
+ return new CompoundCriteria(CompoundCriteria.AND, crits);
}
public void consumedCriteria() {
@@ -227,139 +235,20 @@
return;
}
- int restartIndex = ((Integer)restartIndexes.removeLast()).intValue();
+ int restartIndex = restartIndexes.removeLast().intValue();
for (int i = restartIndex; i < sources.size(); i++) {
- DependentSourceState dss = (DependentSourceState)dependentState.get(sources.get(i));
+ List<SetState> source = sources.get(i);
- for (int j = 0; j < dss.getDepedentSetStates().size(); j++) {
-
- SetState state = (SetState)dss.getDepedentSetStates().get(j);
-
- state.replacement.clear();
+ for (SetState setState : source) {
+ setState.replacement.clear();
}
}
- currentIterator = restartIndex;
+ currentIndex = restartIndex;
}
- private void initializeDependentState() throws MetaMatrixComponentException {
- hasNextCommand = false;
- dependentState = new LinkedHashMap();
- currentIterator = 0;
- restartIndexes = new LinkedList();
-
- List queryCriteria = Criteria.separateCriteriaByAnd(dependentCrit);
-
- for (Iterator i = queryCriteria.iterator(); i.hasNext();) {
- Criteria criteria = (Criteria)i.next();
-
- if (!(criteria instanceof AbstractSetCriteria)) {
- continue;
- }
-
- Object source = null;
-
- if (criteria instanceof SetCriteria) {
- SetCriteria setCriteria = (SetCriteria)criteria;
- if (setCriteria.getNumberOfValues() <= maxSetSize) {
- continue;
- }
- source = new Object(); //we just need a consistent hash key
-
- // jh Case 6435a
- } else if (criteria instanceof DependentSetCriteria) {
- source = ((DependentSetCriteria)criteria).getValueIteratorSource();
- } else {
- continue;
- }
- List sets = (List)dependentState.get(source);
-
- if (sets == null) {
- sets = new LinkedList();
- dependentState.put(source, sets);
- }
-
- sets.add(criteria);
- }
-
- sources = new ArrayList(dependentState.keySet());
-
- for (Iterator i = dependentState.entrySet().iterator(); i.hasNext();) {
-
- Map.Entry entry = (Map.Entry)i.next();
-
- if (entry.getKey() instanceof DependentValueSource) {
-
- DependentValueSource dvs = (DependentValueSource)entry.getKey();
-
- List sets = (List)entry.getValue();
-
- List symbols = new ArrayList(sets.size());
-
- for (int j = 0; j < sets.size(); j++) {
-
- DependentSetCriteria crit = (DependentSetCriteria)sets.get(j);
-
- SetState state = new SetState();
- state.valueExpression = crit.getValueExpression();
- symbols.add(state.valueExpression);
-
- sets.set(j, state);
-
- crit.setValueIteratorSource(new SimpleValueIteratorSource(state.replacement));
- }
-
- DependentSourceState dss = new TupleState(symbols, dvs.getTupleSource(), dvs.getTupleSourceID());
-
- entry.setValue(dss);
-
- dss.setDependentSetStates(sets);
- } else {
-
- List sets = (List)entry.getValue();
-
- SetCriteria crit = (SetCriteria)sets.get(0);
-
- DependentSourceState dss = new FixedState(crit);
-
- SetState state = new SetState();
- state.valueExpression = crit.getExpression();
-
- sets.set(0, state);
-
- crit.setValues(state.replacement);
-
- entry.setValue(dss);
-
- dss.setDependentSetStates(sets);
- }
- }
- }
-
- private void sortDependentSources() throws BlockedException,
- MetaMatrixComponentException {
- for (int i = 0; i < sources.size(); i++) {
- DependentSourceState dss = (DependentSourceState)dependentState.get(sources.get(i));
-
- dss.sort();
- }
-
- // all have been sorted, now create the tuple source iterators
- for (int i = 0; i < sources.size(); i++) {
- DependentSourceState dss = (DependentSourceState)dependentState.get(sources.get(i));
-
- dss.connectValueSource();
-
- for (int j = 0; j < dss.getDepedentSetStates().size(); j++) {
- SetState setState = (SetState)dss.getDepedentSetStates().get(j);
-
- setState.valueIterator = dss.getValueIterator(setState);
- }
- }
- }
-
/**
* Replace the dependentSet value iterators with the next set of values from the independent tuple source
*
@@ -369,9 +258,9 @@
*/
private void replaceDependentValueIterators() throws MetaMatrixComponentException {
- for (; currentIterator < sources.size(); currentIterator++) {
+ for (; currentIndex < sources.size(); currentIndex++) {
- DependentSourceState dss = (DependentSourceState)dependentState.get(sources.get(currentIterator));
+ List<SetState> source = sources.get(currentIndex);
boolean done = false;
@@ -380,9 +269,7 @@
boolean isNull = false;
boolean lessThanMax = true;
- for (int i = 0; i < dss.getDepedentSetStates().size(); i++) {
- SetState state = (SetState)dss.getDepedentSetStates().get(i);
-
+ for (SetState state : source) {
if (state.nextValue == null && !state.isNull) {
if (state.valueIterator.hasNext()) {
state.nextValue = state.valueIterator.next();
@@ -399,16 +286,14 @@
}
if (done) {
- if (!restartIndexes.isEmpty() && ((Integer)restartIndexes.getLast()).intValue() == currentIterator) {
+ if (!restartIndexes.isEmpty() && restartIndexes.getLast().intValue() == currentIndex) {
restartIndexes.removeLast();
}
break;
}
if (lessThanMax || isNull) {
- for (int i = 0; i < dss.getDepedentSetStates().size(); i++) {
- SetState state = (SetState)dss.getDepedentSetStates().get(i);
-
+ for (SetState state : source) {
if (!isNull) {
state.replacement.add(state.nextValue);
}
@@ -416,7 +301,7 @@
state.isNull = false;
}
} else {
- restartIndexes.add(new Integer(currentIterator));
+ restartIndexes.add(currentIndex);
done = true;
}
}
@@ -428,5 +313,24 @@
protected boolean hasNextCommand() {
return hasNextCommand;
}
+
+ public Criteria replaceDependentCriteria(AbstractSetCriteria crit, SetState state) {
+ if (state.replacement.isEmpty()) {
+ // No values - return criteria that is always false
+ return QueryRewriter.FALSE_CRITERIA;
+ }
+ if (state.replacement.size() == 1) {
+ return new CompareCriteria(crit.getExpression(), CompareCriteria.EQ, new Constant(state.replacement.iterator().next()));
+ }
+ List vals = new ArrayList(state.replacement.size());
+ for (Object val : state.replacement) {
+ vals.add(new Constant(val));
+ }
+
+ SetCriteria sc = new SetCriteria();
+ sc.setExpression(crit.getExpression());
+ sc.setValues(vals);
+ return sc;
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureAccessNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureAccessNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureAccessNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,7 +22,6 @@
package com.metamatrix.query.processor.relational;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -67,9 +66,9 @@
* @see com.metamatrix.query.processor.relational.PlanExecutionNode#clone()
*/
public Object clone() {
- DependentProcedureAccessNode copy = new DependentProcedureAccessNode(getID(), (Criteria)inputCriteria.clone(),
- new ArrayList(inputReferences),
- new ArrayList(inputDefaults));
+ DependentProcedureAccessNode copy = new DependentProcedureAccessNode(getID(), inputCriteria,
+ inputReferences,
+ inputDefaults);
copy(this, copy);
return copy;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureCriteriaProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureCriteriaProcessor.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureCriteriaProcessor.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -27,18 +27,18 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.sql.lang.AbstractSetCriteria;
+import com.metamatrix.query.rewriter.QueryRewriter;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.IsNullCriteria;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.util.ValueIterator;
import com.metamatrix.query.sql.util.VariableContext;
public class DependentProcedureCriteriaProcessor extends DependentCriteriaProcessor {
@@ -52,18 +52,13 @@
Criteria dependentCriteria,
List references,
List defaults,
- Evaluator eval) {
+ Evaluator eval) throws ExpressionEvaluationException, MetaMatrixComponentException {
super(1, dependentNode, dependentCriteria);
this.eval = eval;
this.inputDefaults = defaults;
this.inputReferences = references;
}
- public void reset() {
- super.reset();
- critInProgress = null;
- }
-
/**
* @throws TupleSourceNotFoundException
* @see com.metamatrix.query.processor.relational.PlanExecutionNode#prepareNextCommand()
@@ -81,6 +76,12 @@
context.remove(ref.getExpression());
}
+
+ if (critInProgress == QueryRewriter.FALSE_CRITERIA) {
+ critInProgress = null;
+ consumedCriteria();
+ return false;
+ }
boolean validRow = true;
@@ -91,14 +92,7 @@
boolean nullAllowed = false;
Reference parameter = null;
- if (crit instanceof AbstractSetCriteria) {
- AbstractSetCriteria asc = (AbstractSetCriteria)crit;
- ValueIterator iter = asc.getValueIterator();
- if (iter.hasNext()) {
- value = asc.getValueIterator().next();
- }
- parameter = (Reference)asc.getExpression();
- } else if (crit instanceof IsNullCriteria) {
+ if (crit instanceof IsNullCriteria) {
parameter = (Reference)((IsNullCriteria)crit).getExpression();
nullAllowed = true;
} else if (crit instanceof CompareCriteria) {
@@ -150,5 +144,5 @@
return true;
}
-
+
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProjectNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProjectNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProjectNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -28,8 +28,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
/**
* A project node containing one or more scalar subqueries.
@@ -40,14 +38,13 @@
public class DependentProjectNode extends ProjectNode {
private SubqueryProcessorUtility subqueryProcessor;
- private SymbolMap correlatedReferences;
/**
* @param nodeID
*/
- public DependentProjectNode(int nodeID, SymbolMap correlatedReferences) {
+ public DependentProjectNode(int nodeID, SubqueryProcessorUtility spu) {
super(nodeID);
- this.correlatedReferences = correlatedReferences;
+ this.subqueryProcessor = spu;
}
public void reset() {
@@ -65,13 +62,6 @@
this.subqueryProcessor.open(this);
}
- @Override
- public void setSelectSymbols(List symbols) {
- super.setSelectSymbols(symbols);
- List valueList = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(this.getSelectSymbols());
- this.subqueryProcessor = new SubqueryProcessorUtility(valueList, this.correlatedReferences);
- }
-
/**
* Closes the subquery processor (which removes the temporary tuple
* sources of the subquery results)
@@ -107,9 +97,8 @@
* @see java.lang.Object#clone()
*/
public Object clone(){
- DependentProjectNode clonedNode = new DependentProjectNode(super.getID(), this.correlatedReferences);
+ DependentProjectNode clonedNode = new DependentProjectNode(super.getID(), this.subqueryProcessor.clone());
super.copy(this, clonedNode);
-
return clonedNode;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentSelectNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentSelectNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentSelectNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -28,9 +28,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
/**
* This node represents a Select node for the case where the criteria
@@ -43,15 +40,14 @@
public class DependentSelectNode extends SelectNode {
private SubqueryProcessorUtility subqueryProcessor;
- private SymbolMap correlatedReferences;
/**
* Constructor for DependentSelectNode.
* @param nodeID
*/
- public DependentSelectNode(int nodeID, SymbolMap correlatedReferences) {
+ public DependentSelectNode(int nodeID, SubqueryProcessorUtility subqueryProcessorUtility) {
super(nodeID);
- this.correlatedReferences = correlatedReferences;
+ this.subqueryProcessor = subqueryProcessorUtility;
}
/** for unit testing */
@@ -74,13 +70,6 @@
this.subqueryProcessor.open(this);
}
- @Override
- public void setCriteria(Criteria criteria) {
- super.setCriteria(criteria);
- List valueList = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(this.getCriteria());
- this.subqueryProcessor = new SubqueryProcessorUtility(valueList, this.correlatedReferences);
- }
-
/**
* Closes the subquery processor (which removes the temporary tuple
* sources of the subquery results)
@@ -116,7 +105,7 @@
* @see java.lang.Object#clone()
*/
public Object clone(){
- DependentSelectNode clonedNode = new DependentSelectNode(super.getID(), this.correlatedReferences);
+ DependentSelectNode clonedNode = new DependentSelectNode(super.getID(), subqueryProcessor.clone());
super.copy(this, clonedNode);
return clonedNode;
}
Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentSourceState.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentSourceState.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentSourceState.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor.relational;
-
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.util.ValueIterator;
-
-interface DependentSourceState {
-
- public static class SetState {
-
- Collection replacement = new LinkedHashSet();
-
- Expression valueExpression;
-
- ValueIterator valueIterator;
-
- Object nextValue;
-
- boolean isNull;
- }
-
- public void sort() throws BlockedException,
- MetaMatrixComponentException;
-
- public void close() throws MetaMatrixComponentException;
-
- public ValueIterator getValueIterator(SetState setState);
-
- public void connectValueSource() throws MetaMatrixComponentException;
-
- public List getDepedentSetStates();
-
- public void setDependentSetStates(List states);
-
-}
\ No newline at end of file
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentValueSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentValueSource.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentValueSource.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,10 +22,11 @@
package com.metamatrix.query.processor.relational;
-import java.util.List;
-
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.IndexedTupleSource;
import com.metamatrix.common.buffer.TupleSourceID;
+import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.util.ValueIterator;
import com.metamatrix.query.sql.util.ValueIteratorSource;
@@ -36,47 +37,35 @@
public class DependentValueSource implements
ValueIteratorSource {
- // Runtime
- private IndexedTupleSource tupleSource;
private TupleSourceID tupleSourceID;
+ private BufferManager bm;
- public DependentValueSource() {
- super();
- }
-
- public void setTupleSource(IndexedTupleSource tupleSource, TupleSourceID tupleSourceID) {
- this.tupleSource = tupleSource;
+ public DependentValueSource(TupleSourceID tupleSourceID, BufferManager bm) {
this.tupleSourceID = tupleSourceID;
+ this.bm = bm;
}
public TupleSourceID getTupleSourceID() {
- return tupleSourceID;
- }
+ return tupleSourceID;
+ }
- public IndexedTupleSource getTupleSource() {
- return tupleSource;
- }
-
- public boolean isReady() {
- return this.tupleSource != null;
- }
-
/**
+ * @throws MetaMatrixComponentException
+ * @throws TupleSourceNotFoundException
* @see com.metamatrix.query.sql.util.ValueIteratorSource#getValueIterator(com.metamatrix.query.sql.symbol.Expression)
*/
- public ValueIterator getValueIterator(Expression valueExpression) {
- TupleSourceValueIterator iter = null;
- if(this.tupleSource != null) {
- List schema = tupleSource.getSchema();
- int columnIndex = schema.indexOf(valueExpression);
- iter = new TupleSourceValueIterator(this.tupleSource, columnIndex);
- }
- return iter;
+ public ValueIterator getValueIterator(Expression valueExpression) throws MetaMatrixComponentException {
+ IndexedTupleSource its;
+ try {
+ its = bm.getTupleSource(tupleSourceID);
+ } catch (TupleSourceNotFoundException e) {
+ throw new MetaMatrixComponentException(e);
+ }
+ int index = 0;
+ if (valueExpression != null) {
+ index = its.getSchema().indexOf(valueExpression);
+ }
+ return new TupleSourceValueIterator(its, index);
}
- public void reset() {
- // Reset runtime state
- this.tupleSource = null;
- }
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -443,12 +443,8 @@
public Object clone(){
GroupingNode clonedNode = new GroupingNode(super.getID());
super.copy(this, clonedNode);
- if(sortElements != null){
- clonedNode.sortElements = new ArrayList(sortElements);
- }
- if(sortTypes != null){
- clonedNode.sortTypes = new ArrayList(sortTypes);
- }
+ clonedNode.sortElements = sortElements;
+ clonedNode.sortTypes = sortTypes;
return clonedNode;
}
Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/IndexedTupleSourceIterator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/IndexedTupleSourceIterator.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/IndexedTupleSourceIterator.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -1,105 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor.relational;
-
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.IndexedTupleSource;
-
-/**
- * A ValueIterator implementation that iterates over the TupleSource
- */
-class IndexedTupleSourceIterator implements TupleSourceIterator {
-
- private IndexedTupleSource tupleSource;
- private int currentRow = 1;
- private int mark = 1;
- private List currentTuple;
-
- IndexedTupleSourceIterator(IndexedTupleSource tupleSource){
- this.tupleSource = tupleSource;
- }
-
- /**
- * @throws MetaMatrixProcessingException
- * @see com.metamatrix.query.processor.relational.TupleSourceIterator#hasNext()
- */
- public boolean hasNext() throws MetaMatrixComponentException, MetaMatrixProcessingException{
- if (this.currentTuple != null) {
- return true;
- }
-
- this.tupleSource.setCurrentTupleIndex(currentRow);
-
- this.currentTuple = this.tupleSource.nextTuple();
-
- return this.currentTuple != null;
- }
-
- /**
- * @throws MetaMatrixProcessingException
- * @see com.metamatrix.query.processor.relational.TupleSourceIterator#next()
- */
- public List next() throws MetaMatrixComponentException, MetaMatrixProcessingException{
- if (currentTuple == null && !hasNext()){
- throw new NoSuchElementException();
- }
- this.currentRow++;
- List result = currentTuple;
- currentTuple = null;
- return result;
- }
-
- /**
- * @see com.metamatrix.query.processor.relational.TupleSourceIterator#reset()
- */
- public void reset() {
- this.currentRow = mark;
- this.mark = 1;
- }
-
- /**
- * @see com.metamatrix.query.processor.relational.TupleSourceIterator#getCurrentIndex()
- */
- public int getCurrentIndex() {
- return currentRow;
- }
-
- /**
- * @see com.metamatrix.query.processor.relational.TupleSourceIterator#mark()
- */
- public void mark() {
- this.mark = currentRow;
- }
-
- /**
- * @see com.metamatrix.query.processor.relational.TupleSourceIterator#setPosition(int)
- */
- public void setPosition(int position) {
- this.currentRow = position;
- }
-
-}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -36,7 +36,6 @@
import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.symbol.Expression;
/**
* @since 4.2
@@ -51,7 +50,7 @@
private JoinStrategy joinStrategy;
private JoinType joinType;
- private DependentValueSource dependentValueSource;
+ private String dependentValueSource;
// Set up state - need to be cloned but not reset
private List leftExpressions;
@@ -133,21 +132,9 @@
clonedNode.joinCriteria = this.joinCriteria;
- if (leftExpressions != null) {
- List leftCopy = new ArrayList(leftExpressions.size());
- for(int i=0; i<leftExpressions.size(); i++) {
- leftCopy.add(((Expression)leftExpressions.get(i)).clone());
- }
- clonedNode.leftExpressions = leftCopy;
- }
+ clonedNode.leftExpressions = leftExpressions;
- if (rightExpressions != null) {
- List rightCopy = new ArrayList(rightExpressions.size());
- for(int i=0; i<rightExpressions.size(); i++) {
- rightCopy.add(((Expression)rightExpressions.get(i)).clone());
- }
- clonedNode.rightExpressions = rightCopy;
- }
+ clonedNode.rightExpressions = rightExpressions;
clonedNode.dependentValueSource = this.dependentValueSource;
return clonedNode;
@@ -168,7 +155,7 @@
if (state == State.LOAD_RIGHT) {
if (isDependent() && !this.rightOpened) {
TupleSourceID tsID = this.joinStrategy.leftSource.getTupleSourceID();
- this.dependentValueSource.setTupleSource(this.getBufferManager().getTupleSource(tsID), tsID);
+ this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource, new DependentValueSource(tsID, this.getBufferManager()));
//open the right side now that the tuples have been collected
this.getChildren()[1].open();
this.rightOpened = true;
@@ -259,7 +246,7 @@
/**
* @param isDependent The isDependent to set.
*/
- public void setDependentValueSource(DependentValueSource dependentValueSource) {
+ public void setDependentValueSource(String dependentValueSource) {
this.dependentValueSource = dependentValueSource;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/LimitNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/LimitNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/LimitNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -150,15 +150,8 @@
}
public Object clone() {
- Expression clonedLimit = null;
- if (limitExpr != null) {
- clonedLimit = (Expression)limitExpr.clone();
- }
- Expression clonedOffset = null;
- if (offsetExpr != null) {
- clonedOffset = (Expression)offsetExpr.clone();
- }
- LimitNode node = new LimitNode(getID(), clonedLimit, clonedOffset);
+
+ LimitNode node = new LimitNode(getID(), limitExpr, offsetExpr);
copy(this, node);
node.rowCounter = this.rowCounter;
return node;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectIntoNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectIntoNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectIntoNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -203,8 +203,8 @@
ProjectIntoNode clonedNode = new ProjectIntoNode(super.getID());
super.copy(this, clonedNode);
- clonedNode.intoGroup = (GroupSymbol) intoGroup.clone();
- clonedNode.intoElements = new ArrayList(intoElements);
+ clonedNode.intoGroup = intoGroup;
+ clonedNode.intoElements = intoElements;
clonedNode.modelName = this.modelName;
clonedNode.doBatching = this.doBatching;
clonedNode.doBulkInsert = this.doBulkInsert;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -36,7 +36,6 @@
import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.AliasSymbol;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -288,13 +287,7 @@
protected void copy(ProjectNode source, ProjectNode target){
super.copy(source, target);
- if(selectSymbols != null){
- List clonedSymbols = new ArrayList(source.selectSymbols.size());
- for (LanguageObject obj : (List<LanguageObject>)this.selectSymbols) {
- clonedSymbols.add(obj.clone());
- }
- target.setSelectSymbols(clonedSymbols);
- }
+ target.selectSymbols = this.selectSymbols;
}
/*
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -170,12 +170,8 @@
protected void copy(SelectNode source, SelectNode target){
super.copy(source, target);
- if(criteria != null){
- target.setCriteria((Criteria)source.criteria.clone());
- }
- if(elementMap != null){
- target.elementMap = new HashMap(source.elementMap);
- }
+ target.criteria = criteria;
+ target.elementMap = source.elementMap;
}
/*
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -38,8 +38,7 @@
private IndexedTupleSource tupleSource;
private TupleSourceID tsID;
private List<Object> outerVals;
- private TupleSourceIterator iterator;
- private List expressions;
+ private IndexedTupleSource iterator;
private int[] expressionIndexes;
private List currentTuple;
private int maxProbeMatch = 1;
@@ -65,7 +64,7 @@
}
public List saveNext() throws MetaMatrixComponentException, MetaMatrixProcessingException {
- this.currentTuple = this.getIterator().next();
+ this.currentTuple = this.getIterator().nextTuple();
return currentTuple;
}
@@ -112,10 +111,10 @@
}
}
- TupleSourceIterator getIterator() {
+ IndexedTupleSource getIterator() {
if (this.iterator == null) {
if (this.tupleSource != null) {
- iterator = new IndexedTupleSourceIterator(this.tupleSource);
+ iterator = this.tupleSource;
} else {
// return a TupleBatch tuplesource iterator
iterator = new BatchIterator(this.source);
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryProcessorUtility.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryProcessorUtility.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryProcessorUtility.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -30,62 +30,30 @@
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.IndexedTupleSource;
import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.sql.util.ValueIteratorProvider;
import com.metamatrix.query.sql.util.VariableContext;
import com.metamatrix.query.util.CommandContext;
/**
* <p>This utility handles the work of processing a subquery; certain types
* of processor nodes will use an instance of this class to do that work.
- * All the corresponding "child" or "sub" ProcessorPlans
- * (one for each ValueIteratorProvider) must be processed before the
- * client processor node can do it's work.</p>
- *
- * <p>For example, a DependentSelectNode is basically a select node where
- * part of the criteria is a subquery. The criteria cannot be evaluated
- * until the values of the subquery result are available. A
- * DependentProjectNode is a project node where one of the projected
- * symbols is a scalar subquery. That project cannot be performed until
- * the scalar subquery is executed and it's value is available so that the
- * subquery can be evaluated as an expression.</p>
- *
- * <p>The ValueIteratorProvider interface abstracts a language object that
- * needs to have it's subquery processed and the resulting values given to
- * it. This utility class does the processing of the subquery ProcessorPlan,
- * and provides the ValueIteratorProvider instance with a ValueIterator
- * instance, which iterates over the subquery results.</p>
*/
public class SubqueryProcessorUtility {
- /**
- * List of ProcessorPlans for each subquery. Contents match
- * 1-for-1 with the contents of {@link #valueIteratorProviders} List
- * see {@link #setPlansAndValueProviders}
- */
- private List<ProcessorPlan> processorPlans = new ArrayList<ProcessorPlan>();
- private List<QueryProcessor> processors = new ArrayList<QueryProcessor>();
+ private List<? extends ProcessorPlan> processorPlans;
+ private List<String> contextReferences;
+ private SymbolMap correlatedReferences;
- /**
- * List of ValueIteratorProvider for each subquery. Contents match
- * 1-for-1 with the contents of {@link #processorPlans} List
- * see {@link #setPlansAndValueProviders}
- */
- private List<ValueIteratorProvider> valueIteratorProviders;
-
- private SymbolMap correlatedReferences;
-
+ private List<QueryProcessor> processors = new ArrayList<QueryProcessor>();
+
// "Placeholder" state, for resuming processing after
// a BlockedException - not cloned
private int currentIndex = 0;
@@ -97,25 +65,26 @@
private VariableContext currentContext;
- public SubqueryProcessorUtility(List<ValueIteratorProvider> valList, SymbolMap references) {
- for (ValueIteratorProvider val : valList) {
- SubqueryContainer sc = (SubqueryContainer)val;
- this.processorPlans.add((ProcessorPlan)sc.getCommand().getProcessorPlan().clone());
- }
- this.valueIteratorProviders = valList;
+ public SubqueryProcessorUtility(List<? extends ProcessorPlan> valList, List<String> contextReferences, SymbolMap references) {
+ this.processorPlans = valList;
+ this.contextReferences = contextReferences;
if (references != null && !references.asMap().isEmpty()) {
this.correlatedReferences = references;
}
}
+
+ public SubqueryProcessorUtility clone() {
+ List<ProcessorPlan> plans = new ArrayList<ProcessorPlan>(processorPlans.size());
+ for (ProcessorPlan processorPlan : processorPlans) {
+ plans.add((ProcessorPlan)processorPlan.clone());
+ }
+ return new SubqueryProcessorUtility(plans, contextReferences, correlatedReferences);
+ }
- List<ProcessorPlan> getSubqueryPlans(){
+ List<? extends ProcessorPlan> getSubqueryPlans(){
return this.processorPlans;
}
- List getValueIteratorProviders(){
- return this.valueIteratorProviders;
- }
-
void reset() {
this.currentIndex = 0;
currentProcessor = null;
@@ -212,10 +181,8 @@
}
// Process the results
- IndexedTupleSource subqueryResults = null;
try {
this.currentProcessor.process(Integer.MAX_VALUE);
- subqueryResults = parent.getBufferManager().getTupleSource(this.currentProcessor.getResultsID());
this.currentProcessor.getProcessorPlan().reset();
} catch (MetaMatrixProcessingException e) {
throw e;
@@ -226,9 +193,7 @@
}
// Set the results on the ValueIteratorProviders
- ValueIteratorProvider vip = this.valueIteratorProviders.get(this.currentIndex);
- ValueIterator iterator = new TupleSourceValueIterator(subqueryResults, 0);
- vip.setValueIterator(iterator);
+ parent.getContext().getVariableContext().setGlobalValue(this.contextReferences.get(this.currentIndex), new DependentValueSource(this.currentProcessor.getResultsID(), parent.getBufferManager()));
this.currentProcessor = null;
this.currentIndex++;
Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/TupleSourceIterator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/TupleSourceIterator.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/TupleSourceIterator.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor.relational;
-
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-
-/**
- * @since 4.3
- */
-interface TupleSourceIterator {
-
- /**
- * @see java.util.Iterator#hasNext()
- */
- boolean hasNext() throws MetaMatrixComponentException, MetaMatrixProcessingException;
-
- /**
- * Returns constant Object values, not Expressions.
- * @see java.util.Iterator#next()
- */
- List next() throws MetaMatrixComponentException, MetaMatrixProcessingException;
-
- /**
- * Flags a reset as being needed
- * @see com.metamatrix.query.sql.util.ValueIterator#reset()
- */
- void reset();
-
- void mark();
-
- int getCurrentIndex();
-
- void setPosition(int position);
-
- //int available();
-
-}
\ No newline at end of file
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/TupleSourceValueIterator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/TupleSourceValueIterator.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/TupleSourceValueIterator.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -37,11 +37,11 @@
*/
class TupleSourceValueIterator implements ValueIterator{
- private TupleSourceIterator tupleSourceIterator;
+ private IndexedTupleSource tupleSourceIterator;
private int columnIndex;
TupleSourceValueIterator(IndexedTupleSource tupleSource, int columnIndex){
- this.tupleSourceIterator = new IndexedTupleSourceIterator(tupleSource);
+ this.tupleSourceIterator = tupleSource;
this.columnIndex = columnIndex;
}
@@ -62,7 +62,7 @@
*/
public Object next() throws MetaMatrixComponentException{
try {
- return tupleSourceIterator.next().get(columnIndex);
+ return tupleSourceIterator.nextTuple().get(columnIndex);
} catch (MetaMatrixProcessingException err) {
throw new MetaMatrixComponentException(err, err.getMessage());
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/AbstractSetCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/AbstractSetCriteria.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/AbstractSetCriteria.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -23,15 +23,13 @@
package com.metamatrix.query.sql.lang;
import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.util.ValueIteratorProvider;
/**
* This is an abstract class to define some common functionality in the two varieties of
* IN criteria: {@link SetCriteria} (where values are specified) and {@link SubquerySetCriteria}
* (where a subquery is defined and will supply the values for the IN set).
*/
-public abstract class AbstractSetCriteria extends PredicateCriteria
-implements ValueIteratorProvider{
+public abstract class AbstractSetCriteria extends PredicateCriteria {
/** The left expression */
private Expression expression;
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/DependentSetCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/DependentSetCriteria.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/DependentSetCriteria.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,15 +22,11 @@
package com.metamatrix.query.sql.lang;
-import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageVisitor;
+import com.metamatrix.query.sql.symbol.ContextReference;
import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.sql.util.ValueIteratorSource;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
@@ -39,45 +35,28 @@
* by a separate processing node.
* @since 5.0.1
*/
-public class DependentSetCriteria extends AbstractSetCriteria {
-
+public class DependentSetCriteria extends AbstractSetCriteria implements ContextReference {
+
/**
- * Specifies who will provide the value iterator later during execution. The
- * ValueIterator is typically not ready yet, so we can't hold it directly.
- */
- private ValueIteratorSource valueIteratorSource;
-
- /**
* Specifies the expression whose values we want to return in the iterator
*/
private Expression valueExpression;
+ private String id;
/**
* Construct with the left expression
*/
- public DependentSetCriteria(Expression expr) {
+ public DependentSetCriteria(Expression expr, String id) {
setExpression(expr);
+ this.id = id;
}
-
- /**
- * Get the valute iterator source, which will provide the iterator
- * when it is ready during processing.
- * @return Returns the valueIteratorSource.
- */
- public ValueIteratorSource getValueIteratorSource() {
- return this.valueIteratorSource;
+
+ @Override
+ public String getContextSymbol() {
+ return id;
}
-
/**
- * Set the value iterator source, which will provide value iterators during processing.
- * @param valueIteratorSource The valueIteratorSource to set.
- */
- public void setValueIteratorSource(ValueIteratorSource valueIteratorSource) {
- this.valueIteratorSource = valueIteratorSource;
- }
-
- /**
* Get the independent value expression
* @return Returns the valueExpression.
*/
@@ -94,25 +73,6 @@
this.valueExpression = valueExpression;
}
- /**
- * Returns a ValueIterator to obtain the values in this IN criteria's value set.
- * This method can only be safely called if the ValueIteratorSource is ready.
- * @return this object's ValueIterator instance
- * @throws MetaMatrixRuntimeException if the subquery for this set criteria
- * has not yet been processed and no value iterator is available
- * @see com.metamatrix.query.sql.lang.AbstractSetCriteria#getValueIterator()
- */
- public ValueIterator getValueIterator() {
- ValueIterator valueIterator = this.valueIteratorSource.getValueIterator(this.valueExpression);
-
- if(valueIterator == null) {
- throw new MetaMatrixRuntimeException(ErrorMessageKeys.SQL_0012, QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0012));
- }
-
- valueIterator.reset();
- return valueIterator;
- }
-
public void acceptVisitor(LanguageVisitor visitor) {
visitor.visit(this);
}
@@ -165,21 +125,11 @@
copy = (Expression) getExpression().clone();
}
- DependentSetCriteria criteriaCopy = new DependentSetCriteria(copy);
+ DependentSetCriteria criteriaCopy = new DependentSetCriteria(copy, id);
criteriaCopy.setNegated(isNegated());
- criteriaCopy.setValueIteratorSource(getValueIteratorSource());
criteriaCopy.setValueExpression((Expression) getValueExpression().clone());
+ criteriaCopy.id = this.id;
return criteriaCopy;
}
- /**
- * This method is not supported for DependentSetCriteria as it will obtain it's
- * value iterators for the ValueIteratorSource.
- * @see com.metamatrix.query.sql.lang.AbstractSetCriteria#setValueIterator(com.metamatrix.query.sql.util.ValueIterator)
- * @throws UnsupportedOperationException Always
- */
- public void setValueIterator(ValueIterator valueIterator) {
- throw new UnsupportedOperationException("DependentSetCriteria.setValueIterator() should never be called as the value iterator is produced dynamically."); //$NON-NLS-1$
- }
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ExistsCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ExistsCriteria.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ExistsCriteria.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,14 +22,13 @@
package com.metamatrix.query.sql.lang;
-import com.metamatrix.core.MetaMatrixRuntimeException;
+import java.util.concurrent.atomic.AtomicInteger;
+
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.sql.util.ValueIteratorProvider;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import com.metamatrix.query.sql.symbol.ContextReference;
+import com.metamatrix.query.sql.symbol.Expression;
/**
* This predicate criteria implements the "exists" predicate, which has
@@ -37,10 +36,12 @@
* "EXISTS (Select EmployeeID FROM Employees WHERE EmployeeName = 'Smith')".
*/
public class ExistsCriteria extends PredicateCriteria
-implements SubqueryContainer, ValueIteratorProvider {
+implements SubqueryContainer, ContextReference {
+
+ private static AtomicInteger ID = new AtomicInteger();
private Command command;
- private ValueIterator valueIterator;
+ private String id = "$ec/id" + ID.getAndIncrement(); //$NON-NLS-1$
/**
* Default constructor
@@ -52,6 +53,16 @@
public ExistsCriteria(Command subqueryCommand){
this.command = subqueryCommand;
}
+
+ @Override
+ public String getContextSymbol() {
+ return id;
+ }
+
+ @Override
+ public Expression getValueExpression() {
+ return null;
+ }
/**
* @see com.metamatrix.query.sql.lang.SubqueryCriteria#getCommand()
@@ -64,35 +75,6 @@
this.command = subqueryCommand;
}
- /**
- * Returns always the same instance of a ValueIterator, but
- * {@link ValueIterator#reset resets} it each time this method is called
- * @return this object's ValueIterator instance (always the same instance)
- * @throws MetaMatrixRuntimeException if the subquery for this set criteria
- * has not yet been processed and no value iterator is available
- * @see com.metamatrix.query.sql.lang.AbstractSetCriteria#getValueIterator()
- */
- public ValueIterator getValueIterator() {
- if (this.valueIterator == null){
- throw new MetaMatrixRuntimeException(ErrorMessageKeys.SQL_0034, QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0034));
- }
- this.valueIterator.reset();
- return this.valueIterator;
- }
-
- /**
- * Set the ValueIterator on this object (the ValueIterator will encapsulate
- * the single-column results of the subquery processor plan). This
- * ValueIterator must be set before processing (before the Criteria can be
- * evaluated). Also, this ValueIterator should be considered transient -
- * only available during processing - and it will not be cloned should
- * this Criteria object be cloned.
- * @param valueIterator encapsulating the results of the sub query
- */
- public void setValueIterator(ValueIterator valueIterator) {
- this.valueIterator = valueIterator;
- }
-
public void acceptVisitor(LanguageVisitor visitor) {
visitor.visit(this);
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetCriteria.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetCriteria.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,13 +22,17 @@
package com.metamatrix.query.sql.lang;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
+import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.util.ValueIterator;
/**
* A criteria which is true is the expression's value is a member in a list
@@ -78,25 +82,7 @@
this.values = values;
}
- /**
- * Returns a new instance of a ValueIterator
- * @return new ValueIterator instance
- * @see com.metamatrix.query.sql.lang.AbstractSetCriteria#getValueIterator()
- */
- public ValueIterator getValueIterator() {
- return new CollectionValueIterator(this.values);
- }
-
/**
- * This method is purposely not implemented. The values are
- * set through the constructor or the {@link #setValues} method.
- * @see com.metamatrix.query.sql.util.ValueIteratorProvider#setValueIterator(com.metamatrix.query.sql.util.ValueIterator)
- */
- public void setValueIterator(ValueIterator valueIterator) {
- //Do nothing
- }
-
- /**
* Sets the membership expression and the set of value expressions
* @param expression The membership expression
* @param values The set of value expressions
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SubqueryCompareCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SubqueryCompareCriteria.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SubqueryCompareCriteria.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,16 +22,14 @@
package com.metamatrix.query.sql.lang;
-import com.metamatrix.core.MetaMatrixRuntimeException;
+import java.util.concurrent.atomic.AtomicInteger;
+
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageVisitor;
+import com.metamatrix.query.sql.symbol.ContextReference;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.sql.util.ValueIteratorProvider;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
* <p>This class implements a quantified comparison predicate. This is
@@ -57,8 +55,10 @@
* </UL>
*/
public class SubqueryCompareCriteria extends AbstractCompareCriteria
-implements SubqueryContainer, ValueIteratorProvider{
+implements SubqueryContainer, ContextReference {
+ private static AtomicInteger ID = new AtomicInteger();
+
/** "All" predicate quantifier */
public static final int NO_QUANTIFIER = 1;
@@ -74,9 +74,8 @@
private int predicateQuantifier = NO_QUANTIFIER;
private Command command;
+ private String id = "$scc/id" + ID.getAndIncrement(); //$NON-NLS-1$
- private ValueIterator valueIterator;
-
public SubqueryCompareCriteria(){
super();
}
@@ -87,6 +86,16 @@
setOperator(operator);
setPredicateQuantifier(predicateQuantifier);
}
+
+ @Override
+ public String getContextSymbol() {
+ return id;
+ }
+
+ @Override
+ public Expression getValueExpression() {
+ return null;
+ }
/**
* Get the predicate quantifier - returns one of the following:
@@ -128,35 +137,6 @@
}
/**
- * Returns always the same instance of a ValueIterator, but
- * {@link ValueIterator#reset resets} it each time this method is called
- * @return this object's ValueIterator instance (always the same instance)
- * @throws MetaMatrixRuntimeException if the subquery for this set criteria
- * has not yet been processed and no value iterator is available
- * @see com.metamatrix.query.sql.lang.SubqueryCriteria#getValueIterator()
- */
- public ValueIterator getValueIterator() {
- if (this.valueIterator == null){
- throw new MetaMatrixRuntimeException(ErrorMessageKeys.SQL_0034, QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0034));
- }
- this.valueIterator.reset();
- return this.valueIterator;
- }
-
- /**
- * Set the ValueIterator on this object (the ValueIterator will encapsulate
- * the single-column results of the subquery processor plan). This
- * ValueIterator must be set before processing (before the Criteria can be
- * evaluated). Also, this ValueIterator should be considered transient -
- * only available during processing - and it will not be cloned should
- * this Criteria object be cloned.
- * @param valueIterator encapsulating the results of the sub query
- */
- public void setValueIterator(ValueIterator valueIterator) {
- this.valueIterator = valueIterator;
- }
-
- /**
* Returns the predicate quantifier as a string.
* @return String version of predicate quantifier
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SubquerySetCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SubquerySetCriteria.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SubquerySetCriteria.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,24 +22,25 @@
package com.metamatrix.query.sql.lang;
-import com.metamatrix.core.MetaMatrixRuntimeException;
+import java.util.concurrent.atomic.AtomicInteger;
+
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageVisitor;
+import com.metamatrix.query.sql.symbol.ContextReference;
import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
* A criteria which is true is the expression's value is a member in a list
* of values returned from a subquery. This criteria can be represented as
* "<expression> IN (SELECT ...)".
*/
-public class SubquerySetCriteria extends AbstractSetCriteria implements SubqueryContainer {
+public class SubquerySetCriteria extends AbstractSetCriteria implements SubqueryContainer, ContextReference {
+ private static AtomicInteger ID = new AtomicInteger();
+
private Command command;
- private ValueIterator valueIterator;
+ private String id = "$ssc/id" + ID.getAndIncrement(); //$NON-NLS-1$
/**
* Constructor for SubquerySetCriteria.
@@ -52,6 +53,16 @@
setExpression(expression);
setCommand(subCommand);
}
+
+ @Override
+ public String getContextSymbol() {
+ return id;
+ }
+
+ @Override
+ public Expression getValueExpression() {
+ return null;
+ }
/**
* Set the subquery command (either a SELECT or a procedure execution).
@@ -69,35 +80,6 @@
return this.command;
}
- /**
- * Returns always the same instance of a ValueIterator, but
- * {@link ValueIterator#reset resets} it each time this method is called
- * @return this object's ValueIterator instance (always the same instance)
- * @throws MetaMatrixRuntimeException if the subquery for this set criteria
- * has not yet been processed and no value iterator is available
- * @see com.metamatrix.query.sql.lang.AbstractSetCriteria#getValueIterator()
- */
- public ValueIterator getValueIterator() {
- if (this.valueIterator == null){
- throw new MetaMatrixRuntimeException(ErrorMessageKeys.SQL_0012, QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0012));
- }
- this.valueIterator.reset();
- return this.valueIterator;
- }
-
- /**
- * Set the ValueIterator on this object (the ValueIterator will encapsulate
- * the single-column results of the subquery processor plan). This
- * ValueIterator must be set before processing (before the Criteria can be
- * evaluated). Also, this ValueIterator should be considered transient -
- * only available during processing - and it will not be cloned should
- * this Criteria object be cloned.
- * @param valueIterator encapsulating the results of the sub query
- */
- public void setValueIterator(ValueIterator valueIterator) {
- this.valueIterator = valueIterator;
- }
-
public void acceptVisitor(LanguageVisitor visitor) {
visitor.visit(this);
}
Added: trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ContextReference.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ContextReference.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ContextReference.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.query.sql.symbol;
+
+public interface ContextReference {
+
+ public String getContextSymbol();
+
+ public Expression getValueExpression();
+
+}
Property changes on: trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ContextReference.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -32,7 +32,7 @@
* to an element from another scope). This reference may resolve to many different values
* during evaluation. For any particular bound value, it is treated as a constant.
*/
-public class Reference implements Expression {
+public class Reference implements Expression, ContextReference {
private boolean positional;
@@ -73,11 +73,18 @@
public int getIndex() {
return this.refIndex;
}
+
+ @Override
+ public String getContextSymbol() {
+ return "$param/pos" + this.refIndex; //$NON-NLS-1$
+ }
+
+ @Override
+ public Expression getValueExpression() {
+ return this.expression;
+ }
public ElementSymbol getExpression() {
- if (this.isPositional() && this.expression == null) {
- return new ElementSymbol("$param/pos" + this.refIndex); //$NON-NLS-1$
- }
return this.expression;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ScalarSubquery.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ScalarSubquery.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ScalarSubquery.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,15 +22,12 @@
package com.metamatrix.query.sql.symbol;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.QueryPlugin;
+import java.util.concurrent.atomic.AtomicInteger;
+
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.sql.util.ValueIteratorProvider;
import com.metamatrix.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
* This is an Expression implementation that can be used in a SELECT clause.
@@ -40,16 +37,15 @@
* of this could be used wherever an Expression is legal, but it is
* specifically needed for the SELECT clause.
*/
-public class ScalarSubquery implements Expression, SubqueryContainer, ValueIteratorProvider {
+public class ScalarSubquery implements Expression, SubqueryContainer, ContextReference {
+ private static AtomicInteger ID = new AtomicInteger();
+
private Command command;
private Class type;
private int hashCode;
+ private String id = "$sc/id" + ID.getAndIncrement(); //$NON-NLS-1$
- // This is "transient" state, available only during query
- // processing. It is not cloned, if present.
- private ValueIterator valueIterator;
-
/**
* Default constructor
*/
@@ -60,34 +56,15 @@
public ScalarSubquery(Command subqueryCommand){
this.setCommand(subqueryCommand);
}
-
- /**
- * Returns always the same instance of a ValueIterator, but
- * {@link ValueIterator#reset resets} it each time this method is called
- * @return this object's ValueIterator instance (always the same instance)
- * @throws MetaMatrixRuntimeException if the subquery for this set criteria
- * has not yet been processed and no value iterator is available
- * @see com.metamatrix.query.sql.lang.SubqueryLanguageObject#getValueIterator()
- */
- public ValueIterator getValueIterator() {
- if (this.valueIterator == null){
- throw new MetaMatrixRuntimeException(ErrorMessageKeys.SQL_0034, QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0034));
- }
- this.valueIterator.reset();
- return this.valueIterator;
+
+ @Override
+ public String getContextSymbol() {
+ return id;
}
-
- /**
- * Set the ValueIterator on this object (the ValueIterator will encapsulate
- * the single-column results of the subquery processor plan). This
- * ValueIterator must be set before processing (before the Criteria can be
- * evaluated). Also, this ValueIterator should be considered transient -
- * only available during processing - and it will not be cloned should
- * this Criteria object be cloned.
- * @param valueIterator encapsulating the results of the sub query
- */
- public void setValueIterator(ValueIterator valueIterator) {
- this.valueIterator = valueIterator;
+
+ @Override
+ public Expression getValueExpression() {
+ return null;
}
/**
Deleted: trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorProvider.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorProvider.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorProvider.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.sql.util;
-
-import com.metamatrix.query.sql.LanguageObject;
-
-/**
- * <p>Language Object Implementors of this interface will provide a
- * {@link ValueIterator} over one or potentially more values
- * that they have.</p>
- *
- * <p>Also, in some cases implementors may need to
- * have their value iterators given to them by some external
- * entity, so there is a setter method in this interface.</p>
- */
-public interface ValueIteratorProvider extends LanguageObject {
-
- /**
- * Get the {@link ValueIterator} from this ValueIterator provider
- * @return ValueIterator over the values of this instance
- */
- ValueIterator getValueIterator();
-
- /**
- * Set the {@link ValueIterator} instance on this ValueIterator
- * provider. Note that the implementor may choose to not
- * implement this method, and the method call would have no
- * effect.
- * @param valueIterator an instance of ValueIterator to be set
- * on this ValueIterator provider (as in the case of subquery
- * containers whose results are provided externally).
- */
- void setValueIterator(ValueIterator valueIterator);
-
-}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorSource.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorSource.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,6 +22,8 @@
package com.metamatrix.query.sql.util;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.query.sql.symbol.Expression;
@@ -39,14 +41,10 @@
* not ready yet, return null to indicate that.
* @param valueExpression The expression we are retrieving an iterator for
* @return ValueIterator if ready, null otherwise
+ * @throws MetaMatrixComponentException
+ * @throws TupleSourceNotFoundException
* @since 5.0.1
*/
- ValueIterator getValueIterator(Expression valueExpression);
+ ValueIterator getValueIterator(Expression valueExpression) throws MetaMatrixComponentException;
- /**
- * Check whether the source is ready to provide valid iterators
- * @return True if iterator is ready
- */
- boolean isReady();
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -25,7 +25,10 @@
import java.util.HashMap;
import java.util.Map;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.util.ErrorMessageKeys;
public class VariableContext {
@@ -48,8 +51,27 @@
this.variableMap = new HashMap();
}
+ public void setGlobalValue(String variable, Object value) {
+ if (this.parentContext != null) {
+ this.parentContext.setGlobalValue(variable, value);
+ } else {
+ variableMap.put(variable, value);
+ }
+ }
+
+ public Object getGlobalValue(String variable) throws MetaMatrixComponentException {
+ if (this.parentContext != null) {
+ return this.parentContext.getGlobalValue(variable);
+ }
+ Object value = variableMap.get(variable);
+ if (value == null && !variableMap.containsKey(variable)) {
+ throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, variable, "No value was available")); //$NON-NLS-1$
+ }
+ return value;
+ }
+
/**
- * Set the value for the given, if the variable aready exits replaces its value
+ * Set the value for the given, if the variable already exits replaces its value
* with the given value else adds a new variable to the map.
* @param variable The <code>ElementSymbol</code> to be added as a variable.
* @param value The value to be set for the given variable.
@@ -135,6 +157,7 @@
if(this.parentContext != null) {
return this.parentContext.isEmpty();
}
+ return true;
}
return false;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluateExpressionVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluateExpressionVisitor.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluateExpressionVisitor.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,33 +22,21 @@
package com.metamatrix.query.sql.visitor;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.eval.LookupEvaluator;
import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SetCriteria;
import com.metamatrix.query.sql.navigator.DeepPostOrderNavigator;
import com.metamatrix.query.sql.navigator.PostOrderNavigator;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.util.ValueIterator;
+import com.metamatrix.query.sql.symbol.ScalarSubquery;
import com.metamatrix.query.util.CommandContext;
/**
@@ -64,80 +52,14 @@
private CommandContext context;
private LookupEvaluator dataMgr;
- public EvaluateExpressionVisitor() {
+ EvaluateExpressionVisitor() {
super(null);
}
public void setContext(CommandContext context) {
this.context = context;
}
-
- // ######### Visit methods that are replacing DependentSetCriteria with resolved SetCriteria ########
-
- public void visit(CompoundCriteria obj) {
- List crit = obj.getCriteria();
- List newCrit = new ArrayList(crit.size());
- Iterator iter = crit.iterator();
- while(iter.hasNext()) {
- newCrit.add(checkDependentCriteria((Criteria) iter.next()));
- }
- obj.setCriteria(newCrit);
- }
- public void visit(JoinPredicate obj) {
- List joinCrit = obj.getJoinCriteria();
- List newCrit = new ArrayList(joinCrit.size());
- Iterator iter = joinCrit.iterator();
- while(iter.hasNext()) {
- newCrit.add(checkDependentCriteria((Criteria) iter.next()));
- }
- obj.setJoinCriteria(newCrit);
- }
-
- public void visit(Query obj) {
- obj.setCriteria(checkDependentCriteria(obj.getCriteria()));
- obj.setHaving(checkDependentCriteria(obj.getHaving()));
- }
-
- private Criteria checkDependentCriteria(Criteria crit) {
- if (!(crit instanceof DependentSetCriteria)) {
- return crit;
- }
- return replaceDependentCriteria((DependentSetCriteria)crit);
- }
-
- public Criteria replaceDependentCriteria(DependentSetCriteria crit) {
- ValueIterator iter = crit.getValueIterator();
- if(iter == null) {
- // Something has gone horribly wrong! This should never happen
- Assertion.failed(QueryPlugin.Util.getString("EvaluateExpressionVisitor.Cant_get_iterator", crit.getValueExpression().toString())); //$NON-NLS-1$
- }
-
- try {
- List vals = new ArrayList();
- while(iter.hasNext()) {
- Object val = iter.next();
- if(val != null) {
- vals.add(new Constant(val));
- }
- }
-
- if(vals.size() > 0) {
- SetCriteria sc = new SetCriteria();
- sc.setExpression(crit.getExpression());
- sc.setValues(vals);
- return sc;
- }
-
- // No values - return criteria that is always false
- return new CompareCriteria(new Constant(new Integer(0)), CompareCriteria.EQ, new Constant(new Integer(1)));
-
- } catch(MetaMatrixComponentException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- }
-
-
/**
* Evaluate the expression. This method takes into account whether the
* Expression CAN be evaluated or not.
@@ -151,12 +73,8 @@
* @return
*/
public Expression replaceExpression(Expression expr) {
- if(!ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(expr).isEmpty()) {
- return expr;
- }
-
//if the expression is a constant or is not evaluatable, just return
- if (expr instanceof Constant || (!(expr instanceof Reference) && !EvaluatableVisitor.isEvaluatable(expr, false, true, false, false))) {
+ if (expr instanceof Constant || expr instanceof ScalarSubquery || (!(expr instanceof Reference) && !EvaluatableVisitor.isEvaluatable(expr, false, true, false, false))) {
return expr;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -28,13 +28,20 @@
import java.util.Stack;
import java.util.TimeZone;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryProcessingException;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.eval.SecurityFunctionEvaluator;
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.optimizer.relational.PlanToProcessConverter;
import com.metamatrix.query.processor.QueryProcessor;
+import com.metamatrix.query.sql.symbol.ContextReference;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.Expression;
+import com.metamatrix.query.sql.util.ValueIterator;
+import com.metamatrix.query.sql.util.ValueIteratorSource;
import com.metamatrix.query.sql.util.VariableContext;
/**
@@ -89,7 +96,7 @@
private QueryProcessor.ProcessorFactory queryProcessorFactory;
- private VariableContext variableContext;
+ private VariableContext variableContext = new VariableContext();
/**
* Construct a new context.
@@ -403,4 +410,25 @@
toPush.setParentContext(this.variableContext);
this.variableContext = toPush;
}
+
+ public Object getFromContext(Expression expression) throws MetaMatrixComponentException {
+ if (variableContext == null || !(expression instanceof ElementSymbol)) {
+ throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, expression, "No value was available")); //$NON-NLS-1$
+ }
+ Object value = variableContext.getValue((ElementSymbol)expression);
+ if (value == null && !variableContext.containsVariable((ElementSymbol)expression)) {
+ throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, expression, "No value was available")); //$NON-NLS-1$
+ }
+ return value;
+ }
+
+ public ValueIterator getValueIterator(ContextReference ref)
+ throws MetaMatrixComponentException {
+ if (variableContext == null) {
+ throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, ref.getContextSymbol(), "No value was available")); //$NON-NLS-1$
+ }
+ ValueIteratorSource dvs = (ValueIteratorSource) this.variableContext.getGlobalValue(ref.getContextSymbol());
+ return dvs.getValueIterator(ref.getValueExpression());
+ }
+
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -228,7 +228,7 @@
}
if (paramValues.size() > 1) {
- this.context.setVariableContext(null);
+ this.context.setVariableContext(new VariableContext());
}
if (supportPreparedBatchUpdate || paramValues.size() == 1) {
@@ -287,7 +287,7 @@
}
//bind variable
- result.setValue(param.getExpression(), value);
+ result.setGlobalValue(param.getContextSymbol(), value);
}
context.setVariableContext(result);
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -99,7 +99,7 @@
instanceNode.setConnectorBindingId(bindingUUID);
// Modify the command to pull the instance column and evaluate the criteria
- Command command = instanceNode.getCommand();
+ Command command = (Command)instanceNode.getCommand().clone();
// Replace all multi-source elements with the source name
DeepPreOrderNavigator.doVisit(command, new MultiSourceElementReplacementVisitor(bindingName));
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -167,7 +167,7 @@
}
@Test public void testProcAsTable3(){
- String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1 in (1,2,3) and param2 in ('a', 'b')"; //$NON-NLS-1$
+ String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1 in (1,2,3) and param2 in ('a', 'b') order by param1, param2"; //$NON-NLS-1$
// Create expected results
List[] expected = new List[] {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -5479,7 +5479,7 @@
// Collect reference, set value
Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
VariableContext vc = new VariableContext();
- vc.setValue(ref.getExpression() , "a "); //$NON-NLS-1$
+ vc.setGlobalValue(ref.getContextSymbol(), "a "); //$NON-NLS-1$
CommandContext context = createCommandContext();
context.setVariableContext(vc);
// Run query
@@ -5521,7 +5521,7 @@
// Collect reference, set value
Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
VariableContext vc = new VariableContext();
- vc.setValue(ref.getExpression() , "a"); //$NON-NLS-1$
+ vc.setGlobalValue(ref.getContextSymbol(), "a"); //$NON-NLS-1$
CommandContext context = createCommandContext();
context.setVariableContext(vc);
@@ -7870,7 +7870,7 @@
Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
VariableContext vc = new VariableContext();
- vc.setValue(ref.getExpression(), "a"); //$NON-NLS-1$
+ vc.setGlobalValue(ref.getContextSymbol(), "a"); //$NON-NLS-1$
CommandContext context = createCommandContext();
context.setVariableContext(vc);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestCriteriaEvaluator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestCriteriaEvaluator.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestCriteriaEvaluator.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -45,7 +45,10 @@
import com.metamatrix.query.sql.lang.SetCriteria;
import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
import com.metamatrix.query.sql.symbol.Constant;
+import com.metamatrix.query.sql.symbol.ContextReference;
import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.util.ValueIterator;
+import com.metamatrix.query.util.CommandContext;
public class TestCriteriaEvaluator extends TestCase {
@@ -91,15 +94,21 @@
assertEquals("Result did not match expected value", expectedMatch, result); //$NON-NLS-1$
}
- private void helpTestCompareSubqueryCriteria(Criteria crit, boolean expectedResult) throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException{
+ private void helpTestCompareSubqueryCriteria(Criteria crit, boolean expectedResult, final Collection values) throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException{
Map elementMap = new HashMap();
ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
elementMap.put(e1, new Integer(0));
List tuple = Arrays.asList(new String[]{"a"}); //$NON-NLS-1$
-
- assertEquals(expectedResult, new Evaluator(elementMap, null, null).evaluate(crit, tuple));
+ CommandContext cc = new CommandContext() {
+ @Override
+ public ValueIterator getValueIterator(ContextReference ref)
+ throws MetaMatrixComponentException {
+ return new CollectionValueIterator(values);
+ }
+ };
+ assertEquals(expectedResult, new Evaluator(elementMap, null, cc).evaluate(crit, tuple));
}
private SubqueryCompareCriteria helpGetCompareSubqueryCriteria(int operator, int predicateQuantifier){
@@ -381,18 +390,12 @@
values.add("a"); //$NON-NLS-1$
values.add("b"); //$NON-NLS-1$
values.add("c"); //$NON-NLS-1$
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
-
- assertTrue( Evaluator.evaluate(crit) );
+ helpTestCompareSubqueryCriteria(crit, true, values);
}
public void testExistsCriteria2() throws Exception {
ExistsCriteria crit = new ExistsCriteria(new Query());
- CollectionValueIterator valueIter = new CollectionValueIterator(Collections.EMPTY_LIST);
- crit.setValueIterator(valueIter);
-
- assertFalse( Evaluator.evaluate(crit) );
+ helpTestCompareSubqueryCriteria(crit, false, Collections.emptyList());
}
/**
@@ -405,10 +408,7 @@
values.add(null);
values.add(null);
values.add(null);
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
-
- assertTrue( Evaluator.evaluate(crit) );
+ helpTestCompareSubqueryCriteria(crit, true, values);
}
/**
@@ -417,9 +417,7 @@
*/
public void testCompareSubqueryCriteriaNoRows() throws Exception {
SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ALL);
- CollectionValueIterator valueIter = new CollectionValueIterator(Collections.EMPTY_LIST);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, true);
+ helpTestCompareSubqueryCriteria(crit, true, Collections.emptyList());
}
/**
@@ -428,9 +426,7 @@
*/
public void testCompareSubqueryCriteriaNoRows2() throws Exception {
SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.SOME);
- CollectionValueIterator valueIter = new CollectionValueIterator(Collections.EMPTY_LIST);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, false);
+ helpTestCompareSubqueryCriteria(crit, false, Collections.emptyList());
}
/**
@@ -439,9 +435,7 @@
*/
public void testCompareSubqueryCriteriaNoRows3() throws Exception {
SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.NO_QUANTIFIER);
- CollectionValueIterator valueIter = new CollectionValueIterator(Collections.EMPTY_LIST);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, false);
+ helpTestCompareSubqueryCriteria(crit, false, Collections.emptyList());
}
public void testCompareSubqueryCriteria2() throws Exception {
@@ -450,9 +444,7 @@
values.add("a"); //$NON-NLS-1$
values.add("b"); //$NON-NLS-1$
values.add("c"); //$NON-NLS-1$
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, false);
+ helpTestCompareSubqueryCriteria(crit, false, values);
}
public void testCompareSubqueryCriteria3() throws Exception {
@@ -461,9 +453,7 @@
values.add("a"); //$NON-NLS-1$
values.add("b"); //$NON-NLS-1$
values.add("c"); //$NON-NLS-1$
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, true);
+ helpTestCompareSubqueryCriteria(crit, true, values);
}
public void testCompareSubqueryCriteria4() throws Exception {
@@ -471,9 +461,7 @@
ArrayList values = new ArrayList();
values.add("b"); //$NON-NLS-1$
values.add("c"); //$NON-NLS-1$
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, false);
+ helpTestCompareSubqueryCriteria(crit, false, values);
}
public void testCompareSubqueryCriteria5() throws Exception {
@@ -482,27 +470,21 @@
values.add("a"); //$NON-NLS-1$
values.add("b"); //$NON-NLS-1$
values.add("c"); //$NON-NLS-1$
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, true);
+ helpTestCompareSubqueryCriteria(crit, true, values);
}
public void testCompareSubqueryCriteria6() throws Exception {
SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.NO_QUANTIFIER);
ArrayList values = new ArrayList();
values.add("a"); //$NON-NLS-1$
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, true);
+ helpTestCompareSubqueryCriteria(crit, true, values);
}
public void testCompareSubqueryCriteria7() throws Exception {
SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.NO_QUANTIFIER);
ArrayList values = new ArrayList();
values.add("b"); //$NON-NLS-1$
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, false);
+ helpTestCompareSubqueryCriteria(crit, false, values);
}
@@ -517,10 +499,8 @@
values.add("a"); //$NON-NLS-1$
values.add("b"); //$NON-NLS-1$
values.add("c"); //$NON-NLS-1$
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
try {
- helpTestCompareSubqueryCriteria(crit, false);
+ helpTestCompareSubqueryCriteria(crit, false, values);
} catch (CriteriaEvaluationException e) {
assertEquals("The subquery of this compare criteria has to be scalar, but returned more than one value: e1 = (<undefined>)", e.getMessage()); //$NON-NLS-1$
}
@@ -530,9 +510,7 @@
SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.NO_QUANTIFIER);
ArrayList values = new ArrayList();
values.add(null);
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, false);
+ helpTestCompareSubqueryCriteria(crit, false, values);
}
public void testCompareSubqueryCriteriaNulls3() throws Exception {
@@ -540,9 +518,7 @@
ArrayList values = new ArrayList();
values.add(null);
values.add(null);
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, false);
+ helpTestCompareSubqueryCriteria(crit, false, values);
}
public void testCompareSubqueryCriteriaNulls4() throws Exception {
@@ -550,9 +526,7 @@
ArrayList values = new ArrayList();
values.add(null);
values.add(null);
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, false);
+ helpTestCompareSubqueryCriteria(crit, false, values);
}
public void testCompareSubqueryCriteriaNulls5() throws Exception {
@@ -561,9 +535,7 @@
values.add(null);
values.add("a"); //$NON-NLS-1$
values.add(null);
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, true);
+ helpTestCompareSubqueryCriteria(crit, true, values);
}
public void testCompareSubqueryCriteriaNulls6() throws Exception {
@@ -572,9 +544,7 @@
values.add("a"); //$NON-NLS-1$
values.add(null);
values.add("a"); //$NON-NLS-1$
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, true);
+ helpTestCompareSubqueryCriteria(crit, true, values);
}
/**
@@ -585,9 +555,7 @@
ArrayList values = new ArrayList();
values.add(null);
values.add(null);
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, false);
+ helpTestCompareSubqueryCriteria(crit, false, values);
}
/**
@@ -598,8 +566,6 @@
ArrayList values = new ArrayList();
values.add(null);
values.add(null);
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- crit.setValueIterator(valueIter);
- helpTestCompareSubqueryCriteria(crit, false);
+ helpTestCompareSubqueryCriteria(crit, false, values);
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -47,6 +47,7 @@
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.CaseExpression;
import com.metamatrix.query.sql.symbol.Constant;
+import com.metamatrix.query.sql.symbol.ContextReference;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.Function;
@@ -55,6 +56,7 @@
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.symbol.TestCaseExpression;
import com.metamatrix.query.sql.symbol.TestSearchedCaseExpression;
+import com.metamatrix.query.sql.util.ValueIterator;
import com.metamatrix.query.sql.visitor.EvaluateExpressionVisitor;
import com.metamatrix.query.util.CommandContext;
@@ -264,28 +266,35 @@
ScalarSubquery expr = new ScalarSubquery(new Query());
ArrayList values = new ArrayList(1);
values.add("a"); //$NON-NLS-1$
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- expr.setValueIterator(valueIter);
-
- assertEquals("a", Evaluator.evaluate(expr) ); //$NON-NLS-1$
+ Object expected = "a"; //$NON-NLS-1$
+ helpTestWithValueIterator(expr, values, expected);
}
+ private void helpTestWithValueIterator(ScalarSubquery expr,
+ List<?> values, Object expected)
+ throws BlockedException,
+ MetaMatrixComponentException, ExpressionEvaluationException {
+ final CollectionValueIterator valueIter = new CollectionValueIterator(values);
+ CommandContext cc = new CommandContext() {
+ @Override
+ public ValueIterator getValueIterator(ContextReference ref)
+ throws MetaMatrixComponentException {
+ return valueIter;
+ }
+ };
+ assertEquals(expected, new Evaluator(Collections.emptyMap(), null, cc).evaluate(expr, null) );
+ }
+
public void testScalarSubquery2() throws Exception{
ScalarSubquery expr = new ScalarSubquery(new Query());
ArrayList values = new ArrayList(1);
values.add(null);
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- expr.setValueIterator(valueIter);
-
- assertEquals(null, Evaluator.evaluate(expr) );
+ helpTestWithValueIterator(expr, values, null);
}
public void testScalarSubquery3() throws Exception{
ScalarSubquery expr = new ScalarSubquery(new Query());
- CollectionValueIterator valueIter = new CollectionValueIterator(Collections.EMPTY_LIST);
- expr.setValueIterator(valueIter);
-
- assertEquals(null, Evaluator.evaluate(expr) );
+ helpTestWithValueIterator(expr, Collections.emptyList(), null);
}
public void testScalarSubqueryFails() throws Exception{
@@ -293,11 +302,9 @@
ArrayList values = new ArrayList(2);
values.add("a"); //$NON-NLS-1$
values.add("b"); //$NON-NLS-1$
- CollectionValueIterator valueIter = new CollectionValueIterator(values);
- expr.setValueIterator(valueIter);
try {
- Evaluator.evaluate(expr);
+ helpTestWithValueIterator(expr, values, null);
fail("Expected ExpressionEvaluationException but got none"); //$NON-NLS-1$
} catch (ExpressionEvaluationException e) {
assertEquals("Unable to evaluate (<undefined>): The command of this scalar subquery returned more than one value: <undefined>", e.getMessage()); //$NON-NLS-1$
Added: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentCriteriaProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentCriteriaProcessor.java (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentCriteriaProcessor.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.query.processor.relational;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+import com.metamatrix.query.processor.relational.DependentAccessNode;
+import com.metamatrix.query.processor.relational.DependentCriteriaProcessor;
+import com.metamatrix.query.sql.lang.CompareCriteria;
+import com.metamatrix.query.sql.lang.Criteria;
+import com.metamatrix.query.sql.lang.SetCriteria;
+import com.metamatrix.query.sql.symbol.Constant;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.Reference;
+import com.metamatrix.query.util.CommandContext;
+
+public class TestDependentCriteriaProcessor {
+
+ @Test public void testNegatedSetCriteria() throws Exception {
+ DependentAccessNode dan = new DependentAccessNode(0);
+ SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), Arrays.asList(new Constant(1), new Constant(2))); //$NON-NLS-1$
+ DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, dan, sc);
+ Criteria result = dcp.prepareCriteria();
+ assertEquals(new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(1)), result); //$NON-NLS-1$
+ assertTrue(dcp.hasNextCommand());
+ }
+
+ @Test public void testEvaluatedSetCriteria() throws Exception {
+ DependentAccessNode dan = new DependentAccessNode(0);
+ CommandContext cc = new CommandContext();
+ dan.setContext(cc);
+ List<Reference> references = Arrays.asList(new Reference(1), new Reference(2));
+ for (Reference reference : references) {
+ cc.getVariableContext().setGlobalValue(reference.getContextSymbol(), 1);
+ }
+ SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), references); //$NON-NLS-1$
+ DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, dan, sc);
+ Criteria result = dcp.prepareCriteria();
+ assertEquals(new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(1)), result); //$NON-NLS-1$
+ assertFalse(dcp.hasNextCommand());
+ }
+
+}
Property changes on: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentCriteriaProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentSelectNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentSelectNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentSelectNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,16 +22,35 @@
package com.metamatrix.query.processor.relational;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
-import junit.framework.*;
+import junit.framework.TestCase;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.*;
-import com.metamatrix.query.processor.*;
-import com.metamatrix.query.sql.lang.*;
-import com.metamatrix.query.sql.symbol.*;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.common.buffer.TupleSource;
+import com.metamatrix.query.processor.ProcessorDataManager;
+import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.CompoundCriteria;
+import com.metamatrix.query.sql.lang.Criteria;
+import com.metamatrix.query.sql.lang.ExistsCriteria;
+import com.metamatrix.query.sql.lang.From;
+import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.lang.Select;
+import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
+import com.metamatrix.query.sql.lang.SubquerySetCriteria;
+import com.metamatrix.query.sql.symbol.Constant;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.util.CommandContext;
/**
@@ -128,10 +147,7 @@
Command subCommand2 = helpMakeCommand2();
subCommand2.setProcessorPlan(new DoNothingProcessorPlan());
Criteria subCrit2 = new SubquerySetCriteria(new ElementSymbol("f"), subCommand2); //$NON-NLS-1$
- List crits = new ArrayList(2);
- crits.add(subCrit);
- crits.add(subCrit2);
- DependentSelectNode node = new DependentSelectNode(id, null);
+ DependentSelectNode node = new DependentSelectNode(id, new SubqueryProcessorUtility(Arrays.asList(new DoNothingProcessorPlan(), new DoNothingProcessorPlan()), null, null));
//Set up criteria
CompoundCriteria crit = new CompoundCriteria();
crit.addCriteria(subCrit);
@@ -144,25 +160,16 @@
//Test clone
DependentSelectNode cloned = (DependentSelectNode)node.clone();
- List<ProcessorPlan> originalProcessorPlans = node.getSubqueryProcessorUtility().getSubqueryPlans();
+ List<? extends ProcessorPlan> originalProcessorPlans = node.getSubqueryProcessorUtility().getSubqueryPlans();
List clonedProcessorPlans = cloned.getSubqueryProcessorUtility().getSubqueryPlans();
- List clonedCrits = cloned.getSubqueryProcessorUtility().getValueIteratorProviders();
- List checkClonedCrits = new ArrayList(clonedCrits.size());
- ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(cloned.getCriteria(), checkClonedCrits);
assertTrue(clonedProcessorPlans.size() == 2);
assertEquals(originalProcessorPlans.size(), clonedProcessorPlans.size());
- assertEquals(clonedCrits.size(), checkClonedCrits.size());
- assertEquals(clonedCrits.size(), clonedProcessorPlans.size());
for (int i=0; i<originalProcessorPlans.size(); i++){
//Check ProcessorPlans
ProcessorPlan originalPlan = originalProcessorPlans.get(i);
DoNothingProcessorPlan clonedPlan = (DoNothingProcessorPlan)clonedProcessorPlans.get(i);
assertNotNull(clonedPlan.original);
- assertSame(((DoNothingProcessorPlan)originalPlan).original, clonedPlan.original);
-
- //Check SubquerySetCriteria
- assertNotNull(clonedCrits.get(i));
- assertSame(clonedCrits.get(i), checkClonedCrits.get(i));
+ assertSame(originalPlan, clonedPlan.original);
}
}
@@ -185,7 +192,7 @@
crits.add(subCrit);
crits.add(subCrit2);
- DependentSelectNode node = new DependentSelectNode(id, null);
+ DependentSelectNode node = new DependentSelectNode(id, new SubqueryProcessorUtility(Arrays.asList(new DoNothingProcessorPlan(), new DoNothingProcessorPlan()), null, null));
//Set up criteria
CompoundCriteria crit = new CompoundCriteria();
@@ -201,23 +208,14 @@
List originalProcessorPlans = node.getSubqueryProcessorUtility().getSubqueryPlans();
List clonedProcessorPlans = cloned.getSubqueryProcessorUtility().getSubqueryPlans();
- List clonedCrits = cloned.getSubqueryProcessorUtility().getValueIteratorProviders();
- List checkClonedCrits = new ArrayList(clonedCrits.size());
- ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(cloned.getCriteria(), checkClonedCrits);
assertTrue(clonedProcessorPlans.size() == 2);
assertEquals(originalProcessorPlans.size(), clonedProcessorPlans.size());
- assertEquals(clonedCrits.size(), checkClonedCrits.size());
- assertEquals(clonedCrits.size(), clonedProcessorPlans.size());
for (int i=0; i<originalProcessorPlans.size(); i++){
//Check ProcessorPlans
Object originalPlan = originalProcessorPlans.get(i);
DoNothingProcessorPlan clonedPlan = (DoNothingProcessorPlan)clonedProcessorPlans.get(i);
assertNotNull(clonedPlan.original);
- assertSame(((DoNothingProcessorPlan)originalPlan).original, clonedPlan.original);
-
- //Check SubquerySetCriteria
- assertNotNull(clonedCrits.get(i));
- assertSame(clonedCrits.get(i), checkClonedCrits.get(i));
+ assertSame(originalPlan, clonedPlan.original);
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -85,7 +85,7 @@
for (int i = 0; i < expected.length; i++) {
while (true) {
try {
- assertEquals("Rows don't match at " + i, expected[i], iterator.next()); //$NON-NLS-1$
+ assertEquals("Rows don't match at " + i, expected[i], iterator.nextTuple()); //$NON-NLS-1$
break;
} catch (BlockedException e) {
continue;
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestDependentSetCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestDependentSetCriteria.java 2009-04-20 14:15:14 UTC (rev 800)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestDependentSetCriteria.java 2009-04-20 14:57:25 UTC (rev 801)
@@ -22,17 +22,10 @@
package com.metamatrix.query.sql.lang;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
import junit.framework.TestCase;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.sql.util.ValueIteratorSource;
/**
@@ -53,72 +46,30 @@
super(name);
}
- private DependentSetCriteria example(Object[] vals) {
+ private DependentSetCriteria example() {
ElementSymbol e1 = new ElementSymbol("pm1.g1.e1"); //$NON-NLS-1$
- DependentSetCriteria dsc = new DependentSetCriteria(e1);
+ DependentSetCriteria dsc = new DependentSetCriteria(e1, ""); //$NON-NLS-1$
final ElementSymbol e2 = new ElementSymbol("pm2.g1.e2"); //$NON-NLS-1$
dsc.setValueExpression(e2);
- FakeValueIteratorSource vis = new FakeValueIteratorSource();
- vis.addData(e2, vals);
- vis.ready();
- dsc.setValueIteratorSource(vis);
-
return dsc;
}
- public void testGetValueIterator() throws Exception {
- Object[] vals = new Object[] { "a", "b", "c"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- DependentSetCriteria dsc = example(vals);
- ValueIterator iter = dsc.getValueIterator();
- for(int i=0; iter.hasNext(); i++) {
- assertEquals(vals[i], iter.next());
- }
- assertEquals(false, iter.hasNext());
- }
-
public void testEquivalence() {
- Object[] vals = new Object[] { "a", "b", "c"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- DependentSetCriteria dsc = example(vals);
+ DependentSetCriteria dsc = example();
UnitTestUtil.helpTestEquivalence(0, dsc, dsc);
UnitTestUtil.helpTestEquivalence(0, dsc, dsc.clone());
}
public void testEquivalence1() {
- Object[] vals = new Object[] { "a", "b", "c"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- DependentSetCriteria dsc = example(vals);
- DependentSetCriteria dsc1 = example(vals);
+ DependentSetCriteria dsc = example();
+ DependentSetCriteria dsc1 = example();
dsc1.setValueExpression(new ElementSymbol("foo")); //$NON-NLS-1$
assertNotSame(dsc, dsc1);
}
- static class FakeValueIteratorSource implements ValueIteratorSource {
-
- private Map data = new HashMap();
- private boolean ready = false;
-
-
- public void addData(Expression valueExpression, Object[] values) {
- data.put(valueExpression, values);
- }
-
- public void ready() {
- this.ready = true;
- }
-
- public ValueIterator getValueIterator(Expression valueExpression) {
- Object[] vals = (Object[])data.get(valueExpression);
- return new CollectionValueIterator(Arrays.asList(vals));
- }
-
- public boolean isReady() {
- return ready;
- }
-
- }
-
}
15 years, 8 months
teiid SVN: r800 - trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-20 10:15:14 -0400 (Mon, 20 Apr 2009)
New Revision: 800
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
Log:
TEIID-379 fixing ansi mode set.
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java 2009-04-20 14:09:47 UTC (rev 799)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java 2009-04-20 14:15:14 UTC (rev 800)
@@ -81,7 +81,7 @@
Statement stmt = null;
try {
stmt = connection.createStatement();
- stmt.execute("set SESSION sql-mode = 'ANSI'"); //$NON-NLS-1$
+ stmt.execute("set SESSION sql_mode = 'ANSI'"); //$NON-NLS-1$
} catch (SQLException e) {
getEnvironment().getLogger().logError("Error setting ANSI mode", e); //$NON-NLS-1$
} finally {
15 years, 8 months
teiid SVN: r799 - trunk/metadata/src/main/java/com/metamatrix/modeler/internal/core/index.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-20 10:09:47 -0400 (Mon, 20 Apr 2009)
New Revision: 799
Modified:
trunk/metadata/src/main/java/com/metamatrix/modeler/internal/core/index/RuntimeIndexSelector.java
Log:
TEIID-427 changing the isDirectory check to be on the zip entry
Modified: trunk/metadata/src/main/java/com/metamatrix/modeler/internal/core/index/RuntimeIndexSelector.java
===================================================================
--- trunk/metadata/src/main/java/com/metamatrix/modeler/internal/core/index/RuntimeIndexSelector.java 2009-04-19 16:32:45 UTC (rev 798)
+++ trunk/metadata/src/main/java/com/metamatrix/modeler/internal/core/index/RuntimeIndexSelector.java 2009-04-20 14:09:47 UTC (rev 799)
@@ -337,7 +337,7 @@
// create a file at the temporary location writing
// the contents of the zip entry to this file
File entryFile = new File(getIndexDirectoryPath(), entry.getName());
- if (entryFile.isDirectory()) {
+ if (entry.isDirectory()) {
entryFile.mkdirs();
} else {
FileUtils.write(zipInputStream, entryFile, length);
15 years, 8 months
teiid SVN: r798 - trunk/server.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-19 12:32:45 -0400 (Sun, 19 Apr 2009)
New Revision: 798
Modified:
trunk/server/pom.xml
Log:
TEIID-506 removing the jgroups dependency from common internal
Modified: trunk/server/pom.xml
===================================================================
--- trunk/server/pom.xml 2009-04-19 16:32:13 UTC (rev 797)
+++ trunk/server/pom.xml 2009-04-19 16:32:45 UTC (rev 798)
@@ -89,5 +89,9 @@
<groupId>com.google.code.guice</groupId>
<artifactId>guice</artifactId>
</dependency>
+ <dependency>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
15 years, 8 months
teiid SVN: r797 - trunk/common-internal.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-19 12:32:13 -0400 (Sun, 19 Apr 2009)
New Revision: 797
Modified:
trunk/common-internal/pom.xml
Log:
TEIID-506 removing the jgroups dependency from common internal
Modified: trunk/common-internal/pom.xml
===================================================================
--- trunk/common-internal/pom.xml 2009-04-18 20:24:38 UTC (rev 796)
+++ trunk/common-internal/pom.xml 2009-04-19 16:32:13 UTC (rev 797)
@@ -33,13 +33,8 @@
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
</dependency>
-
+
<dependency>
- <groupId>jgroups</groupId>
- <artifactId>jgroups</artifactId>
- </dependency>
-
- <dependency>
<groupId>beanshell</groupId>
<artifactId>bsh</artifactId>
</dependency>
15 years, 8 months
teiid SVN: r796 - trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-04-18 16:24:38 -0400 (Sat, 18 Apr 2009)
New Revision: 796
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java
Log:
TEIID-505
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java 2009-04-17 21:23:08 UTC (rev 795)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java 2009-04-18 20:24:38 UTC (rev 796)
@@ -289,9 +289,6 @@
}
});
} else {
- if (url != null && url.trim().length() > 0) {
- connectionProps.setProperty(JDBCPropertyNames.URL, url);
- }
if (temp instanceof DataSource) {
this.ds = (DataSource)temp;
PropertiesUtils.setBeanProperties(this.ds, connectionProps, null);
15 years, 8 months
teiid SVN: r795 - in trunk/connectors/connector-jdbc/src: test/java/org/teiid/connector/jdbc and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-04-17 17:23:08 -0400 (Fri, 17 Apr 2009)
New Revision: 795
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCConnector.java
Log:
TEIID-505
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java 2009-04-17 19:59:03 UTC (rev 794)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java 2009-04-17 21:23:08 UTC (rev 795)
@@ -254,13 +254,13 @@
}
final String url = connectionProps.getProperty(JDBCPropertyNames.URL);
- if (url == null || url.trim().length() == 0) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Missing_JDBC_database_name_3")); //$NON-NLS-1$
- }
-
- if (temp instanceof Driver) {
+
+ if (temp instanceof Driver) {
final Driver driver = (Driver)temp;
// check URL if there is one
+ if (url == null || url.trim().length() == 0) {
+ throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Missing_JDBC_database_name_3")); //$NON-NLS-1$
+ }
validateURL(driver, url);
this.ds = (DataSource)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {DataSource.class}, new InvocationHandler() {
@Override
@@ -289,7 +289,9 @@
}
});
} else {
- parseURL(url, connectionProps);
+ if (url != null && url.trim().length() > 0) {
+ connectionProps.setProperty(JDBCPropertyNames.URL, url);
+ }
if (temp instanceof DataSource) {
this.ds = (DataSource)temp;
PropertiesUtils.setBeanProperties(this.ds, connectionProps, null);
@@ -325,57 +327,6 @@
}
}
- /**
- * Parse URL for DataSource connection properties and add to connectionProps.
- * @param url
- * @param connectionProps
- * @throws ConnectorException
- */
- static void parseURL(final String url, final Properties connectionProps) throws ConnectorException {
- // Will be: [jdbc:mmx:dbType://aHost:aPort], [DatabaseName=aDataBase], [CollectionID=aCollectionID], ...
- final String[] urlParts = url.split(";"); //$NON-NLS-1$
-
- // Will be: [jdbc:mmx:dbType:], [aHost:aPort]
- final String[] protoHost = urlParts[0].split("//"); //$NON-NLS-1$
-
- // Will be: [aHost], [aPort]
- final String[] hostPort = protoHost[1].split(":"); //$NON-NLS-1$
- connectionProps.setProperty(XAJDBCPropertyNames.SERVER_NAME, hostPort[0]);
- connectionProps.setProperty(XAJDBCPropertyNames.PORT_NUMBER, hostPort[1]);
-
- // For "databaseName", "SID", and all optional props
- // (<propName1>=<propValue1>;<propName2>=<propValue2>;...)
- for ( int i = 1; i < urlParts.length; i++ ) {
- final String nameVal = urlParts[i];
- // Will be: [propName], [propVal]
- final String[] aProp = nameVal.split("="); //$NON-NLS-1$
- if ( aProp.length > 1) {
- // Set optional prop names lower case so that we can find
- // set method names for them when we introspect the DataSource
- connectionProps.setProperty(aProp[0].toLowerCase(), aProp[1]);
- }
- }
-
- String serverName = connectionProps.getProperty(XAJDBCPropertyNames.SERVER_NAME);
- String serverPort = connectionProps.getProperty(XAJDBCPropertyNames.PORT_NUMBER);
- if ( serverName == null || serverName.trim().length() == 0 ) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.MissingProp", //$NON-NLS-1$
- XAJDBCPropertyNames.SERVER_NAME));
- }
- if ( serverPort == null || serverPort.trim().length() == 0 ) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.MissingProp", //$NON-NLS-1$
- XAJDBCPropertyNames.PORT_NUMBER));
- }
-
- // Unique resource name for this connector
- final StringBuffer dataSourceResourceName = new StringBuffer(connectionProps.getProperty(XAJDBCPropertyNames.DATASOURCE_NAME, "XADS")); //$NON-NLS-1$
- dataSourceResourceName.append('_');
- dataSourceResourceName.append(serverName);
- dataSourceResourceName.append('_');
- dataSourceResourceName.append(connectionProps.getProperty(ConnectorPropertyNames.CONNECTOR_ID));
- connectionProps.setProperty( XAJDBCPropertyNames.DATASOURCE_NAME, dataSourceResourceName.toString());
- }
-
public int getDefaultTransactionIsolationLevel() {
return this.transIsoLevel;
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCConnector.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCConnector.java 2009-04-17 19:59:03 UTC (rev 794)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCConnector.java 2009-04-17 21:23:08 UTC (rev 795)
@@ -60,18 +60,4 @@
public void test3() throws Exception {
helpTestMaxIn(1, 1);
}
-
- @Test
- public void testParseUrl() throws ConnectorException {
- String urlWithEmptyProp = "jdbc:mmx:db2://aHost:aPort;DatabaseName=DB2_DataBase;CollectionID=aCollectionID;PackageName=aPackageName;BogusProp=aBogusProp;UnEmptyProp=;"; //$NON-NLS-1$
- Properties props = new Properties();
- JDBCConnector.parseURL(urlWithEmptyProp, props);
-
- assertEquals("aPort", props.getProperty(XAJDBCPropertyNames.PORT_NUMBER)); //$NON-NLS-1$
- assertEquals("aHost", props.getProperty(XAJDBCPropertyNames.SERVER_NAME)); //$NON-NLS-1$
- assertEquals("XADS_aHost_null", props.getProperty(XAJDBCPropertyNames.DATASOURCE_NAME)); //$NON-NLS-1$
- assertEquals("aBogusProp", props.getProperty("bogusprop")); //$NON-NLS-1$ //$NON-NLS-2$
- assertNull(props.getProperty("unemptyprop")); //$NON-NLS-1$
- }
-
}
15 years, 8 months
teiid SVN: r794 - in trunk/client/src/main/java: org and 6 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-17 15:59:03 -0400 (Fri, 17 Apr 2009)
New Revision: 794
Added:
trunk/client/src/main/java/org/teiid/
trunk/client/src/main/java/org/teiid/netty/
trunk/client/src/main/java/org/teiid/netty/handler/
trunk/client/src/main/java/org/teiid/netty/handler/codec/
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/
Removed:
trunk/client/src/main/java/org/jboss/netty/handler/codec/serialization/
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectInputStream.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java
Log:
TEIID-292 repackaging the client classes to avoid conflict if a netty jar is present
Modified: trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java 2009-04-17 16:16:06 UTC (rev 793)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java 2009-04-17 19:59:03 UTC (rev 794)
@@ -37,8 +37,8 @@
import java.util.concurrent.Future;
import java.util.logging.Logger;
-import org.jboss.netty.handler.codec.serialization.ObjectDecoderInputStream;
-import org.jboss.netty.handler.codec.serialization.ObjectEncoderOutputStream;
+import org.teiid.netty.handler.codec.serialization.ObjectDecoderInputStream;
+import org.teiid.netty.handler.codec.serialization.ObjectEncoderOutputStream;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.platform.socket.ObjectChannel;
Copied: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization (from rev 790, trunk/client/src/main/java/org/jboss/netty/handler/codec/serialization)
Property changes on: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectInputStream.java
===================================================================
--- trunk/client/src/main/java/org/jboss/netty/handler/codec/serialization/CompactObjectInputStream.java 2009-04-16 22:53:44 UTC (rev 790)
+++ trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectInputStream.java 2009-04-17 19:59:03 UTC (rev 794)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.netty.handler.codec.serialization;
+package org.teiid.netty.handler.codec.serialization;
import java.io.EOFException;
import java.io.IOException;
Modified: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java
===================================================================
--- trunk/client/src/main/java/org/jboss/netty/handler/codec/serialization/CompactObjectOutputStream.java 2009-04-16 22:53:44 UTC (rev 790)
+++ trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java 2009-04-17 19:59:03 UTC (rev 794)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.netty.handler.codec.serialization;
+package org.teiid.netty.handler.codec.serialization;
import java.io.IOException;
import java.io.ObjectOutputStream;
Modified: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java
===================================================================
--- trunk/client/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoderInputStream.java 2009-04-16 22:53:44 UTC (rev 790)
+++ trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java 2009-04-17 19:59:03 UTC (rev 794)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.netty.handler.codec.serialization;
+package org.teiid.netty.handler.codec.serialization;
import java.io.DataInputStream;
import java.io.IOException;
Modified: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java
===================================================================
--- trunk/client/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectEncoderOutputStream.java 2009-04-16 22:53:44 UTC (rev 790)
+++ trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java 2009-04-17 19:59:03 UTC (rev 794)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.netty.handler.codec.serialization;
+package org.teiid.netty.handler.codec.serialization;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
15 years, 8 months
teiid SVN: r793 - trunk/common-internal/src/main/java/com/metamatrix/common/config.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-17 12:16:06 -0400 (Fri, 17 Apr 2009)
New Revision: 793
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java
Log:
Teiid - 323 - part of the refacturing of configuration cleanup
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java 2009-04-17 16:15:40 UTC (rev 792)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java 2009-04-17 16:16:06 UTC (rev 793)
@@ -31,6 +31,7 @@
import java.util.Properties;
import com.metamatrix.common.CommonPlugin;
+import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.config.api.ComponentTypeID;
import com.metamatrix.common.config.api.Configuration;
import com.metamatrix.common.config.api.ConfigurationID;
@@ -288,25 +289,12 @@
* @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
* @see com.metamatrix.common.api.ComponentType
*/
- public Collection getComponentTypes(boolean includeDeprecated) throws ConfigurationException {
+ public Collection<ComponentType> getComponentTypes(boolean includeDeprecated) throws ConfigurationException {
return getReader().getConfigurationModel().getComponentTypes().values();
}
+
/**
- * Returns a <code>Collection</code> of type <code>ProductType</code> that represents
- * all the ComponentTypes defined.
- * @return List of type <code>ProductType</code>
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- * @see #ProductType
- */
- public Collection getProductTypes() throws ConfigurationException {
- Collection c = new ArrayList(1);
- return c;
-// c.add(BasicProductType.PRODUCT_TYPE);
-// return c;
- }
-
- /**
* Returns the Host based on the current running machine.
* @return the full Host object
* @throws ConfigurationException if an error occurred within or during
15 years, 8 months