WWW.BOOK.DISLIB.INFO
FREE ELECTRONIC LIBRARY - Books, dissertations, abstract
 
<< HOME
CONTACTS



Pages:     | 1 |   ...   | 18 | 19 || 21 | 22 |   ...   | 27 |

«Introduction to Core Data Programming Guide 11 Who Should Read This Document 11 Organization of This Document 11 See Also 13 Technology Overview 14 ...»

-- [ Page 20 ] --

Security Core Data makes no guarantees regarding the security of persistent stores from untrusted sources and cannot detect whether files have been maliciously modified. The SQLite store offers slightly better security than the XML and binary stores, but it should not be considered inherently secure. Note that you should also consider the security of store metadata since it is possible for data archived in the metadata to be tampered with independently of the store data. If you want to ensure data security, you should use a technology such as an encrypted disk image.

2012-09-19 | Copyright © 2004, 2012 Apple Inc. All Rights Reserved.

Persistent Store Features Fetch Predicates and Sort Descriptors Fetch Predicates and Sort Descriptors There are some interactions between fetching and the type of store. In the XML, binary, and in-memory stores, evaluation of the predicate and sort descriptors is performed in Objective-C with access to all Cocoa's functionality, including the comparison methods on NSString. The SQL store, on the other hand, compiles the predicate and sort descriptors to SQL and evaluates the result in the database itself. This is done primarily for performance, but it means that evaluation happens in a non-Cocoa environment, and so sort descriptors (or predicates) that rely on Cocoa cannot work. The supported sort selectors are compare: and caseInsensitiveCompare:, localizedCompare:, localizedCaseInsensitiveCompare:, and localizedStandardCompare: (the latter is Finder-like sorting, and what most people should use most of the time). In addition you cannot sort on transient properties using the SQLite store.

There are additional constraints on the predicates you can use with the SQLite store:

You cannot necessarily translate “arbitrary” SQL queries into predicates.

● Prior to OS X v10.6, Core Data’s SQL store did not support the MATCHES operator (you could use the ● MATCHES operator to perform in-memory filtering of results returned from the store).

You can only have one to-many element in a key path in a predicate.

● For example, no toOne.toMany.toMany, or toMany.toOne.toMany type constructions (they evaluate to sets of sets). As a consequence, in any predicate sent to the SQL store, there may be only one operator (and one instance of that operator) from ALL, ANY, and IN.

- CoreData supports a noindex: (see NSPredicate documentation re: function expressions) that can be used to drop indices in queries passed to SQLite. This is done primarily for performance reasons: SQLite uses a limited number of indices per query, and noindex: allows the user to preferentially specify which indexes should not be used.

SQLite Store

File-systems supported by the SQLite store The SQLite store supports reading data from a file that resides on any type of file-system. The SQLite store does not in general, however, support writing directly to file-systems which do not implement byte-range locking. For DOS filesystems and for some NFS file system implementations that do not support byte-range locking correctly, SQLite will use "dbfile.lock" locking, and for SMB file systems it uses flock-style locking.

2012-09-19 | Copyright © 2004, 2012 Apple Inc. All Rights Reserved.

Persistent Store Features SQLite Store To summarize: byte-range locking file systems have the best concurrent read/write support; these include HFS+, AFP, and NFS. File systems with simplistic file locking are also supported but do not allow for as much concurrent read/write access by multiple processes; these include SMB, and DOS. The SQLite store does not support writing to WebDAV file-systems (this includes iDisk).

File Size May Not Reduce After Deleting a Record Simply deleting a record from a SQLite store does not necessarily result in a reduction in the size of the file. If enough items are removed to free up a page in the database file, SQLite’s automatic database vacuuming will reduce the size of the file as it rearranges the data to remove that page. Similarly, the file size may be reduced if you remove an item that itself occupies multiple pages (such as a thumbnail image).

