本文整理汇总了Golang中github.com/couchbase/query/errors.NewSystemDatastoreError函数的典型用法代码示例。如果您正苦于以下问题:Golang NewSystemDatastoreError函数的具体用法?Golang NewSystemDatastoreError怎么用?Golang NewSystemDatastoreError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewSystemDatastoreError函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Scan
func (pi *keyspaceIndex) Scan(requestId string, span *datastore.Span, distinct bool, limit int64,
cons datastore.ScanConsistency, vector timestamp.Vector, conn *datastore.IndexConnection) {
defer close(conn.EntryChannel())
val := ""
a := span.Seek[0].Actual()
switch a := a.(type) {
case string:
val = a
default:
conn.Error(errors.NewSystemDatastoreError(nil, fmt.Sprintf("Invalid seek value %v of type %T.", a, a)))
return
}
ids := strings.SplitN(val, "/", 2)
if len(ids) != 2 {
return
}
namespace, _ := pi.keyspace.namespace.store.actualStore.NamespaceById(ids[0])
if namespace == nil {
return
}
keyspace, _ := namespace.KeyspaceById(ids[1])
if keyspace != nil {
entry := datastore.IndexEntry{PrimaryKey: fmt.Sprintf("%s/%s", namespace.Id(), keyspace.Id())}
conn.EntryChannel() <- &entry
}
}
示例2: Count
func (b *namespaceKeyspace) Count() (int64, errors.Error) {
namespaceIds, excp := b.namespace.store.actualStore.NamespaceIds()
if excp == nil {
return int64(len(namespaceIds)), nil
}
return 0, errors.NewSystemDatastoreError(excp, "")
}
示例3: fetchOne
func (b *storeKeyspace) fetchOne(key string) (value.AnnotatedValue, errors.Error) {
if key == b.namespace.store.actualStore.Id() {
doc := value.NewAnnotatedValue(map[string]interface{}{
"id": b.namespace.store.actualStore.Id(),
"url": b.namespace.store.actualStore.URL(),
})
return doc, nil
}
return nil, errors.NewSystemDatastoreError(nil, "Key Not Found "+key)
}
示例4: Count
func (b *keyspaceKeyspace) Count() (int64, errors.Error) {
count := int64(0)
namespaceIds, excp := b.namespace.store.actualStore.NamespaceIds()
if excp == nil {
for _, namespaceId := range namespaceIds {
namespace, excp := b.namespace.store.actualStore.NamespaceById(namespaceId)
if excp == nil {
keyspaceIds, excp := namespace.KeyspaceIds()
if excp == nil {
count += int64(len(keyspaceIds))
} else {
return 0, errors.NewSystemDatastoreError(excp, "")
}
} else {
return 0, errors.NewSystemDatastoreError(excp, "")
}
}
return count, nil
}
return 0, errors.NewSystemDatastoreError(excp, "")
}
示例5: fetchOne
func (b *namespaceKeyspace) fetchOne(key string) (value.AnnotatedValue, errors.Error) {
namespace, excp := b.namespace.store.actualStore.NamespaceById(key)
if namespace != nil {
doc := value.NewAnnotatedValue(map[string]interface{}{
"id": namespace.Id(),
"name": namespace.Name(),
"datastore_id": b.namespace.store.actualStore.Id(),
})
return doc, nil
}
return nil, errors.NewSystemDatastoreError(excp, "Key Not Found "+key)
}
示例6: ScanEntries
func (pi *indexIndex) ScanEntries(requestId string, limit int64, cons datastore.ScanConsistency,
vector timestamp.Vector, conn *datastore.IndexConnection) {
defer close(conn.EntryChannel())
// eliminate duplicate keys
keys := make(map[string]string, 64)
actualStore := pi.keyspace.namespace.store.actualStore
namespaceIds, err := actualStore.NamespaceIds()
if err == nil {
for _, namespaceId := range namespaceIds {
namespace, err := actualStore.NamespaceById(namespaceId)
if err == nil {
keyspaceIds, err := namespace.KeyspaceIds()
if err == nil {
for _, keyspaceId := range keyspaceIds {
keyspace, err := namespace.KeyspaceById(keyspaceId)
if err == nil {
indexers, err := keyspace.Indexers()
if err == nil {
for _, indexer := range indexers {
err = indexer.Refresh()
if err != nil {
logging.Errorf("Refreshing indexes failed %v", err)
conn.Error(errors.NewSystemDatastoreError(err, ""))
// don't return here but continue processing, because other keyspaces may still be responsive. MB-15834
continue
}
indexIds, err := indexer.IndexIds()
if err == nil {
for _, indexId := range indexIds {
key := fmt.Sprintf("%s/%s/%s", namespaceId, keyspaceId, indexId)
keys[key] = key
}
}
}
}
}
}
}
}
}
}
for k, _ := range keys {
entry := datastore.IndexEntry{PrimaryKey: k}
conn.EntryChannel() <- &entry
}
}
示例7: ScanEntries
func (pi *indexIndex) ScanEntries(requestId string, limit int64, cons datastore.ScanConsistency,
vector timestamp.Vector, conn *datastore.IndexConnection) {
defer close(conn.EntryChannel())
// eliminate duplicate keys
keys := make(map[string]string, 64)
actualStore := pi.keyspace.namespace.store.actualStore
namespaceIds, err := actualStore.NamespaceIds()
if err == nil {
for _, namespaceId := range namespaceIds {
namespace, err := actualStore.NamespaceById(namespaceId)
if err == nil {
keyspaceIds, err := namespace.KeyspaceIds()
if err == nil {
for _, keyspaceId := range keyspaceIds {
keyspace, err := namespace.KeyspaceById(keyspaceId)
if err == nil {
indexers, err := keyspace.Indexers()
if err == nil {
for _, indexer := range indexers {
err = indexer.Refresh()
if err != nil {
conn.Error(errors.NewSystemDatastoreError(err, ""))
return
}
indexIds, err := indexer.IndexIds()
if err == nil {
for _, indexId := range indexIds {
key := fmt.Sprintf("%s/%s/%s", namespaceId, keyspaceId, indexId)
keys[key] = key
}
}
}
}
}
}
}
}
}
}
for k, _ := range keys {
entry := datastore.IndexEntry{PrimaryKey: k}
conn.EntryChannel() <- &entry
}
}
示例8: Count
func (b *indexKeyspace) Count() (int64, errors.Error) {
count := int64(0)
namespaceIds, excp := b.namespace.store.actualStore.NamespaceIds()
if excp == nil {
for _, namespaceId := range namespaceIds {
namespace, excp := b.namespace.store.actualStore.NamespaceById(namespaceId)
if excp == nil {
keyspaceIds, excp := namespace.KeyspaceIds()
if excp == nil {
for _, keyspaceId := range keyspaceIds {
keyspace, excp := namespace.KeyspaceById(keyspaceId)
if excp == nil {
indexers, excp := keyspace.Indexers()
if excp == nil {
for _, indexer := range indexers {
excp = indexer.Refresh()
if excp != nil {
return 0, errors.NewSystemDatastoreError(excp, "")
}
indexIds, excp := indexer.IndexIds()
if excp == nil {
count += int64(len(indexIds))
} else {
return 0, errors.NewSystemDatastoreError(excp, "")
}
}
} else {
return 0, errors.NewSystemDatastoreError(excp, "")
}
} else {
return 0, errors.NewSystemDatastoreError(excp, "")
}
}
} else {
return 0, errors.NewSystemDatastoreError(excp, "")
}
} else {
return 0, errors.NewSystemDatastoreError(excp, "")
}
}
return count, nil
}
return 0, errors.NewSystemDatastoreError(excp, "")
}
示例9: Scan
func (pi *dualIndex) Scan(requestId string, span *datastore.Span, distinct bool, limit int64,
cons datastore.ScanConsistency, vector timestamp.Vector, conn *datastore.IndexConnection) {
defer close(conn.EntryChannel())
val := ""
a := span.Seek[0].Actual()
switch a := a.(type) {
case string:
val = a
default:
conn.Error(errors.NewSystemDatastoreError(nil, fmt.Sprintf("Invalid seek value %v of type %T.", a, a)))
return
}
if strings.EqualFold(val, KEYSPACE_NAME_DUAL) {
entry := datastore.IndexEntry{PrimaryKey: KEYSPACE_NAME_DUAL}
conn.EntryChannel() <- &entry
}
}
示例10: Delete
func (b *dualKeyspace) Delete(deletes []string) ([]string, errors.Error) {
return nil, errors.NewSystemDatastoreError(nil, "Mutations not allowed on system:dual.")
}
示例11: Upsert
func (b *dualKeyspace) Upsert(upserts []datastore.Pair) ([]datastore.Pair, errors.Error) {
return nil, errors.NewSystemDatastoreError(nil, "Mutations not allowed on system:dual.")
}