Book Image

Learning Couchbase

By : Henry Potsangbam
Book Image

Learning Couchbase

By: Henry Potsangbam

Overview of this book

This book achieves its goal by taking up an end-to-end development structure, right from understanding NOSQL document design to implementing full fledged eCommerce application design using Couchbase as a backend. Starting with the architecture of Couchbase to get you up and running, this book quickly takes you through designing a NoSQL document and implementing highly scalable applications using Java API. You will then be introduced to document design and get to know the various ways to administer Couchbase. Followed by this, learn to store documents using bucket. Moving on, you will then learn to store, retrieve and delete documents using smart client base on Java API. You will then retrieve documents using SQL like syntax call N1QL. Next, you will learn how to write map reduce base views. Finally, you will configure XDCR for disaster recovery and implement an eCommerce application using Couchbase.
Table of Contents (12 chapters)
Index

Custom reduce functions


Why do we need custom reduce functions? Sometimes, the built-in reduce function doesn't meet our requirements, although it will suffice most of the time.

Custom reduce functions allow you to create your own reduce function. In such a reduce function, output of map function goes to the corresponding reduce function group as per the key of the map output and the group level parameter. Couchbase ensures that output from the map will be grouped by key and supplied to reduce. Then it's developer's role to define logic in reduce, what to perform on the data such as aggregating, addition etc.

To handle the incremental MapReduce functionality (that is, updating an existing view), each function must also be able to handle and consume it's own output. In an incremental situation, the function must handle both new records and previously computed reductions.

The input to reduce function can be not only raw data from the map phase but also output of a previous reduce phase. This...