An SQLite file is arranged as a collection of pages. The data within those pages is managed via B-trees, not as simple fixed-length records. This is much more efficient for searching and for overall storage, since it allows SQLite to optimize how it stores both data and indexes in a single file, and is also the foundation of its data integrity (transaction and journaling) mechanism. However, the cost of this is that some delete operations may leave holes in the file. If you delete some data and add other data, the holes left by the deleted data may be filled by the added data, or the file may be vacuumed to compact its data, whichever SQLite considers most appropriate based on the operations you’re performing.

Configuring a SQLite Store’s Save Behavior When Core Data saves a SQLite store, SQLite updates just part of the store file. Loss of that partial update would be catastrophic, so you may want to ensure that the file is written correctly before your application continues.

Unfortunately, doing so means that in some situations saving even a small set of changes to an SQLite store can take considerably longer than saving to, say, an XML store. (For example, where saving to an XML file might take less than a hundredth of a second, saving to an SQLite store may take almost half a second. This is not an issue for XML or Binary stores—since they are atomic, there is a much lower likelihood of data loss that involves corruption of the file, especially since the writes are typically atomic and the old file is not deleted until the new has been successfully written.) fsync in OS X: Since in OS X the fsync command does not make the guarantee that bytes are written, SQLite sends a F_FULLFSYNC request to the kernel to ensures that the bytes are actually written through to the drive platter. This causes the kernel to flush all buffers to the drives and causes the drives to flush their track caches. Without this, there is a significantly large window of time within which data will reside in volatile memory—and in the event of system failure you risk data corruption.





Core Data provides a way to control sync behavior in SQLite using two independent pragmas, giving you

control over the tradeoff between performance and reliability:

–  –  –

synchronous controls the frequency of disk-syncing ● PRAGMA synchronous FULL [2] / NORMAL [1] / OFF [0] full_fsync controls the type of disk-sync operation performed ●

–  –  –

The pragmas are publicly documented at http://sqlite.org/pragma.html.

You can set both pragmas using the key NSSQLitePragmasOption in the options dictionary when opening the store. The NSSQLitePragmasOption dictionary contains pragma names as keys and string values as

objects, as illustrated in the following example:

NSPersistentStoreCoordinator *psc = #Get a persistent store coordinator#;

NSMutableDictionary *pragmaOptions = [NSMutableDictionary dictionary];

[pragmaOptions setObject:@"NORMAL" forKey:@"synchronous"];

[pragmaOptions setObject:@"1" forKey:@"fullfsync"];

NSDictionary *storeOptions = [NSDictionary dictionaryWithObject:pragmaOptions forKey:NSSQLitePragmasOption];

NSPersistentStore *store;

–  –  –

OS X v10.4: OS X v10.

4 uses full_fsync by default. Since the fsync command does not make the guarantee that bytes are written, SQLite sends a F_FULLFSYNC request to the kernel. This causes the kernel to flush all buffers to the drives and causes the drives to flush their track caches.

In OS X v10.4, there are only two settings to control the way in which data in a SQLite-based store is written to disk.

If you want to trade risk of data corruption against the time taken to save a file, you can set the defaults key com.apple.CoreData.SQLiteDebugSynchronous to one of three

values:

0: Disk syncing is switched off

–  –  –

2 (The default): Disk syncing is performed via the fctl FULL_FSYNC command—a costly operation but one that guarantees data is written to disk Important: The default behaviors in OS X v10.4 an 10.5 are different. In OS X v10.4, SQLite uses FULL_FSYNC by default; in OS X v10.5 it does not.

–  –  –

There are several situations in which performing operations with Core Data on a background thread or queue is beneficial, in particular if you want to ensure that your application’s user interface remains responsive while Core Data is undertaking a long-running task. If you do perform concurrent operations with Core Data, however, you need to take considerable care that object graphs do not get into an inconsistent state.

Note: You can use threads, serial operation queues, or dispatch queues for concurrency. For the sake of conciseness, this article uses “thread” throughout to refer to any of these.

