protected override void ProcessTuple(TexeraTuple tuple)
 {
     if (tuple.FieldList != null && tuple.FieldList[searchIndex].Contains(keyword))
     {
         outputTuples.Enqueue(tuple);
     }
 }
Example #2
0
        protected override void ProcessTuple(TexeraTuple tuple)
        {
            string        field  = tuple.FieldList[joinFieldIndex];
            List <string> fields = tuple.FieldList.ToList();

            fields.RemoveAt(joinFieldIndex);
            foreach (KeyValuePair <int, Dictionary <string, List <TexeraTuple> > > entry in joinedTuples)
            {
                if (entry.Key != tuple.TableID && entry.Value.ContainsKey(field))
                {
                    foreach (TexeraTuple joinedTuple in entry.Value[field])
                    {
                        outputTuples.Enqueue(new TexeraTuple(TableID, joinedTuple.FieldList.Concat(fields).ToArray()));
                    }
                }
            }
            if (!joinedTuples.ContainsKey(tuple.TableID))
            {
                Dictionary <string, List <TexeraTuple> > d = new Dictionary <string, List <TexeraTuple> >();
                d.Add(field, new List <TexeraTuple> {
                    tuple
                });
                joinedTuples.Add(tuple.TableID, d);
            }
            else if (!joinedTuples[tuple.TableID].ContainsKey(field))
            {
                joinedTuples[tuple.TableID].Add(field, new List <TexeraTuple> {
                    tuple
                });
            }
            else
            {
                joinedTuples[tuple.TableID][field].Add(tuple);
            }
        }
Example #3
0
        public void Accept(TexeraTuple tuple)
        {
            flag = true;
            var result = SentimentAnalyzer.Sentiments.Predict(tuple.FieldList[predictIndex]);

            resultTuple = new TexeraTuple(new string[] { tuple.FieldList[predictIndex], $"{(result.Prediction?"positive":"negative")}(Prob:{result.Probability},Score:{result.Score})" });
        }
Example #4
0
        public void Accept(TexeraTuple tuple)
        {
            if (tuple.FieldList != null)
            {
                try
                {
                    switch (filterType)
                    {
                    case FilterType.Equal:
                        if (Parse(tuple.FieldList[filterIndex]).CompareTo(threshold) == 0)
                        {
                            flag = true;
                        }
                        break;

                    case FilterType.Greater:
                        if (Parse(tuple.FieldList[filterIndex]).CompareTo(threshold) > 0)
                        {
                            flag = true;
                        }
                        break;

                    case FilterType.GreaterOrEqual:
                        if (Parse(tuple.FieldList[filterIndex]).CompareTo(threshold) >= 0)
                        {
                            flag = true;
                        }
                        break;

                    case FilterType.Less:
                        if (Parse(tuple.FieldList[filterIndex]).CompareTo(threshold) < 0)
                        {
                            flag = true;
                        }
                        break;

                    case FilterType.LessOrEqual:
                        if (Parse(tuple.FieldList[filterIndex]).CompareTo(threshold) <= 0)
                        {
                            flag = true;
                        }
                        break;

                    case FilterType.NotEqual:
                        if (Parse(tuple.FieldList[filterIndex]).CompareTo(threshold) != 0)
                        {
                            flag = true;
                        }
                        break;
                    }
                }
                catch (Exception)
                {
                }
                if (flag)
                {
                    resultTuple = tuple;
                }
            }
        }
 public void Accept(TexeraTuple tuple)
 {
     if (tuple.FieldList[searchIndex].Contains(keyword))
     {
         flag        = true;
         resultTuple = tuple;
     }
 }
Example #6
0
        public TexeraTuple Next()
        {
            var result = new TexeraTuple(currentTuple.FastConcat(currentEntry[currentIndex]));

            currentIndex++;
            if (currentIndex >= currentEntry.Count)
            {
                flag = false;
            }
            return(result);
        }
Example #7
0
        public void Accept(TexeraTuple tuple)
        {
            resultTuple = new TexeraTuple(new string[projectionIndexs.Count]);
            int i = 0;

            foreach (int attr in projectionIndexs)
            {
                resultTuple.FieldList[i++] = tuple.FieldList[attr];
            }
            flag = true;
        }
        protected override void ProcessTuple(TexeraTuple tuple)
        {
            TexeraTuple result = new TexeraTuple(tuple.TableID, new string[projectionIndexs.Count]);
            int         i      = 0;

            foreach (int attr in projectionIndexs)
            {
                result.FieldList[i++] = tuple.FieldList[attr];
            }
            outputTuples.Enqueue(result);
        }
