Skip to content

Instantly share code, notes, and snippets.

package org.testcontainers.couchbase;
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.CouchbaseCluster;
import com.couchbase.client.java.document.JsonDocument;
import com.couchbase.client.java.document.json.JsonObject;
import com.couchbase.client.java.env.CouchbaseEnvironment;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
import org.junit.ClassRule;
> cbq -u Administrator -p password --script "select * from `travel-sample` limit 10" -q | from-json | get results.travel-sample | sort-by name
━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━┯━━━━━━┯━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━
callsign │ country │ iata │ icao │ id │ name │ type
──────────┼───────────────┼──────┼──────┼────┼─────────────┼─────────
MILE-AIR │ United States │ Q5 │ MLA │ 10 │ 40-Mile Air │ airline
━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━┷━━━━━━┷━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━
> cbq -u Administrator -p password --script "select * from `travel-sample` limit 10" -q | from-json | get results | get travel-sample | sort-by name
━━━┯━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━┯━━━━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━
# │ callsign │ country │ iata │ icao │ id │ name │ type
/**
* Copyright (C) 2014 Couchbase, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@daschl
daschl / samples.py
Created August 22, 2016 07:07
Couchbase Spark Samples
// Start the Shell
./pyspark --packages com.couchbase.client:spark-connector_2.10:1.2.1 --conf "spark.couchbase.bucket.travel-sample="
// Create a DF
>>> df = sqlContext.read.format("com.couchbase.spark.sql.DefaultSource").option("schemaFilter", "type=\"airline\"").load()
// Print the Schema
>>> df.printSchema()
root
<ul id="results-list" className="list-group">
{
this.state.responses.map((item, key) => {
if (item.success) {
<li key={key} className="list-group-item list-group-item-success">
<pre>{JSON.stringify(item, null, 2)}</pre>
</li>
} else {
<li key={key} className="list-group-item list-group-item-success">bla</li>
}
plugins {
id 'scala'
id 'maven-publish'
}
repositories {
mavenCentral()
jcenter()
}
/*
* Copyright (c) 2018 Couchbase, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@daschl
daschl / couchbase-php-2pc-advanced.php
Created July 21, 2012 12:57
Advanced Couchbase 2PC PHP Implementation
<?php
/**
* A more general PHP two-phase commit implementation.
*
* This assumes that we run on 5.3 or later.
*/
class TransactionException extends Exception {}
/**
// --- Collection API ---
// full doc fetch
Optional<Document> doc = collection.get("id");
// full doc fetch, turns into subdoc actually
Optional<Document> doc = collection.get("id", getOptions().withExpiration(true));
// full doc insert (since we now return a doc, let's take a document!)
collection.insert(
package com.couchbase.testcontainers;
import org.jetbrains.annotations.NotNull;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.WaitStrategy;
import org.testcontainers.images.builder.ImageFromDockerfile;
import org.testcontainers.images.builder.dockerfile.DockerfileBuilder;
import java.util.Arrays;
import java.util.Collection;