If you choose to use concurrency with Core Data, you also need to consider the application environment. For the most part, AppKit and UIKit are not thread safe; in particular, on OS X Cocoa bindings and controllers are not thread safe—if you are using these technologies, multi-threading may be complex.

Use Thread Confinement to Support Concurrency The pattern recommended for concurrent programming with Core Data is thread confinement : each thread must have its own entirely private managed object context.

There are two possible ways to adopt the pattern:

1. Create a separate managed object context for each thread and share a single persistent store coordinator.

This is the typically-recommended approach.

2. Create a separate managed object context and persistent store coordinator for each thread.

This approach provides for greater concurrency at the expense of greater complexity (particularly if you need to communicate changes between different contexts) and increased memory usage.

You must create the managed context on the thread on which it will be used. If you use NSOperation, note that its init method is invoked on the same thread as the caller. You must not, therefore, create a managed object context for the queue in the queue’s init method, otherwise it is associated with the caller’s thread.

Instead, you should create the context in main (for a serial queue) or start (for a concurrent queue).

Using thread confinement, you should not pass managed objects or managed object contexts between threads.

To “pass” a managed object from one context another across thread boundaries, you either:

2012-09-19 | Copyright © 2004, 2012 Apple Inc. All Rights Reserved.

Concurrency with Core Data Track Changes in Other Threads Using Notifications Pass its object ID (objectID) and use objectWithID: or existingObjectWithID:error: on the ● receiving managed object context.

The corresponding managed objects must have been saved—you cannot pass the ID of a newly-inserted managed object to another context.

Execute a fetch on the receiving context.

● These create a local version of the managed object in the receiving context.

You can use the methods provided by NSFetchRequest to make working with data across threads easier and more efficient. For example, you can configure a fetch request to return just object IDs but also include the row data (and update the row cache)—this can be useful if you're just going to pass those object IDs from a background thread to another thread.

There is typically no need to use locks with managed objects or managed object contexts. However, if you use a single persistent store coordinator shared by multiple contexts and want to perform operations on it (for example, if you want to add a new store), or if you want to aggregate a number of operations in one context together as if a virtual single transaction, you should lock the persistent store coordinator.



Pages:     | 1 |   ...   | 18 | 19 || 21 | 22 |   ...   | 27 |


Similar works:

«An Oracle White Paper Updated December 2012 Best Practices for Conflict Detection and Resolution in Active-Active Replication Environments Using Oracle GoldenGate Best Practices for Conflict Detection and Resolution in Active-Active Replication Environments Using Oracle GoldenGate Contents Executive Overview Introduction Oracle GoldenGate for Active-Active Replication Key Requirements for Active-Active Replication Configurations. 5 Real-Time, Low-Impact Data Movement Conflict Detection and...»

«E T A Hoffmann Gesammelte Werke Andhofs Grosse Literaturbibliothek Erschienen haben den Themenboxen auf einer Deutschland Marke Stadt, dessen Haussegen den genervten Park waren. Aber zudem hat Bestandteil Auflage mehr am positiv, hier dass uns sehr die Prozentpunkte wissen sollte. Andere PDF am download wie seit der MTI der Minuten of Kraniche ging, haben die Geschwindigkeit der Francisco Montenegro um die Oktober angefangen. Grau sich die windund Friedensplans weiter extrem demonstrieren, gibt...»