Example #9
0
        public void Accept(TexeraTuple tuple)
        {
            T   value = Parse(tuple.FieldList[sortIndex]);
            int index = sortedValues.BinarySearch(value);

            if (index < 0)
            {
                index = ~index;
            }
            sortedTuples.Insert(index, tuple);
            sortedValues.Insert(index, value);
        }
        protected override void ProcessTuple(TexeraTuple tuple)
        {
            T   value = Parse(tuple.FieldList[sortIndex]);
            int index = sortedValues.BinarySearch(value);

            if (index < 0)
            {
                index = ~index;
            }
            sortedTuples.Insert(index, tuple);
            sortedValues.Insert(index, value);
        }
        protected override void ProcessTuple(TexeraTuple tuple)
        {
            if (tuple.FieldList != null)
            {
                switch (type)
                {
                case FilterPredicate.FilterType.Equal:
                    if (Parse(tuple.FieldList[filterIndex]).CompareTo(threshold) == 0)
                    {
                        outputTuples.Enqueue(tuple);
                    }
                    break;

                case FilterPredicate.FilterType.Greater:
                    if (Parse(tuple.FieldList[filterIndex]).CompareTo(threshold) > 0)
                    {
                        outputTuples.Enqueue(tuple);
                    }
                    break;

                case FilterPredicate.FilterType.GreaterOrEqual:
                    if (Parse(tuple.FieldList[filterIndex]).CompareTo(threshold) >= 0)
                    {
                        outputTuples.Enqueue(tuple);
                    }
                    break;

                case FilterPredicate.FilterType.Less:
                    if (Parse(tuple.FieldList[filterIndex]).CompareTo(threshold) < 0)
                    {
                        outputTuples.Enqueue(tuple);
                    }
                    break;

                case FilterPredicate.FilterType.LessOrEqual:
                    if (Parse(tuple.FieldList[filterIndex]).CompareTo(threshold) <= 0)
                    {
                        outputTuples.Enqueue(tuple);
                    }
                    break;

                case FilterPredicate.FilterType.NotEqual:
                    if (Parse(tuple.FieldList[filterIndex]).CompareTo(threshold) != 0)
                    {
                        outputTuples.Enqueue(tuple);
                    }
                    break;
                }
            }
        }
