Ejemplo n.º 1
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = PageSizeSet.GetHashCode();
         hashCode = (hashCode * 397) ^ (Query != null ? Query.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TotalSize != null ? TotalSize.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (QueryInputs != null ? QueryInputs.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Start;
         hashCode = (hashCode * 397) ^ (int)AggregationOperation;
         hashCode = (hashCode * 397) ^ (GroupBy != null ? GroupBy.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (FieldsToFetch != null ? FieldsToFetch.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SortedFields != null ? SortedFields.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Cutoff.GetHashCode();
         hashCode = (hashCode * 397) ^ (CutoffEtag != null ? CutoffEtag.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DefaultField != null ? DefaultField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)DefaultOperator;
         hashCode = (hashCode * 397) ^ SkipTransformResults.GetHashCode();
         hashCode = (hashCode * 397) ^ (SkippedResults != null ? SkippedResults.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DebugOptionGetIndexEntries.GetHashCode();
         hashCode = (hashCode * 397) ^ (HighlightedFields != null ? HighlightedFields.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HighlighterPreTags != null ? HighlighterPreTags.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HighlighterPostTags != null ? HighlighterPostTags.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ResultsTransformer != null ? ResultsTransformer.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DisableCaching.GetHashCode();
         return(hashCode);
     }
 }
Ejemplo n.º 2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = PageSizeSet.GetHashCode();
         hashCode = (hashCode * 397) ^ (Query != null ? Query.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TotalSize != null ? TotalSize.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TransformerParameters != null ? TransformerParameters.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Start;
         hashCode = (hashCode * 397) ^ (IsDistinct ? 1 : 0);
         hashCode = (hashCode * 397) ^ (FieldsToFetch != null ? FieldsToFetch.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SortedFields != null ? SortedFields.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SortHints != null ? SortHints.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Cutoff.GetHashCode();
         hashCode = (hashCode * 397) ^ WaitForNonStaleResultsAsOfNow.GetHashCode();
         hashCode = (hashCode * 397) ^ (CutoffEtag != null ? CutoffEtag.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DefaultField != null ? DefaultField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)DefaultOperator;
         hashCode = (hashCode * 397) ^ (SkippedResults != null ? SkippedResults.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DebugOptionGetIndexEntries.GetHashCode();
         hashCode = (hashCode * 397) ^ (HighlightedFields != null ? HighlightedFields.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HighlighterPreTags != null ? HighlighterPreTags.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HighlighterPostTags != null ? HighlighterPostTags.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HighlighterKeyName != null ? HighlighterKeyName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ResultsTransformer != null ? ResultsTransformer.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ShowTimings ? 1 : 0);
         hashCode = (hashCode * 397) ^ DisableCaching.GetHashCode();
         return(hashCode);
     }
 }
Ejemplo n.º 3
0
    void setHighlightedFields()
    {
        clearHighlights();
        int startx, endx;
        int starty, endy;

        if (x - moveRange > 0)
        {
            startx = x - moveRange;
        }
        else
        {
            startx = 0;
        }

        if (x + moveRange < 29)
        {
            endx = x + moveRange;
        }
        else
        {
            endx = 29;
        }

        if (y - moveRange > 0)
        {
            starty = y - moveRange;
        }
        else
        {
            starty = 0;
        }

        if (y + moveRange < 19)
        {
            endy = y + moveRange;
        }
        else
        {
            endy = 19;
        }

        int loopy = starty;

        while (startx < endx + 1)
        {
            while (loopy < endy + 1)
            {
                HighlightedFields ht = highlightedTile.GetComponent <HighlightedFields>();
                ht.x = startx;
                ht.y = loopy;
                Instantiate(highlightedTile, new Vector3(startx, loopy, 0f), Quaternion.identity);
                loopy++;
            }
            loopy = starty;
            startx++;
        }
    }
Ejemplo n.º 4
0
        public IndexDefinitionBase CreateAutoIndexDefinition()
        {
            if (IsMapReduce == false)
            {
                return(new AutoMapIndexDefinition(ForCollection, MapFields.Select(field =>
                                                                                  new IndexField
                {
                    Name = field.Name,
                    Storage = FieldStorage.No,
                    SortOption = SortDescriptors.FirstOrDefault(x => field.Name.Equals(x.Name))?.FieldType,
                    Highlighted = HighlightedFields.Any(x => field.Name.Equals(x))
                }).ToArray()));
            }

            if (MapFields.Length == 0)
            {
                throw new InvalidOperationException("Invalid dynamic map-reduce query mapping. There is no aggregation specified.");
            }

            if (GroupByFields.Length == 0)
            {
                throw new InvalidOperationException("Invalid dynamic map-reduce query mapping. There is no group by field specified.");
            }

            return(new AutoMapReduceIndexDefinition(new[] { ForCollection }, MapFields.Select(field =>
                                                                                              new IndexField
            {
                Name = field.Name,
                Storage = FieldStorage.Yes,
                MapReduceOperation = field.MapReduceOperation,
                SortOption = SortDescriptors.FirstOrDefault(x => field.Name.Equals(x.Name))?.FieldType,
            }).ToArray(),
                                                    GroupByFields.Select(field =>
                                                                         new IndexField
            {
                Name = field,
                Storage = FieldStorage.Yes,
                SortOption = SortDescriptors.FirstOrDefault(x => field.Equals(x.Name))?.FieldType,
            }).ToArray()));
        }
Ejemplo n.º 5
0
        public void AppendQueryString(StringBuilder path, bool includePageSizeEvenIfNotExplicitlySet = true, bool includeQuery = true)
        {
            path.Append("?");

            AppendMinimalQueryString(path, includeQuery);

            if (Start != 0)
            {
                path.Append("&start=").Append(Start);
            }

            if (includePageSizeEvenIfNotExplicitlySet || PageSizeSet)
            {
                path.Append("&pageSize=").Append(PageSize);
            }

            if (AllowMultipleIndexEntriesForSameDocumentToResultTransformer)
            {
                path.Append("&allowMultipleIndexEntriesForSameDocumentToResultTransformer=true");
            }

            if (IsDistinct)
            {
                path.Append("&distinct=true");
            }

            if (ShowTimings)
            {
                path.Append("&showTimings=true");
            }
            if (SkipDuplicateChecking)
            {
                path.Append("&skipDuplicateChecking=true");
            }

            FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));
            Includes.ApplyIfNotNull(include => path.AppendFormat("&include={0}", Uri.EscapeDataString(include)));

            DynamicMapReduceFields.ApplyIfNotNull(field => path.Append("&mapReduce=")
                                                  .Append(Uri.EscapeDataString(field.Name))
                                                  .Append("-")
                                                  .Append(field.OperationType)
                                                  .Append("-")
                                                  .Append(field.IsGroupBy));

            SortedFields.ApplyIfNotNull(
                field => path.Append("&sort=").Append(field.Descending ? "-" : "").Append(Uri.EscapeDataString(field.Field)));

            if (string.IsNullOrEmpty(Transformer) == false)
            {
                path.AppendFormat("&transformer={0}", Uri.EscapeDataString(Transformer));
            }

            if (TransformerParameters != null)
            {
                foreach (var input in TransformerParameters)
                {
                    path.AppendFormat("&tp-{0}={1}", input.Key, input.Value);
                }
            }

            if (CutoffEtag != null)
            {
                path.Append("&cutOffEtag=").Append(CutoffEtag);
            }

            if (WaitForNonStaleResultsAsOfNow)
            {
                path.Append("&waitForNonStaleResultsAsOfNow=true");
            }

            if (WaitForNonStaleResultsTimeout != null)
            {
                path.AppendLine("&waitForNonStaleResultsTimeout=" + WaitForNonStaleResultsTimeout);
            }

            HighlightedFields.ApplyIfNotNull(field => path.Append("&highlight=").Append(field));
            HighlighterPreTags.ApplyIfNotNull(tag => path.Append("&preTags=").Append(tag));
            HighlighterPostTags.ApplyIfNotNull(tag => path.Append("&postTags=").Append(tag));

            if (string.IsNullOrEmpty(HighlighterKeyName) == false)
            {
                path.AppendFormat("&highlighterKeyName={0}", Uri.EscapeDataString(HighlighterKeyName));
            }

            if (DebugOptionGetIndexEntries)
            {
                path.Append("&debug=entries");
            }

            if (ExplainScores)
            {
                path.Append("&explainScores=true");
            }
        }
Ejemplo n.º 6
0
        public void AppendQueryString(StringBuilder path, bool includePageSizeEvenIfNotExplicitlySet = true, bool includeQuery = true)
        {
            path.Append("?");

            AppendMinimalQueryString(path, includeQuery);

            if (Start != 0)
            {
                path.Append("&start=").Append(Start);
            }

            if (includePageSizeEvenIfNotExplicitlySet || PageSizeSet)
            {
                path.Append("&pageSize=").Append(PageSize);
            }


            if (AllowMultipleIndexEntriesForSameDocumentToResultTransformer)
            {
                path.Append("&allowMultipleIndexEntriesForSameDocumentToResultTransformer=true");
            }

            if (IsDistinct)
            {
                path.Append("&distinct=true");
            }

            if (ShowTimings)
            {
                path.Append("&showTimings=true");
            }

            FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));
            SortedFields.ApplyIfNotNull(
                field => path.Append("&sort=").Append(field.Descending ? "-" : "").Append(Uri.EscapeDataString(field.Field)));
            SortHints.ApplyIfNotNull(hint => path.AppendFormat("&SortHint{2}{0}={1}", Uri.EscapeDataString(hint.Key), hint.Value, hint.Key.StartsWith("-") ? string.Empty : "-"));

            if (string.IsNullOrEmpty(ResultsTransformer) == false)
            {
                path.AppendFormat("&resultsTransformer={0}", Uri.EscapeDataString(ResultsTransformer));
            }

            if (TransformerParameters != null)
            {
                foreach (var input in TransformerParameters)
                {
                    path.AppendFormat("&tp-{0}={1}", input.Key, input.Value);
                }
            }

            if (Cutoff != null)
            {
                var cutOffAsString = Uri.EscapeDataString(Cutoff.Value.ToString("o", CultureInfo.InvariantCulture));
                path.Append("&cutOff=").Append(cutOffAsString);
            }
            if (CutoffEtag != null)
            {
                path.Append("&cutOffEtag=").Append(CutoffEtag);
            }
            if (WaitForNonStaleResultsAsOfNow)
            {
                path.Append("&waitForNonStaleResultsAsOfNow=true");
            }

            HighlightedFields.ApplyIfNotNull(field => path.Append("&highlight=").Append(field));
            HighlighterPreTags.ApplyIfNotNull(tag => path.Append("&preTags=").Append(tag));
            HighlighterPostTags.ApplyIfNotNull(tag => path.Append("&postTags=").Append(tag));

            if (string.IsNullOrEmpty(HighlighterKeyName) == false)
            {
                path.AppendFormat("&highlighterKeyName={0}", Uri.EscapeDataString(HighlighterKeyName));
            }

            if (DebugOptionGetIndexEntries)
            {
                path.Append("&debug=entries");
            }

            if (ExplainScores)
            {
                path.Append("&explainScores=true");
            }
        }
Ejemplo n.º 7
0
        public IndexDefinition CreateIndexDefinition()
        {
            var fromClauses  = new HashSet <string>();
            var realMappings = new HashSet <string>();

            if (!string.IsNullOrEmpty(ForEntityName))
            {
                fromClauses.Add("from doc in docs." + ForEntityName);
            }
            else
            {
                fromClauses.Add("from doc in docs");
            }

            foreach (var map in Items)
            {
                var currentDoc        = "doc";
                var currentExpression = new StringBuilder();

                int currentIndex = 0;
                while (currentIndex < map.From.Length)
                {
                    char currentChar = map.From[currentIndex++];
                    switch (currentChar)
                    {
                    case ',':

                        // doc.NewDoc.Items
                        String newDocumentSource = string.Format("{0}.{1}", currentDoc, currentExpression);

                        // docNewDocItemsItem
                        String newDoc = string.Format("{0}Item", newDocumentSource.Replace(".", ""));

                        // from docNewDocItemsItem in doc.NewDoc.Items
                        String docInclude = string.Format("from {0} in ((IEnumerable<dynamic>){1}).DefaultIfEmpty()", newDoc, newDocumentSource);
                        fromClauses.Add(docInclude);

                        // Start building the property again
                        currentExpression.Clear();

                        // And from this new doc
                        currentDoc = newDoc;

                        break;

                    default:
                        currentExpression.Append(currentChar);
                        break;
                    }
                }

                if (currentExpression.Length > 0 && currentExpression[0] != '[')
                {
                    currentExpression.Insert(0, '.');
                }
                // We get rid of any _Range(s) etc
                var indexedMember = currentExpression.ToString().Replace("_Range", "");
                if (indexedMember.Length == 0)
                {
                    realMappings.Add(string.Format("{0} = {1}",
                                                   map.To.Replace("_Range", ""),
                                                   currentDoc
                                                   ));
                }
                else
                {
                    realMappings.Add(string.Format("{0} = {1}{2}",
                                                   map.To.Replace("_Range", ""),
                                                   currentDoc,
                                                   indexedMember
                                                   ));
                }
            }

            var index = new IndexDefinition
            {
                Map = string.Format("{0}\r\nselect new {{ {1} }}",
                                    string.Join("\r\n", fromClauses.ToArray()),
                                    string.Join(", ",
                                                realMappings.Concat(new[] { AggregationMapPart() }).Where(x => x != null))),
                Reduce           = DynamicAggregation ? null : AggregationReducePart(),
                TransformResults = DynamicAggregation ? AggregationReducePart() : null,
            };

            if (DynamicAggregation)
            {
                foreach (var item in GroupByItems)
                {
                    index.Stores[ToFieldName(item.To)] = FieldStorage.Yes;
                }
            }

            foreach (var descriptor in SortDescriptors)
            {
                index.SortOptions[ToFieldName(descriptor.Field)] = descriptor.FieldType;
            }

            foreach (var field in HighlightedFields.EmptyIfNull())
            {
                index.Stores[field]      = FieldStorage.Yes;
                index.Indexes[field]     = FieldIndexing.Analyzed;
                index.TermVectors[field] = FieldTermVector.WithPositionsAndOffsets;
            }
            return(index);
        }
Ejemplo n.º 8
0
        public void AppendQueryString(StringBuilder path, bool includePageSizeEvenIfNotExplicitlySet = true, bool includeQuery = true)
        {
            path.Append("?");

            AppendMinimalQueryString(path, includeQuery);

            if (Start != 0)
            {
                path.Append("&start=").Append(Start);
            }

            if (includePageSizeEvenIfNotExplicitlySet || PageSizeSet)
            {
                path.Append("&pageSize=").Append(PageSize);
            }


            if (IsDistinct)
            {
                path.Append("&distinct=true");
            }

            FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));
            SortedFields.ApplyIfNotNull(
                field => path.Append("&sort=").Append(field.Descending ? "-" : "").Append(Uri.EscapeDataString(field.Field)));



            if (SkipTransformResults)
            {
                path.Append("&skipTransformResults=true");
            }

            if (string.IsNullOrEmpty(ResultsTransformer) == false)
            {
                path.AppendFormat("&resultsTransformer={0}", Uri.EscapeDataString(ResultsTransformer));
            }

            if (QueryInputs != null)
            {
                foreach (var input in QueryInputs)
                {
                    path.AppendFormat("&qp-{0}={1}", input.Key, input.Value);
                }
            }

            if (Cutoff != null)
            {
                var cutOffAsString = Uri.EscapeDataString(Cutoff.Value.ToString("o", CultureInfo.InvariantCulture));
                path.Append("&cutOff=").Append(cutOffAsString);
            }
            if (CutoffEtag != null)
            {
                path.Append("&cutOffEtag=").Append(CutoffEtag);
            }
            if (WaitForNonStaleResultsAsOfNow)
            {
                path.Append("&waitForNonStaleResultsAsOfNow=true");
            }

            HighlightedFields.ApplyIfNotNull(field => path.Append("&highlight=").Append(field));
            HighlighterPreTags.ApplyIfNotNull(tag => path.Append("&preTags=").Append(tag));
            HighlighterPostTags.ApplyIfNotNull(tag => path.Append("&postTags=").Append(tag));

            if (DebugOptionGetIndexEntries)
            {
                path.Append("&debug=entries");
            }

            if (ExplainScores)
            {
                path.Append("&explainScores=true");
            }
        }