mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-12 07:14:23 +00:00
Merge pull request #1899 from realm/kneth/revert-computeSize
Revert computeSize
This commit is contained in:
commit
f9ab01e604
@ -10,7 +10,6 @@ X.Y.Z Release notes
|
||||
* None.
|
||||
|
||||
### Enhancements
|
||||
* Added a method `Realm.computeSize()` that computes the aggregated size of all objects and their history (#1881).
|
||||
* Improved performance for devices which can support large address spaces.
|
||||
* [Sync] Exposed custom HTTP headers in `Realm.Configuration` (#1897).
|
||||
|
||||
|
@ -285,14 +285,6 @@ class Realm {
|
||||
*/
|
||||
compact() {}
|
||||
|
||||
/**
|
||||
* Computes the aggregated size of all objects and their history in the Realm.
|
||||
*
|
||||
* Note that this will traverse the Realm and might be expensive for large Realms.
|
||||
* @returns {number} the computed size in bytes.
|
||||
*/
|
||||
computeSize() {}
|
||||
|
||||
/**
|
||||
* Writes a compacted copy of the Realm to the given path.
|
||||
*
|
||||
@ -464,3 +456,4 @@ class Realm {
|
||||
* any object of this type from inside the same Realm, and will always be _optional_
|
||||
* (meaning it may also be assigned `null` or `undefined`).
|
||||
*/
|
||||
|
||||
|
@ -130,7 +130,6 @@ util.createMethods(Realm.prototype, objectTypes.REALM, [
|
||||
'removeListener',
|
||||
'removeAllListeners',
|
||||
'close',
|
||||
'computeSize',
|
||||
'_waitForDownload',
|
||||
'_objectForObjectId',
|
||||
]);
|
||||
|
8
lib/index.d.ts
vendored
8
lib/index.d.ts
vendored
@ -733,14 +733,6 @@ declare class Realm {
|
||||
*/
|
||||
compact(): boolean;
|
||||
|
||||
/**
|
||||
* Computes the aggregated size of all objects and their history in the Realm.
|
||||
*
|
||||
* Note that this will traverse the Realm and might be expensive for large Realms.
|
||||
* @returns {number} the computed size in bytes.
|
||||
*/
|
||||
computeSize(): number;
|
||||
|
||||
/**
|
||||
* Write a copy to destination path
|
||||
* @param path destination path
|
||||
|
@ -237,7 +237,6 @@ public:
|
||||
static void delete_model(ContextType, ObjectType, Arguments, ReturnValue &);
|
||||
static void object_for_object_id(ContextType, ObjectType, Arguments, ReturnValue&);
|
||||
static void privileges(ContextType, ObjectType, Arguments, ReturnValue&);
|
||||
static void compute_size(ContextType, ObjectType, Arguments, ReturnValue&);
|
||||
|
||||
// properties
|
||||
static void get_empty(ContextType, ObjectType, ReturnValue &);
|
||||
@ -296,7 +295,6 @@ public:
|
||||
{"writeCopyTo", wrap<writeCopyTo>},
|
||||
{"deleteModel", wrap<delete_model>},
|
||||
{"privileges", wrap<privileges>},
|
||||
{"computeSize", wrap<compute_size>},
|
||||
{"_objectForObjectId", wrap<object_for_object_id>},
|
||||
#if REALM_ENABLE_SYNC
|
||||
{"_waitForDownload", wrap<wait_for_download_completion>},
|
||||
@ -1178,13 +1176,5 @@ void RealmClass<T>::privileges(ContextType ctx, ObjectType this_object, Argument
|
||||
return_value.set(object);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void RealmClass<T>::compute_size(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) {
|
||||
args.validate_maximum(0);
|
||||
|
||||
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
||||
return_value.set(Value::from_number(ctx, realm->compute_size()));
|
||||
}
|
||||
|
||||
} // js
|
||||
} // realm
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit c12c750ecef2ba198d20ff073df05dfa2f750102
|
||||
Subproject commit 0bcb9643b8fb14323df697999b79c4a5341a8a21
|
@ -1,54 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm 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
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
'use strict';
|
||||
|
||||
const Realm = require('realm');
|
||||
const TestCase = require('./asserts');
|
||||
const schemas = require('./schemas');
|
||||
|
||||
module.exports = {
|
||||
testComputeSizeExistsAndIncreases: function() {
|
||||
const realm = new Realm({schema: [
|
||||
{ name: 'Something', properties: { numbers: 'int[]' } }
|
||||
]});
|
||||
|
||||
TestCase.assertEqual(typeof realm.computeSize, 'function');
|
||||
|
||||
const sizeInitially = realm.computeSize();
|
||||
TestCase.assertEqual(typeof sizeInitially, 'number');
|
||||
TestCase.assertTrue(sizeInitially > 0);
|
||||
|
||||
// Compact the Realm first
|
||||
realm.compact();
|
||||
|
||||
const sizeCompacted = realm.computeSize();
|
||||
TestCase.assertEqual(typeof sizeCompacted, 'number');
|
||||
TestCase.assertTrue(sizeCompacted <= sizeInitially);
|
||||
TestCase.assertTrue(sizeCompacted > 0);
|
||||
|
||||
// Add an object
|
||||
realm.write(() => {
|
||||
realm.create('Something', {});
|
||||
});
|
||||
|
||||
const sizeAfter = realm.computeSize();
|
||||
TestCase.assertEqual(typeof sizeAfter, 'number');
|
||||
TestCase.assertTrue(sizeAfter > sizeCompacted);
|
||||
},
|
||||
};
|
@ -50,7 +50,6 @@ var TESTS = {
|
||||
EncryptionTests: require('./encryption-tests'),
|
||||
ObjectIDTests: require('./object-id-tests'),
|
||||
// Garbagecollectiontests: require('./garbage-collection'),
|
||||
ComputeSizeTests: require('./compute-size-tests'),
|
||||
};
|
||||
|
||||
// If sync is enabled, run the sync tests
|
||||
|
Loading…
x
Reference in New Issue
Block a user