番石榴供应商级包含MemoizingSupplier:
static class MemoizingSupplier<T> implements Supplier<T>, Serializable {
final Supplier<T> delegate;
transient volatile boolean initialized;
// "value" does not need to be volatile; visibility piggy-backs
// on volatile read of "initialized".
transient T value;
MemoizingSupplier(Supplier<T> delegate) {
this.delegate = delegate;
}
@Override public T get() {
// A 2-field variant of Double Checked Locking.
if (!initialized) {
synchronized (this) {
if (!initialized) {
T t = delegate.get();
value = t;
initialized = true;
return t;
}
}
}
return value; …Run Code Online (Sandbox Code Playgroud) 如何获得CQL查询的执行计划(或类似的smth)?我找不到任何关于CQL查询优化/执行的整合文档.
例如,我想知道,执行查询有什么不同,例如:
select some_column from SOME_TABLE where
pkField='val1'
and timestampField='date'
allow filtering;
Run Code Online (Sandbox Code Playgroud)
和
select some_column from SOME_TABLE where
pkField='val1'
and timestampField<='date'
and timestampField>='date'
allow filtering;
Run Code Online (Sandbox Code Playgroud) 问题就在这里。我有mongos连接到远程的本地实例mongod。远程数据库使用基本密码身份验证。我正在尝试使用简单的 Scala 应用程序为特定集合设置 ChangeStream 观察器。实际的代码如下所示:
private val mongo = new MongoClient(
new ServerAddress("localhost", 27017),
MongoCredential.createCredential("username", "myDB", "password".toCharArray),
MongoClientOptions.builder().addServerListener(ServerStateListener).build()
)
private val collection = mongo
.getDatabase(DB)
.getCollection("someObjectsCollection")
private val ch = collection
.watch()
.fullDocument(FullDocument.UPDATE_LOOKUP)
.iterator()
Run Code Online (Sandbox Code Playgroud)
它断线.fullDocument(FullDocument.UPDATE_LOOKUP)告诉:
Exception in thread "main" com.mongodb.MongoCommandException: Command failed with error 13: 'not authorized on myDB to execute command { aggregate: "someObjectsCollection", pipeline: [ { $changeStream: { fullDocument: "updateLookup" } } ], cursor: {}, $db: "myDB", $clusterTime: { clusterTime: Timestamp(1524064297, 2), …Run Code Online (Sandbox Code Playgroud)