couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r701748 - in /incubator/couchdb/trunk: share/www/script/couch_tests.js src/couchdb/couch_httpd_view.erl
Date Sun, 05 Oct 2008 05:32:28 GMT
Author: jchris
Date: Sat Oct  4 22:32:28 2008
New Revision: 701748

URL: http://svn.apache.org/viewvc?rev=701748&view=rev
Log:
remove unnecessary negative count feature

Modified:
    incubator/couchdb/trunk/share/www/script/couch_tests.js
    incubator/couchdb/trunk/src/couchdb/couch_httpd_view.erl

Modified: incubator/couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch_tests.js?rev=701748&r1=701747&r2=701748&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] Sat Oct  4 22:32:28 2008
@@ -1101,7 +1101,7 @@
     var queryFun = function(doc) { emit(doc.integer, null) };
     var i;
 
-    // page through the view ascending and going forward
+    // page through the view ascending
     for (i = 0; i < docs.length; i += 10) {
       var queryResults = db.query(queryFun, null, {
         startkey: i,
@@ -1117,23 +1117,7 @@
       }
     }
 
-    // page through the view ascending and going backward
-    for (i = docs.length - 1; i >= 0; i -= 10) {
-      var queryResults = db.query(queryFun, null, {
-        startkey: i,
-        startkey_docid: i,
-        count:-10
-      });
-      T(queryResults.rows.length == 10)
-      T(queryResults.total_rows == docs.length)
-      T(queryResults.offset == i - 9)
-      var j;
-      for (j = 0; j < 10;j++) {
-        T(queryResults.rows[j].key == i - 9 + j);
-      }
-    }
-
-    // page through the view descending and going forward
+    // page through the view descending
     for (i = docs.length - 1; i >= 0; i -= 10) {
       var queryResults = db.query(queryFun, null, {
         startkey: i,
@@ -1150,23 +1134,6 @@
       }
     }
 
-    // page through the view descending and going backward
-    for (i = 0; i < docs.length; i += 10) {
-      var queryResults = db.query(queryFun, null, {
-        startkey: i,
-        startkey_docid: i,
-        descending: true,
-        count:-10
-      });
-      T(queryResults.rows.length == 10)
-      T(queryResults.total_rows == docs.length)
-      T(queryResults.offset == docs.length - i - 10)
-      var j;
-      for (j = 0; j < 10; j++) {
-        T(queryResults.rows[j].key == i + 9 - j);
-      }
-    }
-
     // ignore decending=false. CouchDB should just ignore that.
     for (i = 0; i < docs.length; i += 10) {
       var queryResults = db.query(queryFun, null, {

Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=701748&r1=701747&r2=701748&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_httpd_view.erl Sat Oct  4 22:32:28 2008
@@ -182,16 +182,8 @@
             case (catch list_to_integer(Value)) of
             Count when is_integer(Count) ->
                 if Count < 0 ->
-                    Args#view_query_args {
-                        direction =
-                        if Args#view_query_args.direction == rev -> fwd;
-                        true -> rev
-                        end,
-                        count=Count,
-                        start_key = reverse_key_default(Args#view_query_args.start_key),
-                        start_docid = reverse_key_default(Args#view_query_args.start_docid),
-                        end_key = reverse_key_default(Args#view_query_args.end_key),
-                        end_docid =  reverse_key_default(Args#view_query_args.end_docid)};
+                    Msg = io_lib:format("Count must be a positive integer: count=~s", [Value]),
+                    throw({query_parse_error, Msg});
                 true ->
                     Args#view_query_args{count=Count}
                 end;
@@ -248,8 +240,7 @@
     #view_query_args{
         end_key = EndKey,
         end_docid = EndDocId,
-        direction = Dir,
-        count = Count
+        direction = Dir
     } = QueryArgs,
 
     PassedEndFun =
@@ -264,33 +255,7 @@
         end
     end,
 
-    NegCountFun = fun({{Key, DocId}, Value}, OffsetReds,
-                      {AccCount, AccSkip, Resp, AccRevRows}) ->
-        Offset = ReduceCountFun(OffsetReds),
-        PassedEnd = PassedEndFun(Key, DocId),
-        case {PassedEnd, AccCount, AccSkip, Resp} of
-        {true, _, _, _} -> % The stop key has been passed, stop looping.
-            {stop, {AccCount, AccSkip, Resp, AccRevRows}};
-        {_, 0, _, _} -> % we've done "count" rows, stop foldling
-            {stop, {0, 0, Resp, AccRevRows}};
-        {_, _, AccSkip, _} when AccSkip > 0 ->
-            {ok, {AccCount, AccSkip - 1, Resp, AccRevRows}};
-        {_, _, _, undefined} ->
-            {ok, Resp2} = start_json_response(Req, 200),
-            Offset2 = TotalViewCount - Offset -
-                lists:min([TotalViewCount - Offset, - AccCount]),
-            JsonBegin = io_lib:format("{\"total_rows\":~w,\"offset\":~w,\"rows\":[\r\n",
-                    [TotalViewCount, Offset2]),
-            send_chunk(Resp2, JsonBegin),
-            JsonObj = {[{id, DocId}, {key, Key}, {value, Value}]},
-            {ok, {AccCount + 1, 0, Resp2, [?JSON_ENCODE(JsonObj) | AccRevRows]}};
-        {_, AccCount, _, Resp} ->
-            JsonObj = {[{id, DocId}, {key, Key}, {value, Value}]},
-            {ok, {AccCount + 1, 0, Resp, [?JSON_ENCODE(JsonObj), ",\r\n" | AccRevRows]}}
-        end
-    end,
-
-    PosCountFun = fun({{Key, DocId}, Value}, OffsetReds,
+    fun({{Key, DocId}, Value}, OffsetReds,
                       {AccCount, AccSkip, Resp, AccRevRows}) ->
         Offset = ReduceCountFun(OffsetReds), % I think we only need this call once per view
         PassedEnd = PassedEndFun(Key, DocId),
@@ -316,10 +281,6 @@
             send_chunk(Resp, ",\r\n" ++  ?JSON_ENCODE(JsonObj)),
             {ok, {AccCount - 1, 0, Resp, AccRevRows}}
         end
-    end,
-    case Count > 0 of
-    true ->     PosCountFun;
-    false ->    NegCountFun
     end.
 
 finish_view_fold(Req, TotalRows, FoldResult) ->



Mime
View raw message