Ejemplo n.º 1
0
        /// <inheritdoc />
        public Task <long> GetReadVersionAsync(CancellationToken ct)
        {
            var future = FdbNative.TransactionGetReadVersion(m_handle);

            return(FdbFuture.CreateTaskFromHandle(future,
                                                  (h) =>
            {
                long version;
                var err = Fdb.BindingVersion < 620
                                                ? FdbNative.FutureGetVersion(h, out version)
                                                : FdbNative.FutureGetInt64(h, out version);
#if DEBUG_TRANSACTIONS
                Debug.WriteLine("FdbTransaction[" + m_id + "].GetReadVersion() => err=" + err + ", version=" + version);
#endif
                Fdb.DieOnError(err);
                return version;
            },
                                                  ct
                                                  ));
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public Task <long> GetApproximateSizeAsync(CancellationToken ct)
        {
            // API was introduced in 6.2
            if (Fdb.ApiVersion < 620)
            {
                throw new NotSupportedException($"The GetApproximateSize method is only available for version 6.2 or greater. Your application has selected API version {Fdb.ApiVersion} which is too low. You willl need to select API version 620 or greater.");
            }
            //TODO: for lesser version, maybe we could return our own estimation?

            var future = FdbNative.TransactionGetReadVersion(m_handle);

            return(FdbFuture.CreateTaskFromHandle(future,
                                                  (h) =>
            {
                var err = FdbNative.FutureGetInt64(h, out long size);
#if DEBUG_TRANSACTIONS
                Debug.WriteLine("FdbTransaction[" + m_id + "].GetApproximateSize() => err=" + err + ", size=" + size);
#endif
                Fdb.DieOnError(err);
                return size;
            },
                                                  ct
                                                  ));
        }