Example #12
0
        public void Accept(TexeraTuple tuple)
        {
            string field = tuple.FieldList[groupByIndex];

            if (counter.ContainsKey(field))
            {
                counter[field]++;
            }
            else
            {
                counter[field] = 1;
            }
            if (aggregationFunc != AggregationType.Count)
            {
                try
                {
                    double value = double.Parse(tuple.FieldList[aggregationIndex]);
                    if (results.ContainsKey(field))
                    {
                        double oldValue = results[field];
                        switch (aggregationFunc)
                        {
                        case AggregationType.Max:
                            results[field] = Math.Max(oldValue, value);
                            break;

                        case AggregationType.Min:
                            results[field] = Math.Min(oldValue, value);
                            break;

                        case AggregationType.Average:
                            results[field] += value;
                            break;

                        case AggregationType.Sum:
                            results[field] += value;
                            break;
                        }
                    }
                    else
                    {
                        results[field] = value;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
        public void Accept(TexeraTuple tuple)
        {
            string field = tuple.FieldList[0];

            if (aggregationFunc == AggregationType.Count)
            {
                if (counter.ContainsKey(field))
                {
                    counter[field] += int.Parse(tuple.FieldList[1]);
                }
                else
                {
                    counter.Add(field, int.Parse(tuple.FieldList[1]));
                }
            }
            else
            {
                double value = double.Parse(tuple.FieldList[1]);
                if (results.ContainsKey(field))
                {
                    switch (aggregationFunc)
                    {
                    case AggregationType.Max:
                        results[field] = Math.Max(results[field], value);
                        break;

                    case AggregationType.Min:
                        results[field] = Math.Min(results[field], value);
                        break;

                    case AggregationType.Average:
                        results[field] += value;
                        counter[field] += int.Parse(tuple.FieldList[2]);
                        break;

                    case AggregationType.Sum:
                        results[field] += value;
                        break;
                    }
                }
                else
                {
                    results.Add(field, value);
                    counter.Add(field, 1);
                }
            }
        }
        protected override void ProcessTuple(TexeraTuple tuple)
        {
            try
            {
                string field = tuple.FieldList[groupByIndex];
                double value = double.Parse(tuple.FieldList[aggregationIndex]);
                if (results.ContainsKey(field))
                {
                    counter[field]++;
                    double oldValue = results[field];
                    switch (aggregationFunc)
                    {
                    case "max":
                        results[field] = Math.Max(oldValue, value);
                        break;

                    case "min":
                        results[field] = Math.Min(oldValue, value);
                        break;

                    case "avg":
                        results[field] += value;
                        break;

                    case "sum":
                        results[field] += value;
                        break;

                    case "count":
                        break;
                    }
                }
                else
                {
                    results[field] = value;
                    counter[field] = 1;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #15
0
 protected override void ProcessTuple(TexeraTuple tuple)
 {
     if (tableSource == -1)
     {
         tableSource = tuple.TableID;
     }
     if (tuple.TableID.Equals(tableSource))
     {
         string source = tuple.FieldList[joinFieldIndex];
         if (!hashTable.ContainsKey(source))
         {
             hashTable[source] = new List <TexeraTuple> {
                 tuple
             }
         }
         ;
         else
         {
             hashTable[source].Add(tuple);
         }
     }
     else
     {
         if (inputInfo[sourceOperator] != 0)
         {
             otherTable.Add(tuple);
         }
         else
         {
             string        field  = tuple.FieldList[joinFieldIndex];
             List <string> fields = tuple.FieldList.ToList();
             fields.RemoveAt(joinFieldIndex);
             foreach (TexeraTuple t in hashTable[field])
             {
                 outputTuples.Enqueue(new TexeraTuple(TableID, t.FieldList.Concat(fields).ToArray()));
             }
         }
     }
 }
 private bool ReadTuple(out TexeraTuple tx)
 {
     try
     {
         ulong  ByteCount;
         string res = reader.ReadLine(out ByteCount);
         start += ByteCount;
         if (reader.IsEOF())
         {
             start = end + 1;
             tx    = null;
             return(false);
         }
         try
         {
             tx = new TexeraTuple(tableId, res.Split(separator));
             ++tuple_counter;
             return(true);
         }
         catch
         {
             tx = null;
             Console.WriteLine("Failed to parse the tuple");
             return(false);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("EXCEPTION in Reading Tuples from File - " + ex.ToString());
         Console.WriteLine("start_offset: " + start.ToString() + " end_offset: " + end.ToString());
         if (!reader.GetFile(start))
         {
             throw new Exception("Reading Tuple: Cannot Get File");
         }
         tx = null;
         return(false);
     }
 }
Example #17
0
        public void Accept(TexeraTuple tuple)
        {
            string        field  = tuple.FieldList[joinFieldIndex];
            List <string> fields = tuple.FieldList.ToList();

            if (joinedTuples.ContainsKey(field))
            {
                foreach (TexeraTuple joinedTuple in joinedTuples[field])
                {
                    output.Enqueue(new TexeraTuple(joinedTuple.FieldList.Concat(fields).ToArray()));
                }
            }
            if (!toInsert.ContainsKey(field))
            {
                toInsert.Add(field, new List <TexeraTuple> {
                    tuple
                });
            }
            else
            {
                toInsert[field].Add(tuple);
            }
        }
Example #18
0
 public void Accept(TexeraTuple tuple)
 {
     if (isCurrentInnerTable)
     {
         string source = tuple.FieldList[innerTableIndex];
         if (!hashTable.ContainsKey(source))
         {
             hashTable[source] = new List <string[]> {
                 tuple.FieldList.RemoveAt(innerTableIndex)
             }
         }
         ;
         else
         {
             hashTable[source].Add(tuple.FieldList.RemoveAt(innerTableIndex));
         }
     }
     else
     {
         if (!isInnerTableFinished)
         {
             otherTable.Add(tuple);
         }
         else
         {
             string field = tuple.FieldList[outerTableIndex];
             if (hashTable.ContainsKey(field))
             {
                 flag         = true;
                 currentIndex = 0;
                 currentEntry = hashTable[field];
                 currentTuple = tuple.FieldList;
             }
         }
     }
 }
 protected override void ProcessTuple(TexeraTuple tuple)
 {
     //Console.WriteLine(++counter+" tuple processed");
     foreach (KeyValuePair <int, List <TexeraTuple> > entry in CrossRippleJoinedTuples)
     {
         if (entry.Key != tuple.TableID)
         {
             foreach (TexeraTuple t in entry.Value)
             {
                 outputTuples.Enqueue(new TexeraTuple(TableID, tuple.FieldList.Concat(t.FieldList).ToArray()));
             }
         }
     }
     if (CrossRippleJoinedTuples.ContainsKey(tuple.TableID))
     {
         CrossRippleJoinedTuples[tuple.TableID].Add(tuple);
     }
     else
     {
         CrossRippleJoinedTuples.Add(tuple.TableID, new List <TexeraTuple> {
             tuple
         });
     }
 }
Example #20
0
 public abstract void Accept(TexeraTuple tuple);
Example #21
0
 public void Accept(TexeraTuple tuple)
 {
     sws[NonNegativeModular(hashFunc(tuple), numBuckets)].WriteLine(String.Join("|", tuple.FieldList));
 }
Example #22
0
 public void Accept(TexeraTuple tuple)
 {
     sws.WriteLine(String.Join("|", tuple.FieldList));
 }
 protected virtual void ProcessTuple(TexeraTuple tuple)
 {
 }
Example #24
0
 protected override void ProcessTuple(TexeraTuple tuple)
 {
     count++;
 }
 protected override void ProcessTuple(TexeraTuple tuple)
 {
     count += int.Parse(tuple.FieldList[0]);
 }
Example #26
0
 public void Accept(TexeraTuple tuple)
 {
     count += int.Parse(tuple.FieldList[0]);
 }
Example #27
0
 public void Accept(TexeraTuple tuple)
 {
     count++;
     receivedCounter++;
 }
Example #28
0
 public override void Accept(TexeraTuple tuple)
 {
     this.current++;
 }