Esempio n. 1
0
        /// <summary>
        /// Get the results of an index query prepared for use in a <see cref="CorrugatedIron.Models.MapReduce.MapReduceQuery"/>
        /// </summary>
        /// <returns>
        /// A <see cref="RiakBucketKeyInput"/> of the index query results
        /// </returns>
        /// <param name='indexQuery'>
        /// Index query.
        /// </param>
        public RiakBucketKeyInput GetIndex(RiakIndexInput indexQuery)
        {
            var query = new RiakMapReduceQuery()
                        .Inputs(indexQuery).ReduceErlang(r => r.ModFun("riak_kv_mapreduce", "reduce_identity").Keep(true));
            var result = MapReduce(query);

            var keys = result.Value.PhaseResults.OrderBy(pr => pr.Phase).ElementAt(0).GetObjects <RiakObjectId>();

            return(RiakBucketKeyInput.FromRiakObjectIds(keys));
        }
Esempio n. 2
0
        public void FromRiakObjectIdsHelperMethodSerializesCorrectly()
        {
            var ids = new List <RiakObjectId>
            {
                new RiakObjectId("bazType", "foo", "bar"),
                new RiakObjectId("bazType", "foo", "baz"),
                new RiakObjectId("bazType", "dooby", "scooby")
            };

            var input = RiakBucketKeyInput.FromRiakObjectIds(ids);
            var s     = Serialize(input.WriteJson);

            Assert.AreEqual(s,
                            "\"inputs\":[[\"foo\",\"bar\",\"bazType\"],[\"foo\",\"baz\",\"bazType\"],[\"dooby\",\"scooby\",\"bazType\"]]");
        }