Merge pull request #1899 from realm/kneth/revert-computeSize

Revert computeSize
This commit is contained in:
Kenneth Geisshirt 2018-06-28 11:00:06 +02:00 committed by GitHub
commit f9ab01e604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 4 additions and 86 deletions

View File

@ -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).
@ -193,7 +192,7 @@ X.Y.Z Release notes
The feature known as Partial synchronization has been renamed to Query-based synchronization and is now the default mode for synchronized Realms. This has impacted a number of APIs. See below for the details.
### Deprecated
* [Sync] `Realm.Configuration.SyncConfiguration.partial` has been deprecated in favor of `Realm.Configuration.SyncConfiguration.fullSynchronization`.
* [Sync] `Realm.Configuration.SyncConfiguration.partial` has been deprecated in favor of `Realm.Configuration.SyncConfiguration.fullSynchronization`.
* [Sync] `Realm.automaticSyncConfiguration()` has been deprecated in favor of `Realm.Sync.User.createConfiguration()`.
### Breaking changes

View File

@ -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`).
*/

View File

@ -130,7 +130,6 @@ util.createMethods(Realm.prototype, objectTypes.REALM, [
'removeListener',
'removeAllListeners',
'close',
'computeSize',
'_waitForDownload',
'_objectForObjectId',
]);

10
lib/index.d.ts vendored
View File

@ -318,7 +318,7 @@ declare namespace Realm.Sync {
static requestPasswordReset(server: string, email: string): Promise<void>;
static completePasswordReset(server:string, reset_token:string, new_password:string): Promise<void>;
static requestEmailConfirmation(server:string, email:string): Promise<void>;
static confirmEmail(server:string, confirmation_token:string): Promise<void>;
@ -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

View File

@ -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

View File

@ -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);
},
};

View File

@ -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