«The censor Package Tools for Producing Redacted Documents Steven B. Segletes steven.b.segletes.civ@mail.mil July 30, 2013 v3.21 1 Introduction The censor package allows a convenient redaction/censor capability to be employed, for those who need to protect restricted information, as well as for those who are forced to work in a more inefficient environment when dealing with restricted information. Let us assume you have a document for internal use, containing some restricted (i.e., private,...»

«1 Ethnomusicology Ireland 2/3 (July 2013) “PRETTY YOUNG ARTISTES” AND “THE QUEEN OF IRISH FIDDLERS”: INTELLIGIBILITY, GENDER, AND THE IRISH NATIONALIST IMAGINATION By Tes Slominski And yet if you took the hero out of the story, what was left? What female figure was there to identify with?.The heroine, as such, was utterly passive. She was Ireland or Hibernia. She was stamped, as a rubbed-away mark, on silver or gold; a compromised regal figure on a throne. Or she was a...»

«PositionLiberal 124 Die Zukunft des Euro: Kritische Fragen – Liberale Antworten Karl-Heinz Paqué Michael Theurer Alexander Graf Lambsdorff Wenn Sie unsere Arbeit unterstützen wollen: Commerzbank Berlin BLZ 100 400 00 Spendenkonto: 266 9661 04 Spendenbescheinigungen werden ausgestellt.Impressum: Herausgeber Liberales Institut der Friedrich-Naumann-Stiftung für die Freiheit Reinhardtstraße 12 10117 Berlin Tel.: 0 30.28 87 78-35 Fax: 0 30.28 87 78-39 liberales.institut@freiheit.org...»

«Search on Encrypted Data Hakan Hacıg¨m¨¸1, Bijit Hore2, Bala Iyer3, and Sharad Mehrotra4 u us IBM Almaden Research Center hakanh@acm.org Donald Bren School of Computer Science University of California, Irvine bhore@ics.uci.edu IBM Silicon Valley Lab balaiyer@us.ibm.com Donald Bren School of Computer Science University of California, Irvine sharad@ics.uci.edu 2 Hakan Hacıg¨ m¨¸, Bijit Hore, Bala Iyer, and Sharad Mehrotra u us 1 Introduction The proliferation of a new breed of data...»

«Frequently Asked Questions (FAQ) on Conversion from BPM5 to BPM6 As of April 2015, the Central Bank of Brazil (CBB) will start publishing the Balance of Payments (BP) and International Investment Position (IIP) statistics in accordance with the Sixth Edition of the Balance of Payments and International Investment Position Manual (BPM6), International Monetary Fund (IMF)1, published in 2009. Since 2001, these statistics are being published by the CBB according to the Fifth Edition of the Balance...»

«Diplomatie Ich hatte wirklich keine Lust, in einem Harem zu landen, aber ein klein wenig beruhigt wurde ich durch das Gespräch mit Wendy schon. Allerdings spürte ich trotz meines aufgewühlten Zustandes durchaus, dass meine Bemerkung über das mögliche Strafmaß für Spionage Wirkung bei Wendy hinterlassen hatte. Sie war längst nicht so cool, wie sie sich gab. Das machte sie nur, um mir ein wenig von meiner Angst zu nehmen. Ehe wir jedoch dazu kamen, das Gespräch fortzusetzen, tauchte ein...»

«C. Haas LIBREAS. Library Ideas, 27 (2015). urn:nbn:de:kobv:11-100229826 9 Zwischen Participatory Design und lokaler Forschung. Ethnografie in drei neuen Methodenhandbüchern Corinna Haas Vor kurzem wurden drei neue Methoden-Handbücher für Bibliothekswissenschaftler veröffentlicht (Umlauf u.a., Hg. 2013; Siegfried u.a. 2013 und Schuldt 2014), die alle auf das Thema Ethnografie im Bibliotheksbereich eingehen. Mein Beitrag fragt danach, welches Potential sie jeweils in der Ethnografie sehen,...»

«Katariina Nissinen Diffusion of X-ray Contrast Agents in Intact and Repaired Articular Cartilage Publications of the University of Eastern Finland Dissertations in Forestry and Natural Sciences KATARIINA NISSINEN NÉE KULMALA Diffusion of X-ray contrast agents in intact and repaired articular cartilage Publications of the University of Eastern Finland Dissertations in Forestry and Natural Sciences No 110 Academic Dissertation To be presented by permission of the Faculty of Science and Forestry...»





 
<<  HOME   |    CONTACTS
2016 www.book.dislib.info - Free e-library - Books, dissertations, abstract

Materials of this site are available for review, all rights belong to their respective owners.
If you do not agree with the fact that your material is placed on this site, please, email us, we will within 1-2 business days delete him.