Skip to content

Commit

Permalink
realm lang gone
Browse files Browse the repository at this point in the history
  • Loading branch information
lindseymoore committed Jun 14, 2024
1 parent 7ea109c commit a625924
Show file tree
Hide file tree
Showing 24 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion examples/dotnet/Examples/Compact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task Compacts()
/* totalBytes refers to the size of the file on disk in
* bytes (data + free space).
* usedBytes refers to the number of bytes used by
* the realm file
* the file
*/

// Compact if the file is over 100MB in size and less
Expand Down
4 changes: 2 additions & 2 deletions examples/ios/Examples/Compacting.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ - (void)testCompacting {
};

NSError *error = nil;
// Realm is compacted on the first open if the configuration block conditions were met.
// The database is compacted on the first open if the configuration block conditions were met.
RLMRealm *realm = [RLMRealm realmWithConfiguration:config error:&error];
if (error) {
// handle error compacting or opening Realm
// handle error compacting or opening database
}
// :snippet-end:
}
Expand Down
8 changes: 4 additions & 4 deletions examples/ios/Examples/Compacting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class Compacting: XCTestCase {
return (totalBytes > oneHundredMB) && (Double(usedBytes) / Double(totalBytes)) < 0.5
})
do {
// Realm is compacted on the first open if the configuration block conditions were met.
// The database is compacted on the first open if the configuration block conditions were met.
let realm = try Realm(configuration: config)
} catch {
// handle error compacting or opening Realm
// handle error compacting or opening the database
}
// :snippet-end:
}
Expand All @@ -34,11 +34,11 @@ class Compacting: XCTestCase {
})

do {
// Realm is compacted asynchronously on the first open if the
// The database is compacted asynchronously on the first open if the
// configuration block conditions were met.
let realm = try await Realm(configuration: config)
} catch {
// handle error compacting or opening Realm
// handle error compacting or opening the database
}
}
// :snippet-end:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ func testAsyncCompact() async {
})

do {
// Realm is compacted asynchronously on the first open if the
// The database is compacted asynchronously on the first open if the
// configuration block conditions were met.
let realm = try await Realm(configuration: config)
} catch {
// handle error compacting or opening Realm
// handle error compacting or opening the database
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
};

