コード例 #1
0
ファイル: HqlOutput.cs プロジェクト: elliottmatt/hqlcs
        ///////////////////////
        // Public

        public new string EvaluateGroupBy(int start, HqlResultRow row)
        {
            StringBuilder sb = new StringBuilder(_filename);

            for (int i = 0; i < _fieldgroup.Count; ++i)
            {
                string result = HqlSelect.EvaluateGroupByField(_fieldgroup[i], start + i, row).ToString();
                sb.Replace("{" + _fieldgroup[i].FieldRename + "}", result);
            }

            return(sb.ToString());
        }
コード例 #2
0
ファイル: HqlQuery.cs プロジェクト: elliottmatt/hqlcs
        private void ProcessHavingAndOrder()
        {
            if (_having.Count > 0)
            {
                HqlHavingRow havingRow = new HqlHavingRow(_orderby.FieldGroup, _groupby.FieldGroup, _select.FieldGroup);
                for (IDictionaryEnumerator ptr = _groupby.Table.GetEnumeratorForTable(); ptr.MoveNext();)
                {
                    HqlKey       key2   = (HqlKey)ptr.Key;
                    HqlResultRow value2 = (HqlResultRow)ptr.Value;

                    havingRow.Key = key2;
                    havingRow.Row = value2;

                    if (!_having.Evaluate(havingRow))
                    {
                        value2.ValuesSet = false;
                    }
                }
            }

            if (_orderby.Count > 0)
            {
                // I need to replace the keys with the actual values so that I sort them correctly
                for (IDictionaryEnumerator ptr = _groupby.Table.GetEnumeratorForTable(); ptr.MoveNext();)
                {
                    HqlKey       key2   = (HqlKey)ptr.Key;
                    HqlResultRow value2 = (HqlResultRow)ptr.Value;
                    if (!value2.ValuesSet)
                    {
                        continue;
                    }

                    for (int i = 0; i < _orderby.Count; ++i)
                    {
                        HqlField f = _orderby.FieldGroup[i];
                        if (f.HasFunction)
                        {
                            object o = ((HqlCalc)value2[i]).GetValue();
                            if (f.Scalar != null)
                            {
                                key2[i] = f.Scalar.Evaluate(o);
                            }
                            else
                            {
                                key2[i] = o;
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: HqlQuery.cs プロジェクト: elliottmatt/hqlcs
        private bool GetLineMultiSourceFunction()
        {
            for (; ;)
            {
                if (!_loadedFirstFiles)
                {
                    GetLineMultifileStreamableLoadFirstFiles();
                    _loadedFirstFiles = true;
                }

                if (!_successCalculate)
                {
                    _groupby.InitializeForStoringData(_orderby);
                    CalculateDataMultifiles();
                    _successCalculate = true;

                    ProcessHavingAndOrder();

                    _groupby.Table.Sort();
                    _ptr = _groupby.Table.GetSortedEnumeratorForTable();
                }

                if (!_ptr.MoveNext())
                {
                    return(false);
                }

                HqlKey       key   = (HqlKey)_ptr.Current;
                HqlResultRow value = (HqlResultRow)_groupby.Table[key];

                // did this pass the Having command?
                if (!value.ValuesSet)
                {
                    continue;
                }

                _line = _select.EvaluateGroupBy(_orderby.Count, value);

                if (_settings.PrintCategorizeFilename)
                {
                    _outfilename = _settings.Output.EvaluateGroupBy(_orderby.Count + _select.Count, value);
                }

                return(true);
            }
        }
コード例 #4
0
 public void AddToResultRow(int start, HqlRecord record, HqlResultRow row)
 {
     for (int i = 0; i < _fieldgroup.Count; ++i)
     {
         if (_fieldgroup[i].HasFunction)
         {
             object value = _fieldgroup[i].GetFunctionValue(record);
             row[start + i] = value; // this is an overloaded function that "adds" to this function or assigns if the first time
         }
         else
         {
             if (!row.ValuesSet)
             {
                 // save these!
                 object value = _fieldgroup[i].GetValue(record);
                 row[start + i] = value;
             }
         }
     }
 }
コード例 #5
0
ファイル: HqlQuery.cs プロジェクト: elliottmatt/hqlcs
        private void CreateKeyAndValue(HqlRecord record)
        {
            HqlKey KEY = null;

            object[] keys = CreateRecordKey(record, _orderby, _groupby, _settings.Output, _linenum);
            KEY = new HqlKey(keys);

            HqlResultRow row = _groupby.FindResultRow(KEY);

            if (row == null)
            {
                row = CreateObjectArrayValue(_orderby, _select, _settings.Output);
            }
#if DEBUG
            else
            {
                int stop = 0;
            }
#endif

            // set the values on the row
            int counter = 0;

            _orderby.AddToResultRow(counter, record, row);
            counter += _orderby.Count;

            _select.AddToResultRow(counter, record, row);
            counter += _select.Count;

            if (_settings.PrintCategorizeFilename)
            {
                _settings.Output.AddToResultRow(counter, record, row);
                //counter += _output.Count;
            }

            if (!row.ValuesSet)
            {
                row.ValuesSet = true;
                _groupby.SetResultRow(KEY, row);
            }
        }
コード例 #6
0
        ///////////////////////
        // Static Functions

        static public object EvaluateGroupByField(HqlField f, int num, HqlResultRow row)
        {
            if (f.HasFunction)
            {
                if (f.Scalar != null)
                {
                    object s = ((HqlCalc)row[num]).GetValue();
                    return(f.Scalar.Evaluate(s));
                }
                else
                {
                    object s = ((HqlCalc)row[num]).GetPrintValue();
                    return(s);
                }
            }
            else
            {
                string s = row[num].ToString();
                return(s);
            }
        }
コード例 #7
0
        public string EvaluateGroupBy(int start, HqlResultRow row)
        {
            StringBuilder sb      = new StringBuilder();
            bool          printed = false;

            for (int i = 0; i < _fieldgroup.Count; ++i)
            {
                if (!_fieldgroup[i].PrintResult)
                {
                    continue;
                }
                string s = HqlSelect.EvaluateGroupByField(_fieldgroup[i], start + i, row).ToString();
                if (printed)
                {
                    sb.Append(_settings.OutDelimiter);
                }
                sb.Append(s);
                printed = true;
            }
            sb.Append(_settings.FinalDelimiter);

            return(sb.ToString());
        }
コード例 #8
0
ファイル: HqlTable.cs プロジェクト: elliottmatt/hqlcs
        ///////////////////////
        // Overridden functions

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

        public void Set(HqlKey key, HqlResultRow row)
        {
            _ht[key] = row;
        }
コード例 #9
0
ファイル: HqlQuery.cs プロジェクト: elliottmatt/hqlcs
        private static HqlResultRow CreateObjectArrayValue(HqlClause order, HqlClause select, HqlClause output)
        {
            HqlResultRow row = new HqlResultRow(order.FieldGroup, select.FieldGroup, ((output == null) ? null : output.FieldGroup));

            return(row);
        }
コード例 #10
0
ファイル: HqlGroupBy.cs プロジェクト: elliottmatt/hqlcs
 public void SetResultRow(HqlKey key, HqlResultRow row)
 {
     Table.Set(key, row);
 }