Пример #1
0
        public HqlLine ReadLine()
        {
            HqlDataSource src = _sources[0];
            HqlLine       l   = src.ReadLine();

            return(l);
        }
Пример #2
0
        private bool GetLineStreamable()
        {
            for (; ;)
            {
                if (_from.EndOfStream)
                {
                    _line = String.Empty;
                    return(false);
                }

                HqlLine line = _from.ReadLine();
                if (line.IsBlank && _from.EndOfStream)
                {
                    continue;
                }

                if (_where.Evaluate(line))
                {
                    // now i found a record that matches
                    _line = _select.Evaluate(line);
                    if (_settings.PrintCategorizeFilename)
                    {
                        _outfilename = _settings.Output.Evaluate(line);
                    }
                    return(true);
                }
            }
        }
Пример #3
0
        ///////////////////////
        // Overridden functions

        ///////////////////////
        // Public

        public HqlLine ReadLine()
        {
            string s = ReadLine_Internal();

            for (; SkipRecords > 0;)
            {
                SkipRecords = SkipRecords - 1;
                s           = ReadLine_Internal();
            }
            HqlLine l = new HqlLine(s, Delimiter, RowNum, Name);

            return(l);
        }
Пример #4
0
        private void CalculateData()
        {
            for (; ; _linenum++)
            {
                if (_from.EndOfStream)
                {
                    break;
                }

                //string fromline = _from.ReadLine();
                //if (fromline.Equals(String.Empty) && _from.EndOfStream)
                //    continue;

                // get the current line of data
                //HqlLine line = new HqlLine(fromline, _settings, _from.RowNum);
                HqlLine line = _from.ReadLine();
                if (line.IsBlank && _from.EndOfStream)
                {
                    continue;
                }
                try
                {
                    // does this match the where statement?
                    if (_where.Evaluate(line))
                    {
                        // Process:
                        // Determine key
                        // - Figure out if this key exists
                        // - If it does, pull back the VALUE, which has the static info and the calcs
                        // - The calcs must be kept in a Field Format though
                        // - if written sum(substr(value)) then run through scalar first
                        // - if written len(sum(value)) then run through scalar on GetValue coming out
                        //

                        CreateKeyAndValue(line);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(String.Format("Caught except processing row num|{0}|{1}|", _from.RowNum, line.Line), ex);
                }
            }
        }
Пример #5
0
        //public HqlValues MergeValues(HqlValues priorvalues, HqlValues thisvalues, ref HqlFieldGroup combinedFields)
        //{
        //    if (combinedFields == null)
        //        combinedFields = new HqlFieldGroup(priorvalues.FieldsImpacted, thisvalues.FieldsImpacted);
        //    return new HqlValues(combinedFields, priorvalues, thisvalues);
        //}

        public bool ReadThroughUsingJoin(HqlDataSource prior, HqlWhere onJoin, HqlWhere where, bool selectRecord)
        {
            // TODO
            // - need to sort the prior how I'm going to join these.
            // - read through current and join them and save to new object
            // - clear all the saved data from the prior object
            //HqlFieldGroup combinedFieldsImpacted = null;
            //HqlValuesComparer comparer = prior.comparer;

            // TODO, sort the prior
            //bool sortedPrior = false;

            for (; ;)
            {
                if (selectRecord && Lines.Count > 0)
                {
                    _resultValues = Lines[0];
                    Lines.RemoveAt(0);

                    if (where.Evaluate(_resultValues))
                    {
                        return(true);
                    }
                    continue;
                }

                if (EndOfStream)
                {
                    if (!_completedJoin)
                    {
                        _completedJoin = true;

                        if (prior != null && (prior.JoinType == HqlKeyword.LEFT_OUTER || prior.JoinType == HqlKeyword.FULL_OUTER))
                        {
                            prior.Comparer.JoinMethod = HqlJoinMethod.RETURN_ALL;
                            prior.Comparer.Reset();
                            prior.comparer.SetValues(BlankValues);

                            for (; prior.Comparer.MoveNext();)
                            {
                                prior.Comparer.Current.IncreaseUsedCount();
                                HqlValues combinedvalues = prior.Comparer.CombinedValues;
                                SaveRowValue(combinedvalues);
                            }

                            continue;
                        }
                    }

                    _resultValues = null;
                    return(false);
                }

                //string fromline = ReadLine();
                //if (fromline.Equals(String.Empty) && EndOfStream)
                //    continue;
                //HqlLine line = new HqlLine(fromline, settings, RowNum)
                HqlLine line = ReadLine();
                if (line.IsBlank && EndOfStream)
                {
                    continue;
                }

#if DEBUG
                if (line.Line.StartsWith("1503|706"))
                {
                    int stop = 0;
                }
#endif

                // get the current line of data
                HqlValues thisvalues = new HqlValues(FieldsImpacted, line);

                // does this match the where statement?
                if (JoinType == HqlKeyword.LEFT_OUTER || JoinType == HqlKeyword.FULL_OUTER)
                {
                    // pass through, don't evaluate the ON command because I want this regardless
                }
                else if (prior != null && (prior.JoinType == HqlKeyword.FULL_OUTER || prior.JoinType == HqlKeyword.RIGHT_OUTER))
                {
                    // pass through
                }
                else if (!onJoin.EvaluateJoin(thisvalues, true)) // || !where.EvaluateJoin(thisvalues))
                {
                    // didn't pass through, so continue
                    continue;
                }

                // This is here for the first "join"
                // I need to save all the records.
                if (prior == null)
                {
                    SaveRowValue(thisvalues);
                    continue;
                }

                // now time to join the data!
                bool savedThisRecord = false;

                // do preprocessing if this is to be searched through sorting
                if (prior.Comparer == null)
                {
                    if (prior.Lines.Count == 0)
                    {
                        throw new Exception("Data integrity issue. Didn't find anything to join with on prior! TODO, this can be valid, need to fix!!");
                    }

                    HqlValues priorvalues = prior.Lines[0];                       // guaranteed to be there
                    prior.Comparer = new HqlValuesComparer(prior, onJoin, where); //, settings);
                    prior.Comparer.CombinedFieldsImpacted = new HqlFieldGroup(priorvalues.FieldsImpacted, thisvalues.FieldsImpacted);

                    if (prior.Comparer.CountOfJoinFields == 0)
                    {
                        prior.Comparer.JoinMethod = HqlJoinMethod.LINEAR_COMPARE;
                    }

                    Console.Error.WriteLine(String.Format("Using joining of {0} between ({1}) {2} and ({3}) {4}",
                                                          prior.Comparer.JoinMethod.ToString(),
                                                          prior.TableReference,
                                                          prior.SourceName,
                                                          this.TableReference,
                                                          this.SourceName)
                                            );

                    if (prior.Comparer.JoinMethod == HqlJoinMethod.SORT_COMPARE)
                    {
                        prior.Comparer.SortPrior();
                    }
                }

                prior.Comparer.SetValues(thisvalues);
                prior.Comparer.Reset();

                for (; prior.Comparer.MoveNext();)
                {
                    prior.Comparer.Current.IncreaseUsedCount();

                    HqlValues combinedvalues = prior.Comparer.CombinedValues;

                    SaveRowValue(combinedvalues);
                    savedThisRecord = true;
                }

                if (!savedThisRecord && (prior.JoinType == HqlKeyword.RIGHT_OUTER || prior.JoinType == HqlKeyword.FULL_OUTER))
                {
                    HqlValues combinedvalues = new HqlValues(prior.Comparer.CombinedFieldsImpacted, prior.BlankValues, thisvalues);
                    SaveRowValue(combinedvalues);
                }
            }
        }