NSError *error = nil;
// Realm is compacted on the first open if the configuration block conditions were met.
// The database is compacted on the first open if the configuration block conditions were met.
RLMRealm *realm = [RLMRealm realmWithConfiguration:config error:&error];
if (error) {
// handle error compacting or opening Realm
// handle error compacting or opening database
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ let config = Realm.Configuration(shouldCompactOnLaunch: { totalBytes, usedBytes
return (totalBytes > oneHundredMB) && (Double(usedBytes) / Double(totalBytes)) < 0.5
})
do {
// Realm is compacted on the first open if the configuration block conditions were met.
// The database is compacted on the first open if the configuration block conditions were met.
let realm = try Realm(configuration: config)
} catch {
// handle error compacting or opening Realm
// handle error compacting or opening the database
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* totalBytes refers to the size of the file on disk in
* bytes (data + free space).
* usedBytes refers to the number of bytes used by
* the realm file
* the file
*/

// Compact if the file is over 100MB in size and less
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Specify conditions to execute this method, such as:
- The size of the file on disk
- How much free space the file contains

The following example shows setting the conditions to compact a realm if the
file is above 100 MB and 50% or less of the space in the realm file is used.
The following example shows setting the conditions to compact a database file if the
file is above 100 MB and 50% or less of the space in the file is used.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Alternatively, you can compact a realm file without first obtaining an instance
to the realm by calling the
Alternatively, you can compact a database file without first obtaining an instance
to the database by calling the
:dotnet-sdk:`Compact() <reference/Realms.Realm.html#Realms_Realm_Compact_Realms_RealmConfigurationBase_>`
method.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
You can use the .NET SDK to check the realm file size each time
You can use the .NET SDK to check the file size each time
it is opened by specifying a
:dotnet-sdk:`ShouldCompactDelegate <reference/Realms.RealmConfiguration.ShouldCompactDelegate.html>`
in the configuration.

If the delegate returns ``true`` -- and the file is not in use -- the realm file
If the delegate returns ``true`` -- and the file is not in use -- the file
is compacted prior to making the instance available.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
You can compact a realm file by calling :flutter-sdk:`Realm.compact()
You can compact a file by calling :flutter-sdk:`Realm.compact()
<realm/Realm/compact.html>`. This method takes a :flutter-sdk:`Configuration
<topics/Configuration-topic.html>` as an argument. When you use this method,
the device must have enough free space to make a copy of the realm.
the device must have enough free space to make a copy of the database file.

``Realm.compact()`` obtains an instance of the realm, and opens it to
``Realm.compact()`` obtains an instance of the database, and opens it to
trigger any schema version upgrades, file format upgrades, migration and
initial data callbacks. Upon successfully opening the realm and performing
these operations, this method then compacts the realm.
initial data callbacks. Upon successfully opening the database and performing
these operations, this method then compacts the database file.

If successful, a call to ``Realm.compact()`` returns ``true``.

Do not call this method from inside a transaction. You also cannot compact an
open realm.
open database.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
You can define a :flutter-sdk:`shouldCompactCallback()
<realm/LocalConfiguration/shouldCompactCallback.html>` as a property of a
realm's configuration. You can use this with both local-only and synced realms
database's configuration. You can use this with both local-only and synced databases
with the :flutter-sdk:`Configuration.local() <realm/Configuration/local.html>`
and :flutter-sdk:`Configuration.flexibleSync() <realm/Configuration/flexibleSync.html>`
methods, respectively.

This callback takes two ``int`` values representing the total number of
bytes and the used bytes of the realm file on disk. The callback returns
bytes and the used bytes of the database file on disk. The callback returns
a ``bool``. Compaction only occurs if the ``bool`` returns ``true`` and
another process is not currently accessing the realm file.
another process is not currently accessing the database file.

The most basic usage is to define a file size at which compaction should occur.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
You can remove unused space by compacting the realm file by manually
You can remove unused space by compacting the database file by manually
calling :java-sdk:`compactRealm()
<io/realm/Realm.html#compactRealm-io.realm.RealmConfiguration->`.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. important:: Compact All Production Applications

Every production application should implement compacting to
periodically reduce realm file size.
periodically reduce database file size.

Specify the :java-sdk:`compactOnLaunch()
<io/realm/RealmConfiguration.Builder.html#compactOnLaunch-io.realm.CompactOnLaunchCallback->`
builder option when opening the first connection to a realm in your
builder option when opening the first connection to a database in your
Android application.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
You can compact a realm file whenever you'd like by calling
You can compact a database file whenever you'd like by calling
the :js-sdk:`compact() <Realm.html#compact>` method.

The ``compact()`` method will return true if the operation is successful.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
You can save a compacted (and optionally :ref:`encrypted
<sdks-encrypt-database>`) copy of a realm to another file location
<sdks-encrypt-database>`) copy of a database to another file location
with the :js-sdk:`Realm.writeCopyTo()
<Realm.html#writeCopyTo>`
method. The destination file cannot already exist.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
You can use the Node.js SDK to check the realm file size each time it is opened
You can use the Node.js SDK to check the database file size each time it is opened
by specifying a :js-sdk:`shouldCompact <Realm.html#~Configuration>` function
for the configuration. The following code example shows how to do this:
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
You can compact a realm file without having to open it by calling
You can compact a database file without having to open it by calling
the :kotlin-sdk:`compactRealm <io.realm.kotlin/-realm/-companion/compact-realm.html>` method.

The ``compactRealm`` method will return true if the operation is successful
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
You can save a compacted (and optionally :ref:`encrypted
<sdks-encrypt-database>`) copy of a realm to another file location
<sdks-encrypt-database>`) copy of a database file to another file location
with the :kotlin-sdk:`Realm.writeCopyTo
<io.realm.kotlin/-realm/write-copy-to.html>`
method. The destination file cannot already exist.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
You can use the Kotlin SDK to compact the realm file each time it is opened
You can use the Kotlin SDK to compact the database file each time it is opened
by setting a callback for the :kotlin-sdk:`compactOnLaunch
<io.realm.kotlin/-configuration/-shared-builder/compact-on-launch.html>` function
for the configuration. When you call ``compactOnLaunch`` for the
configuration, the :kotlin-sdk:`DEFAULT_COMPACT_ON_LAUNCH_CALLBACK
<io.realm.kotlin/-realm/-companion/-d-e-f-a-u-l-t_-c-o-m-p-a-c-t_-o-n_-l-a-u-n-c-h_-c-a-l-l-b-a-c-k.html>`
will trigger if the file is above 50 MB and 50% or more of the space in
the realm file is unused. You can specify custom compaction settings
the database file is unused. You can specify custom compaction settings
when calling ``compactOnLaunch`` depending on your applications needs.
The following code example shows how to do this:
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Use :objc-sdk:`shouldCompactOnLaunch <Classes/RLMRealmConfiguration.html>`
on a realm's configuration object to compact a realm.
on a database's configuration object to compact a database file.
Specify conditions to execute this method, such as:

- The size of the file on disk
Expand All @@ -10,5 +10,5 @@ For more information about the conditions to execute in the method, see

.. important:: Compacting may not occur

Compacting cannot occur while a realm is being accessed,
Compacting cannot occur while a database is being accessed,
regardless of any configuration settings.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
You can save a compacted (and optionally :ref:`encrypted
<sdks-encrypt-database>`) copy of a realm to another file location
<sdks-encrypt-database>`) copy of a database file to another file location
with the :swift-sdk:`Realm.writeCopy(toFile:encryptionKey:)
<Structs/Realm.html#/s:10RealmSwift0A0V9writeCopy6toFile13encryptionKeyy10Foundation3URLV_AG4DataVSgtKF>`
method. The destination file cannot already exist.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Use :swift-sdk:`shouldCompactOnLaunch()<Structs/Realm/Configuration.html>`
on a realm's configuration object to compact a realm.
on a database's configuration object to compact a database.
Specify conditions to execute this method, such as:

- The size of the file on disk
Expand All @@ -10,11 +10,11 @@ For more information about the conditions to execute in the method, see:

.. important:: Compacting may not occur

Compacting cannot occur while a realm is being accessed,
Compacting cannot occur while a database is being accessed,
regardless of any configuration settings.

.. literalinclude:: /examples/generated/code/start/Compacting.snippet.compacting.swift
:language: swift

When you use the Swift async/await syntax to open a realm asynchronously, you can also
compact a realm in the background.
When you use the Swift async/await syntax to open a database asynchronously, you can also
compact a database file in the background.
8 changes: 4 additions & 4 deletions source/sdk/files/reduce-file-size.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,18 @@ application:
compact. After experimentation, you may find a different percentage
works best for your application.

These calculations might look like this:
These calculations might look like this:

.. code-block:: javascript

// Set a maxFileSize equal to 20MB in bytes
const maxFileSize = 20 * 1024 * 1024;

/* Check for the realm file size to be greater than the max file size,
/* Check for the file size to be greater than the max file size,
* and the amount of bytes currently used to be less than 50% of the
* total realm file size */
* total file size */
return (totalBytes > (double)maxFileSize) &&
((double)usedBytes / totalBytes < 0.5);

Experiment with conditions to find the right balance of how often to
compact realm files in your application.
compact files in your application.

0 comments on commit a625924

Please sign in to comment.