public void Run(object obj)
        {
            LuaInstance lua = null;

            try
            {
                lua = LuaCache.GetInstance();

                // Start thread queries to each node.
                StartThreads();

                lua.LoadPackage(statement);

                object[] args = new object[4 + statement.functionArgs.Length];
                args[0] = lua.GetFunction(statement.functionName);
                args[1] = 2;
                args[2] = new LuaInputStream(inputQueue, cancel.Token);
                args[3] = new LuaOutputStream(resultSet);
                int count = 4;

                foreach (Value value in statement.functionArgs)
                {
                    args[count++] = value.Object;
                }
                lua.Call("apply_stream", args);
            }
            catch (LuaRuntimeException lre)
            {
                // Try to get that elusive lua stack trace.
                HandleException(new Exception(lre.Message + lre.StackTrace));
            }
            catch (Exception e)
            {
                if (e.InnerException is LuaRuntimeException)
                {
                    // Try to get that elusive lua stack trace.
                    LuaRuntimeException lre = e.InnerException as LuaRuntimeException;
                    HandleException(new Exception(lre.Message + lre.StackTrace));
                }
                else
                {
                    HandleException(e);
                }
            }
            finally
            {
                // Send end command to user's result set.
                // If query was already cancelled, this put will be ignored.
                resultSet.Put(ResultSet.END);

                if (lua != null)
                {
                    LuaCache.PutInstance(lua);
                }
            }
        }
        public override DynamicMetaObject FallbackBinaryOperation(
            DynamicMetaObject target,
            DynamicMetaObject arg,
            DynamicMetaObject errorSuggestion)
        {
            // Defer if any object has no value so that we evaulate their
            // Expressions and nest a CallSite for the InvokeMember.
            if (!target.HasValue || !arg.HasValue)
                return Defer(target, arg);

            DynamicMetaObject targetFirst, argFirst;
            if (RuntimeHelpers.TryGetFirstVarargs(target, out targetFirst) &&
                RuntimeHelpers.TryGetFirstVarargs(arg, out argFirst))
                return FallbackBinaryOperation(targetFirst, argFirst, errorSuggestion);

            Expr expression = null;
            switch (BinaryExprTypes[Operation])
            {
                case BinaryOpType.Relational:
                    {
                        var returnType = this.ReturnType;
                        var left = target;
                        var right = arg;
                        DynamicMetaObject mo = null;
                        try
                        {
                            mo = context.Binder.DoOperation(Operation, left, right);
                        }
                        catch
                        {

                        }

                        if(mo == null || mo.Expression.Type == typeof(void))
                        {
                            var ex = new LuaRuntimeException(context, "attempt to compare {0} with {1}",
                                IronLua.Library.BaseLibrary.TypeName(left.LimitType),
                                IronLua.Library.BaseLibrary.TypeName(right.LimitType));
                            mo =  new DynamicMetaObject(Expr.Throw(Expr.Constant(ex), typeof(LuaRuntimeException)), BindingRestrictions.Empty, ex);
                        }
                        else if (mo.Expression.Type != returnType)
                        {
                            mo = mo.Clone(Expr.Convert(mo.Expression, returnType));
                        }

                        return mo;
                    }
                    //expression = Relational(target, arg);
                    //break;
                case BinaryOpType.Logical:
                    expression = Logical(target, arg);
                    break;
                case BinaryOpType.Numeric:
                    expression = Numeric(target, arg);
                    break;
            }

            if (expression == null)
                expression = MetamethodFallbacks.BinaryOp(context, Operation, target, arg);

            return new DynamicMetaObject(Expr.Convert(expression, typeof(object)),
                RuntimeHelpers.MergeTypeRestrictions(target, arg));
        }