This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from couchbase import Couchbase | |
cb = Couchbase.connect(bucket='beer-sample') | |
hasRow = True | |
rowPerPage = 5 | |
page = 0 | |
currentStartkey="" | |
startDocId="" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from couchbase import Couchbase | |
cb = Couchbase.connect(bucket='beer-sample') | |
hasRow = True | |
rowPerPage = 5 | |
page = 0 | |
currentStartkey="" | |
startDocId="" | |
while hasRow : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
Object o = cb.get("query-result-001"); | |
if (o == null) { | |
View view = cb.getView("brewery", "by_name"); | |
Query query = new Query(); | |
query.setLimit(100); | |
Map<String, String> result = new HashMap<String,String>(); | |
ViewResponse viewResponse = cb.query(view, query); | |
for (ViewRow row : viewResponse) { | |
result.put(row.getId(), row.getKey()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.couchbase.sample; | |
import com.couchbase.client.CouchbaseClient; | |
import com.google.gson.Gson; | |
import java.net.URI; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.UUID; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.couchbase.devday; | |
import com.couchbase.client.CouchbaseClient; | |
import javax.imageio.ImageIO; | |
import java.awt.image.BufferedImage; | |
import java.io.ByteArrayInputStream; | |
import java.io.ByteArrayOutputStream; | |
import java.io.File; | |
import java.io.InputStream; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(doc, meta) { | |
switch(doc.type) { | |
case "brewery": | |
emit([meta.id, 0, doc.name]); | |
break; | |
case "beer": | |
if (doc.name && doc.brewery_id) { | |
emit([doc.brewery_id, 1, doc.name], null); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
View view = client.getView("brewery", "all_with_beers"); | |
Query query = new Query(); | |
query.setIncludeDocs(true).setLimit(100); | |
ViewResponse result = client.query(view, query); | |
ArrayList<HashMap<String, String>> items = | |
new ArrayList<HashMap<String, String>>(); | |
for(ViewRow row : result) { | |
HashMap<String, String> parsedDoc = gson.fromJson( | |
(String)row.getDocument(), HashMap.class); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import | |
import com.couchbase.client.CouchbaseClient; | |
... | |
... | |
List<URI> uris = new LinkedList<URI>(); | |
uris.add(URI.create("http://127.0.0.1:8091/pools")); | |
CouchbaseClient client = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<dependencies> | |
<dependency> | |
<groupId>com.couchbase.client</groupId> | |
<artifactId>couchbase-client</artifactId> | |
<version>1.2.3</version> | |
</dependency> | |
</dependencies> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.couchbase.demo; | |
import com.couchbase.client.CouchbaseClient; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
import twitter4j.*; | |
import twitter4j.json.DataObjectFactory; | |
import java.io.InputStream; |
NewerOlder