コード例 #1
0
        public IFieldMapper Parse(JobParser parser, ParseState state)
        {
            var testIdString = state.Require <string>("TestId", true);

            Guid testId;

            if (!Guid.TryParse(testIdString, out testId))
            {
                throw state.AttributeError("Invalid test id specified ({0})", testIdString);
            }


            var testSet = TestManager.GetTestSet(testId);

            var testMapper = new MvTestFieldMapper(testSet, state.AffixName(state.TryGet("Name", "MvTest")));

            if (state.SelectMany("Fields").Any())
            {
                var splitter = new SplittingFieldMapper(new MvTestSplitter(testId),
                                                        postfix =>
                                                        state.Postfix(postfix).SelectMany("Fields").Select(parser.ParseFieldMapper).ToArray());

                return(new FieldMapperSet(testMapper.Name, true, new IFieldMapper[] { testMapper, splitter }, state.AffixName));
            }

            return(testMapper);
        }
            public ISplitter Parse(JobParser parser, ParseState state)
            {
                var testIdString = state.Require <string>("TestId", true);

                Guid testId;

                if (!Guid.TryParse(testIdString, out testId))
                {
                    throw state.AttributeError("Invalid test id specified ({0})", testIdString);
                }

                return(new MvTestSplitter(testId));
            }
コード例 #3
0
            public IDataSource Parse(JobParser parser, ParseState state)
            {
                var connectionString = state.TryGet("connection", ExperienceExtractorWebApiConfig.XdbConnectionString, true);

                if (!connectionString.StartsWith("mongodb://"))
                {
                    var connection = ConfigurationManager.ConnectionStrings[connectionString];
                    if (connection == null)
                    {
                        throw state.AttributeError("Connection string '{0}' not found", connectionString);
                    }
                    connectionString = connection.ConnectionString;
                }

                var source = new MongoDbVisitAggregationContextSource(new MongoDbDriver(connectionString), ExperienceExtractorWebApiConfig.JobExecutionSettings.LoadThreads);

                //source.SecondaryLookup = state.TryGet("SecondaryLookup", false);

                var index = state.TryGet <string>("index");

                if (!string.IsNullOrEmpty(index))
                {
                    source.CursorInitializing += (sender, cursor) =>
                    {
                        if (index == "$natural")
                        {
                            cursor.SetSortOrder(SortBy.Ascending("$natural"));
                        }
                        else
                        {
                            cursor.SetHint(index);
                        }
                    };
                }

                var fields = state.TryGet("fields", new string[0]);

                if (fields.Length > 0)
                {
                    source.CursorInitializing += (sender, cursor) => cursor.SetFields(fields);
                }


                foreach (var filter in state.SelectMany("Filters"))
                {
                    source.Filters.Add(parser.ParseDataFilter(filter));
                }

                return(source);
            }
コード例 #4
0
        public ITableMapper Parse(JobParser parser, ParseState state)
        {
            var source = state.TryGet <string>("Select", mainParameter: true) ?? "Pages";

            var type = state.TryGet("Type", "CoOccurrence");

            var name = state.TryGet("Name", source + type);

            var selector = Selectors.SelectFromName(source);

            Func <ProcessingScope, IEnumerable <Tuple <object, object> > > matrix;

            if (type.Equals("cooccurrence", StringComparison.InvariantCultureIgnoreCase))
            {
                matrix = scope => MatrixTypes.CoOcurrence(selector(scope));
            }
            else if (type.Equals("links", StringComparison.InvariantCultureIgnoreCase))
            {
                matrix = scope => MatrixTypes.Links(selector(scope));
            }
            else
            {
                throw state.AttributeError("Unkown matrix type '{0}'", type);
            }


            var facts = state.SelectMany("CommonFields").Select(parser.ParseFieldMapper).ToList();

            if (state.Select("CommonFields") == null)
            {
                facts.Add(new SimpleFieldMapper("Count", s => 1, typeof(int), FieldType.Fact));
            }

            return(new MatrixTableMapper(state.AffixName(name), matrix, postfix =>
                                         state.Postfix(postfix).SelectMany("Fields", true).Select(parser.ParseFieldMapper).ToArray(), facts));
        }