/* * __curfile_reset -- * WT_CURSOR->reset method for the btree cursor type. */ static int __curfile_reset(WT_CURSOR *cursor) { WT_CURSOR_BTREE *cbt; WT_DECL_RET; WT_SESSION_IMPL *session; cbt = (WT_CURSOR_BTREE *)cursor; CURSOR_API_CALL(cursor, session, reset, cbt->btree); ret = __wt_btcur_reset(cbt); err: API_END(session); return (ret); }
/* * __curfile_search_near -- * WT_CURSOR->search_near method for the btree cursor type. */ static int __curfile_search_near(WT_CURSOR *cursor, int *exact) { WT_CURSOR_BTREE *cbt; WT_DECL_RET; WT_SESSION_IMPL *session; cbt = (WT_CURSOR_BTREE *)cursor; CURSOR_API_CALL(cursor, session, search_near, cbt->btree); WT_CURSOR_NEEDKEY(cursor); ret = __wt_btcur_search_near(cbt, exact); err: API_END(session); return (ret); }
/* * __curds_prev -- * WT_CURSOR.prev method for the data-source cursor type. */ static int __curds_prev(WT_CURSOR *cursor) { WT_DECL_RET; WT_SESSION_IMPL *session; CURSOR_API_CALL(cursor, session, prev, NULL); WT_ERR(cursor->data_source->prev(cursor->data_source)); __curds_key_get(cursor); __curds_value_get(cursor); err: API_END(session); return (ret); }
/* * __curds_search_near -- * WT_CURSOR.search_near method for the data-source cursor type. */ static int __curds_search_near(WT_CURSOR *cursor, int *exact) { WT_DECL_RET; WT_SESSION_IMPL *session; CURSOR_API_CALL(cursor, session, search_near, NULL); WT_ERR(__curds_key_set(cursor)); WT_ERR(cursor->data_source->search_near(cursor->data_source, exact)); __curds_key_get(cursor); __curds_value_get(cursor); err: API_END(session); return (ret); }
/* * __session_rollback_transaction -- * WT_SESSION->rollback_transaction method. */ static int __session_rollback_transaction(WT_SESSION *wt_session, const char *config) { WT_DECL_RET; WT_SESSION_IMPL *session; session = (WT_SESSION_IMPL *)wt_session; SESSION_API_CALL(session, rollback_transaction, config, cfg); WT_CSTAT_INCR(session, txn_rollback); WT_TRET(__session_reset_cursors(session)); WT_TRET(__wt_txn_rollback(session, cfg)); err: API_END(session); return (ret); }
/* * __curfile_close -- * WT_CURSOR->close method for the btree cursor type. */ static int __curfile_close(WT_CURSOR *cursor) { WT_CURSOR_BTREE *cbt; WT_DECL_RET; WT_SESSION_IMPL *session; cbt = (WT_CURSOR_BTREE *)cursor; CURSOR_API_CALL(cursor, session, close, cbt->btree); WT_TRET(__wt_btcur_close(cbt)); if (session->btree != NULL) WT_TRET(__wt_session_release_btree(session)); /* The URI is owned by the btree handle. */ cursor->uri = NULL; WT_TRET(__wt_cursor_close(cursor)); API_END(session); return (ret); }
/* * __curbulk_insert -- * WT_CURSOR->insert for the bulk cursor type. */ static int __curbulk_insert(WT_CURSOR *cursor) { WT_BTREE *btree; WT_CURSOR_BULK *cbulk; WT_SESSION_IMPL *session; int ret; cbulk = (WT_CURSOR_BULK *)cursor; btree = cbulk->cbt.btree; CURSOR_API_CALL(cursor, session, insert, btree); if (btree->type == BTREE_ROW) WT_CURSOR_NEEDKEY(cursor); WT_CURSOR_NEEDVALUE(cursor); WT_ERR(__wt_bulk_insert(cbulk)); err: API_END(session); return (ret); }
/* * __conn_reconfigure -- * WT_CONNECTION->reconfigure method. */ static int __conn_reconfigure(WT_CONNECTION *wt_conn, const char *config) { WT_CONFIG_ITEM cval; WT_CONNECTION_IMPL *conn; WT_DECL_RET; WT_SESSION_IMPL *session; /* * Special version of cfg that doesn't include the default config: used * to limit changes to values that the application sets explicitly. * Note that any function using this value has to be prepared to handle * not-found as a valid option return. */ const char *raw_cfg[] = { config, NULL }; conn = (WT_CONNECTION_IMPL *)wt_conn; CONNECTION_API_CALL(conn, session, reconfigure, config, cfg); /* Turning on statistics clears any existing values. */ if ((ret = __wt_config_gets(session, raw_cfg, "statistics", &cval)) == 0) { conn->statistics = cval.val == 0 ? 0 : 1; if (conn->statistics) __wt_stat_clear_connection_stats(&conn->stats); } WT_ERR_NOTFOUND_OK(ret); WT_ERR(__wt_conn_cache_pool_config(session, cfg)); WT_ERR(__wt_cache_config(conn, raw_cfg)); WT_ERR(__conn_verbose_config(session, raw_cfg)); /* Wake up the cache pool server so any changes are noticed. */ if (F_ISSET(conn, WT_CONN_CACHE_POOL)) WT_ERR(__wt_cond_signal( session, __wt_process.cache_pool->cache_pool_cond)); err: API_END(session); return (ret); }
/* * __curmetadata_close -- * WT_CURSOR->close method for the metadata cursor type. */ static int __curmetadata_close(WT_CURSOR *cursor) { WT_CURSOR *file_cursor; WT_CURSOR_METADATA *mdc; WT_DECL_RET; WT_SESSION_IMPL *session; mdc = (WT_CURSOR_METADATA *)cursor; file_cursor = mdc->file_cursor; CURSOR_API_CALL(cursor, session, close, ((WT_CURSOR_BTREE *)file_cursor)->btree); ret = file_cursor->close(file_cursor); WT_ERR(__wt_cursor_close(cursor)); err: API_END(session, ret); return (ret); }
/* * __curbulk_close -- * WT_CURSOR->close for the bulk cursor type. */ static int __curbulk_close(WT_CURSOR *cursor) { WT_BTREE *btree; WT_CURSOR_BULK *cbulk; WT_SESSION_IMPL *session; int ret; cbulk = (WT_CURSOR_BULK *)cursor; btree = cbulk->cbt.btree; CURSOR_API_CALL(cursor, session, close, btree); WT_TRET(__wt_bulk_end(cbulk)); if (session->btree != NULL) WT_TRET(__wt_session_release_btree(session)); /* The URI is owned by the btree handle. */ cursor->uri = NULL; WT_TRET(__wt_cursor_close(cursor)); API_END(session); return (ret); }
/* * __session_begin_transaction -- * WT_SESSION->begin_transaction method. */ static int __session_begin_transaction(WT_SESSION *wt_session, const char *config) { WT_DECL_RET; WT_SESSION_IMPL *session; session = (WT_SESSION_IMPL *)wt_session; SESSION_API_CALL(session, begin_transaction, config, cfg); WT_CSTAT_INCR(session, txn_begin); if (!F_ISSET(S2C(session), WT_CONN_TRANSACTIONAL)) WT_ERR_MSG(session, EINVAL, "Database not configured for transactions"); if (F_ISSET(&session->txn, TXN_RUNNING)) WT_ERR_MSG(session, EINVAL, "Transaction already running"); WT_ERR(__session_reset_cursors(session)); ret = __wt_txn_begin(session, cfg); err: API_END(session); return (ret); }
/* * __curds_close -- * WT_CURSOR.close method for the data-source cursor type. */ static int __curds_close(WT_CURSOR *cursor) { WT_DECL_RET; WT_SESSION_IMPL *session; CURSOR_API_CALL(cursor, session, close, NULL); if (cursor->data_source != NULL) ret = cursor->data_source->close(cursor->data_source); /* * The key/value formats are in allocated memory, which isn't standard * behavior. */ __wt_free(session, cursor->key_format); __wt_free(session, cursor->value_format); WT_TRET(__wt_cursor_close(cursor)); err: API_END(session); return (ret); }
/* * __curmetadata_reset -- * WT_CURSOR->reset method for the metadata cursor type. */ static int __curmetadata_reset(WT_CURSOR *cursor) { WT_CURSOR *file_cursor; WT_CURSOR_METADATA *mdc; WT_DECL_RET; WT_SESSION_IMPL *session; mdc = (WT_CURSOR_METADATA *)cursor; file_cursor = mdc->file_cursor; CURSOR_API_CALL(cursor, session, reset, ((WT_CURSOR_BTREE *)file_cursor)->btree); if (F_ISSET(mdc, WT_MDC_POSITIONED) && !F_ISSET(mdc, WT_MDC_ONMETADATA)) ret = file_cursor->reset(file_cursor); F_CLR(mdc, WT_MDC_POSITIONED | WT_MDC_ONMETADATA); F_CLR(cursor, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET); err: API_END(session, ret); return (ret); }
/* * __curmetadata_compare -- * WT_CURSOR->compare method for the metadata cursor type. */ static int __curmetadata_compare(WT_CURSOR *a, WT_CURSOR *b, int *cmpp) { WT_CURSOR *a_file_cursor, *b_file_cursor; WT_CURSOR_METADATA *a_mdc, *b_mdc; WT_DECL_RET; WT_SESSION_IMPL *session; a_mdc = ((WT_CURSOR_METADATA *)a); b_mdc = ((WT_CURSOR_METADATA *)b); a_file_cursor = a_mdc->file_cursor; b_file_cursor = b_mdc->file_cursor; CURSOR_API_CALL(a, session, compare, ((WT_CURSOR_BTREE *)a_file_cursor)->btree); if (b->compare != __curmetadata_compare) WT_ERR_MSG(session, EINVAL, "Can only compare cursors of the same type"); WT_MD_CURSOR_NEEDKEY(a); WT_MD_CURSOR_NEEDKEY(b); if (F_ISSET(a_mdc, WT_MDC_ONMETADATA)) { if (F_ISSET(b_mdc, WT_MDC_ONMETADATA)) *cmpp = 0; else *cmpp = 1; } else if (F_ISSET(b_mdc, WT_MDC_ONMETADATA)) *cmpp = -1; else ret = a_file_cursor->compare( a_file_cursor, b_file_cursor, cmpp); err: API_END(session, ret); return (ret); }
/* * __curbulk_insert -- * WT_CURSOR->insert for the bulk cursor type. */ static int __curbulk_insert(WT_CURSOR *cursor) { WT_BTREE *btree; WT_CURSOR_BULK *cbulk; WT_DECL_RET; WT_SESSION_IMPL *session; cbulk = (WT_CURSOR_BULK *)cursor; btree = cbulk->cbt.btree; /* * Bulk cursor inserts are updates, but don't need auto-commit * transactions because they are single-threaded and not visible until * the bulk cursor is closed. */ CURSOR_API_CALL(cursor, session, insert, btree); if (btree->type == BTREE_ROW) WT_CURSOR_NEEDKEY(cursor); WT_CURSOR_NEEDVALUE(cursor); WT_ERR(__wt_bulk_insert(cbulk)); err: API_END(session); return (ret); }
/* * __curmetadata_remove -- * WT_CURSOR->remove method for the metadata cursor type. */ static int __curmetadata_remove(WT_CURSOR *cursor) { WT_CURSOR *file_cursor; WT_CURSOR_METADATA *mdc; WT_DECL_RET; WT_SESSION_IMPL *session; mdc = (WT_CURSOR_METADATA *)cursor; file_cursor = mdc->file_cursor; CURSOR_API_CALL(cursor, session, remove, ((WT_CURSOR_BTREE *)file_cursor)->btree); WT_MD_CURSOR_NEEDKEY(cursor); /* * Since the key format is 's' the WT_ITEM must contain a NULL * terminated string. */ ret = __wt_metadata_remove(session, cursor->key.data); err: API_END(session, ret); return (ret); }
// // Fin // template<typename T> INLINE_FUNC void RandomUniform_Apply(UniformGenerator* rng, TensorRef* result, float min, float max) { auto func = [rng, min, max](T *r) { *r = (T)ScalarUniform(rng, min, max); }; Apply1<T>(result, func); } int TS_RandomUniform(UniformGenerator* rng, TensorRef* result, float min, float max) { API_BEGIN() SWITCH_TENSOR_TYPE_FLOAT(result->elementType, RandomUniform_Apply, rng, result, min, max) API_END() } template<typename T> INLINE_FUNC void RandomNormal_Apply(UniformGenerator* rng, TensorRef* result, float mean, float stdv) { auto func = [rng, mean, stdv](T *r) { *r = (T)ScalarNormal(rng, mean, stdv); }; Apply1<T>(result, func); } int TS_RandomNormal(UniformGenerator* rng, TensorRef* result, float mean, float stdv) { API_BEGIN() SWITCH_TENSOR_TYPE_FLOAT(result->elementType, RandomNormal_Apply, rng, result, mean, stdv) API_END()
#include "TensorIter-inl.h" #include "TensorApply-inl.h" template<typename T> INLINE_FUNC void Fill_Apply(TensorRef* result, float value) { auto func = [value](T *r) { *r = (T)value; }; Apply1<T>(result, func); } int TS_Fill(TensorRef* result, float value) { API_BEGIN() SWITCH_TENSOR_TYPE_ALL_CPU(result->elementType, Fill_Apply, result, value) API_END() } template<typename TResult, typename TSrc> INLINE_FUNC void Copy_Apply(TensorRef* result, TensorRef* src) { auto func = [](TResult *r, TSrc *s) { *r = (TResult)*s; }; Apply2<TResult, TSrc>(result, src, func); } template<typename TResult> INLINE_FUNC void Copy_ToResult(TensorRef* result, TensorRef* src) {