Skip to content

Instantly share code, notes, and snippets.

@mschoch
mschoch / couchbase-build.xml
Created August 16, 2011 19:03
An Ant build script to assist in adding Mobile Couchbase to your Android project
<?xml version="1.0" encoding="UTF-8"?>
<project name="couchbase-build" default="help">
<property file="build.properties" />
<target name="help">
<echo>
To use this script, please set the property android.couchbase.dir in your build.properties file to
point to the location you installed Android-Couchbase.
@mschoch
mschoch / gist:2783344
Created May 24, 2012 18:32
Integer Key Testcase
public void testIntegerKeyInView() {
String filesDir = getContext().getFilesDir().getAbsolutePath();
TDDatabase db = TDDatabase.createEmptyDBAtPath(filesDir + "/touch_couch_test.sqlite3");
List<String> testStringIntValues = new ArrayList<String>();
testStringIntValues.add("53");
testStringIntValues.add("35305");
testStringIntValues.add("2090");
This is working as expected...
irb(main):006:0> ma = Article.find(100643)
=> #<Article id: 100643>
irb(main):009:0> ma.contributors
=> [{"name"=>"Gproud", "timestamp"=>"2012-09-20T13:05:27Z"}]
However, when I get an article using a view...
Build options to query for specific author, set to include docs...
irb(main):008:0* opt = { :startkey => ["EmausBot", ""], :endkey => ["EmausBot", "\u9999"], :reduce => false, :include_docs =>true}
=> {:startkey=>["EmausBot", ""], :endkey=>["EmausBot", "香"], :reduce=>false, :include_docs=>true}
Now query with those options
irb(main):009:0> Article.by_author(opt).entries
=> [#<Article id: 11897520>, #<Article id: 13251428>, #<Article id: 13389397>, #<Article id: 1410592>, #<Article id: 1480853>, #<Article id: 15176975>, #<Article id: 15504795>, #<Article id: 18996339>, #<Article id: 19012194>, #<Article id: 20151985>, #<Article id: 2018930>, #<Article id: 25575962>, #<Article id: 25615649>, #<Article id: 2568917>, #<Article id: 25879895>, #<Article id: 2733855>, #<Article id: 27550365>, #<Article id: 2860125>, #<Article id: 3559860>, #<Article id: 363145>, #<Article id: 3728186>, #<Article id: 4450579>, #<Article id: 448686>, #<Article id: 6826539>, #<Article id: 72394>, #<Article id: 9193832>]
irb(main):034:0> Article.by_author(opt).entries
=> [#<Article id: 11897520>, #<Article id: 13251428>, #<Article id: 13389397>, #<Article id: 1410592>, #<Article id: 1480853>, #<Article id: 15176975>, #<Article id: 15504795>, #<Article id: 18996339>, #<Article id: 19012194>, #<Article id: 20151985>, #<Article id: 2018930>, #<Article id: 25575962>, #<Article id: 25615649>, #<Article id: 2568917>, #<Article id: 25879895>, #<Article id: 2733855>, #<Article id: 27550365>, #<Article id: 2860125>, #<Article id: 3559860>, #<Article id: 363145>, #<Article id: 3728186>, #<Article id: 4450579>, #<Article id: 448686>, #<Article id: 6826539>, #<Article id: 72394>, #<Article id: 9193832>]
irb(main):035:0> Article.by_author(opt).entries.first
=> #<Article id: 11897520>
irb(main):036:0> Article.by_author(opt).entries.first.doc
=> nil
irb(main):037:0> Article.by_author(opt).entries.first.value
=> nil
irb(main):038:0> Article.by_author(opt).entries.first.as_json
=> {"id"=>"11897520", "key"=>["EmausBot", "11897520"], "value"=>n
[marty@cen-1701 testrunner]$ python testrunner -i couchbase-elasticsearch.ini -c es.conf
/usr/lib64/python2.6/site-packages/Crypto/Util/randpool.py:40: RandomPool_DeprecationWarning: This application uses RandomPool, which is BROKEN in older releases. See http://www.pycrypto.org/randpool-broken
RandomPool_DeprecationWarning)
filename:es.conf
[Global Test input params]
{'cluster_name': 'couchbase-elasticsearch', 'num_nodes': 3, 'ini': 'couchbase-elasticsearch.ini', 'conf_file': 'es.conf', 'spec': 'es'}
./testrunner -i couchbase-elasticsearch.ini -t rebalance.rebalanceout.RebalanceOutTests.rebalance_out_with_ops,nodes_init=3,nodes_out=2,replicas=1,items=20000,doc_ops=create;update;delete
[Test Input params] : {'replicas': '1', 'doc_ops': 'create;update;delete', 'items': '20000', 'case_number': 1, 'conf_file': 'es.conf', 'num_nodes': 3, 'cluster_name': 'couchbase-elasticsearch', 'ini': 'couchbase-elasticsearch.ini', 'nodes_out': '2', 'spec': 'es', 'nodes_init': '3'}
rebalance_out_with_ops (rebalance.rebal
2012-11-19 10:55:02,149 - root - INFO - creating direct client 10.5.2.12:11210 default
2012-11-19 10:55:02,451 - root - INFO - Saw ep_queue_size 0 == 0 expected on '10.5.2.12:8091'
2012-11-19 10:55:02,471 - root - INFO - creating direct client 10.5.2.12:11210 default
2012-11-19 10:55:02,791 - root - INFO - Saw ep_flusher_todo 0 == 0 expected on '10.5.2.12:8091'
2012-11-19 10:55:03,040 - root - INFO - creating direct client 10.5.2.12:11210 default
2012-11-19 10:55:03,341 - root - INFO - 29999 items will be verified on default bucket
2012-11-19 10:55:03,793 - root - INFO - 0 items were verified
2012-11-19 10:55:09,572 - root - INFO - 10000 items were verified
2012-11-19 10:55:16,016 - root - INFO - 20000 items were verified
2012-11-19 10:55:21,710 - root - INFO - 29999 items were verified in 18.3692748547 sec.the average number of ops - 1633.10719534 per second
@mschoch
mschoch / gist:4774593
Last active December 12, 2015 12:49
Snippet: BASH: for loop
#!/bin/bash
for (( i=1; i <= 5; i++ ))
do
echo "Random number $i: $RANDOM"
done
{
"mappings": {
"couchbaseDocument": {
"properties": {
"doc": {
"properties": {
"city": {
"type": "string",
"index": "not_analyzed"
}
@mschoch
mschoch / elasticsearch-couchbase-cbugg.Dockerfile
Last active January 13, 2016 16:12
Dockerfile for elasticsearch-couchbase (cbugg specific build)
FROM dustin/tiny
MAINTAINER Marty Schoch "[email protected]"
ADD https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.2.deb /tmp/elasticsearch-0.20.2.deb
RUN apt-get update
RUN apt-get install -y openjdk-7-jre-headless
RUN dpkg -i /tmp/elasticsearch-0.20.2.deb
RUN rm /tmp/elasticsearch-0.20.2.deb