banshee r4204 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Core/Banshee.Services/Banshee.Query src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Libraries/Hyena/Hyena.Data.Sqlite src/Libraries/Hyena/Hyena.Data.Sqlite/Tests src/Libraries/Hyena/Hyena.Query
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4204 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Core/Banshee.Services/Banshee.Query src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Libraries/Hyena/Hyena.Data.Sqlite src/Libraries/Hyena/Hyena.Data.Sqlite/Tests src/Libraries/Hyena/Hyena.Query
- Date: Thu, 26 Jun 2008 21:33:19 +0000 (UTC)
Author: gburt
Date: Thu Jun 26 21:33:19 2008
New Revision: 4204
URL: http://svn.gnome.org/viewvc/banshee?rev=4204&view=rev
Log:
2008-06-26 Gabriel Burt <gabriel burt gmail com>
* src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs:
Remove WriteLines.
* src/Core/Banshee.Services/Banshee.Collection.Database/FilterModelProvider.cs:
Remove expensive ifnull call; all blank (empty or all white space) strings
should now be saved as null.
* src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs:
Increase the cache size if the library has > 10K tracks, use LogAll = true
for sql debugging.
* src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs:
Update CoreTracks genre, composer etc to be null if blank/whitespace.
Drop the CoreCache table - will be recreated as needed, and as a temporary
table (small performance win). Vacuum and analyze the db, for good
measure.
* src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs: Remove
expensive sort by Uri as the fallback for most non-URI sort options.
* src/Libraries/Hyena/Hyena.Query/QueryTermNode.cs: Explicitly set the
no-field-specified operator (to contains).
* src/Libraries/Hyena/Hyena.Data.Sqlite/Tests/SqliteModelProviderTests.cs:
Test that blank/whitespace strings get saved as null.
* src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs: If a string is
empty or whitespace only, save it as null.
* src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs: Change
Exists function to check sqltie_temp_master too.
* src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs: Wrap the
reload query (delete + insert into CoreCache) in a transaction. Make the
CoreCache table a TEMP table for performance.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/FilterModelProvider.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs
trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs
trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs
trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs
trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/Tests/SqliteModelProviderTests.cs
trunk/banshee/src/Libraries/Hyena/Hyena.Query/QueryTermNode.cs
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/FilterModelProvider.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/FilterModelProvider.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/FilterModelProvider.cs Thu Jun 26 21:33:19 2008
@@ -48,7 +48,7 @@
AddColumn (new DatabaseColumn (value_info, new DatabaseColumnAttribute ()), true);
- select = String.Format ("ifnull({0}, '') as Value", value_column);
+ select = String.Format ("{0} as Value", value_column);
}
public override string TableName { get { return table_name; } }
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs Thu Jun 26 21:33:19 2008
@@ -47,8 +47,8 @@
public BansheeDbConnection () : base (DatabaseFile)
{
// Each cache page is about 1.5K, so 32768 pages = 49152K = 48M
- //Execute ("PRAGMA cache_size = 32768");
- Execute ("PRAGMA cache_size = 16384");
+ int cache_size = Query<long> ("SELECT COUNT(*) FROM CoreTracks") > 10000 ? 32768 : 16384;
+ Execute ("PRAGMA cache_size = ?", cache_size);
Execute ("PRAGMA synchronous = OFF");
Execute ("PRAGMA temp_store = MEMORY");
Execute ("PRAGMA count_changes = OFF");
@@ -61,9 +61,7 @@
migrator = new BansheeDbFormatMigrator (this);
if (Banshee.Base.ApplicationContext.CommandLine.Contains ("debug-sql")) {
- this.Executing += delegate (object sender, ExecutingEventArgs args) {
- Log.Debug (String.Format ("Executing: {0}", args.Command.CommandText));
- };
+ Hyena.Data.Sqlite.HyenaSqliteCommand.LogAll = true;
}
}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs Thu Jun 26 21:33:19 2008
@@ -52,7 +52,7 @@
// NOTE: Whenever there is a change in ANY of the database schema,
// this version MUST be incremented and a migration method
// MUST be supplied to match the new version number
- protected const int CURRENT_VERSION = 14;
+ protected const int CURRENT_VERSION = 16;
protected const int CURRENT_METADATA_VERSION = 2;
#region Migration Driver
@@ -442,6 +442,34 @@
#endregion
+#region Version 15
+
+ [DatabaseVersion (15)]
+ private bool Migrate_15 ()
+ {
+ string [] columns = new string [] {"Genre", "Composer", "Copyright", "LicenseUri", "Comment"};
+ foreach (string column in columns) {
+ Execute (String.Format ("UPDATE CoreTracks SET {0} = NULL WHERE {0} IS NOT NULL AND trim({0}) = ''", column));
+ }
+ return true;
+ }
+
+#endregion
+
+#region Version 16
+
+ [DatabaseVersion (16)]
+ private bool Migrate_16 ()
+ {
+ // The CoreCache table is now created as needed, and as a TEMP table
+ Execute ("DROP TABLE CoreCache");
+ Execute ("COMMIT; VACUUM; BEGIN");
+ Execute ("ANALYZE");
+ return true;
+ }
+
+#endregion
+
#pragma warning restore 0169
#region Fresh database setup
@@ -621,14 +649,6 @@
ModelID TEXT
)
");
-
- Execute(@"
- CREATE TABLE CoreCache (
- OrderID INTEGER PRIMARY KEY,
- ModelID INTEGER,
- ItemID INTEGER
- )
- ");
// This index slows down queries were we shove data into the CoreCache.
// Since we do that frequently, not using it.
@@ -738,6 +758,7 @@
Execute ("UPDATE CorePlaylists SET PrimarySourceID = 1");
InitializeOrderedTracks ();
+ Migrate_15 ();
}
#endregion
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs Thu Jun 26 21:33:19 2008
@@ -225,7 +225,7 @@
DateAddedField, PlaylistField, SmartPlaylistField
);
- private const string default_sort = @"CoreAlbums.ArtistNameLowered ASC, CoreAlbums.TitleLowered ASC, CoreTracks.Disc ASC, CoreTracks.TrackNumber ASC, CoreTracks.Uri ASC";
+ private const string default_sort = @"CoreAlbums.ArtistNameLowered ASC, CoreAlbums.TitleLowered ASC, CoreTracks.Disc ASC, CoreTracks.TrackNumber ASC";
public static string GetSort (string key)
{
return GetSort (key, false);
@@ -249,16 +249,14 @@
CoreArtists.NameLowered {0},
CoreAlbums.TitleLowered ASC,
CoreTracks.Disc ASC,
- CoreTracks.TrackNumber ASC,
- CoreTracks.Uri ASC", ascDesc);
+ CoreTracks.TrackNumber ASC", ascDesc);
break;
case "Album":
sort_query = String.Format (@"
CoreAlbums.TitleLowered {0},
CoreTracks.Disc ASC,
- CoreTracks.TrackNumber ASC,
- CoreTracks.Uri ASC", ascDesc);
+ CoreTracks.TrackNumber ASC", ascDesc);
break;
case "Title":
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs Thu Jun 26 21:33:19 2008
@@ -130,11 +130,9 @@
if (playlist != null) {
//Gtk.Drag.
int row = GetRowAtY (y);
- Console.WriteLine ("track drag drop at y {0}, row {1}; y at row 0 is {2}, row height = {3}", y, row, GetYAtRow (0), RowHeight);
if (row != GetRowAtY (y + RowHeight / 2)) {
row += 1;
}
- Console.WriteLine ("track drag drop, row + 1/2 is {0}", GetRowAtY (y + (RowHeight / 2)));
if (playlist.TrackModel.Selection.Contains (row)) {
// can't drop within the selection
Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs Thu Jun 26 21:33:19 2008
@@ -272,14 +272,15 @@
private bool Exists (string type, string name)
{
- return
- Query<int> (
- String.Format (@"
- SELECT COUNT(*)
- FROM sqlite_master
- WHERE Type='{0}' AND Name='{1}'",
- type, name)
- ) > 0;
+ return Exists (type, name, "sqlite_master") || Exists (type, name, "sqlite_temp_master");
+ }
+
+ private bool Exists (string type, string name, string master)
+ {
+ return Query<int> (String.Format (
+ "SELECT COUNT(*) FROM {0} WHERE Type='{1}' AND Name='{2}'",
+ master, type, name)
+ ) > 0;
}
private delegate void SchemaHandler (string column);
Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs Thu Jun 26 21:33:19 2008
@@ -283,7 +283,7 @@
lock (this) {
if (last_reload_fragment != model.ReloadFragment || last_reload_command == null) {
last_reload_fragment = model.ReloadFragment;
- last_reload_command = new HyenaSqliteCommand (String.Format ("{0}{1}", reload_sql, last_reload_fragment));
+ last_reload_command = new HyenaSqliteCommand (String.Format ("BEGIN; {0}{1}; COMMIT", reload_sql, last_reload_fragment));
}
Clear ();
@@ -438,7 +438,7 @@
if (!connection.TableExists (CacheTableName)) {
connection.Execute (String.Format (@"
- CREATE TABLE {0} (
+ CREATE TEMP TABLE {0} (
OrderID INTEGER PRIMARY KEY,
ModelID INTEGER,
ItemID INTEGER)", CacheTableName
Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs Thu Jun 26 21:33:19 2008
@@ -49,7 +49,12 @@
public static object ToDbFormat (Type type, object value)
{
- if (type == typeof (DateTime)) {
+ if (type == typeof (string)) {
+ // Treat blank strings or strings with only whitespace as null
+ return value == null || String.IsNullOrEmpty (((string)value).Trim ())
+ ? null
+ : value;
+ } else if (type == typeof (DateTime)) {
return DateTime.MinValue.Equals ((DateTime)value)
? (object)null
: DateTimeUtil.FromDateTime ((DateTime)value);
Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/Tests/SqliteModelProviderTests.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/Tests/SqliteModelProviderTests.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/Tests/SqliteModelProviderTests.cs Thu Jun 26 21:33:19 2008
@@ -109,6 +109,24 @@
Assert.AreEqual (newed_item.GetPrivateStringField (), loaded_item.GetPrivateStringField ());
Assert.AreEqual (newed_item.GetPrivateStringProperty (), loaded_item.GetPrivateStringProperty ());
}
+
+ [Test]
+ public void BlankStringMembers ()
+ {
+ DbBoundType newed_item = new DbBoundType ();
+ newed_item.PublicStringField = "";
+ newed_item.PublicStringProperty = null;
+ newed_item.SetPrivateStringField (" \t ");
+ newed_item.SetPrivateStringProperty (" foo ");
+
+ provider.Save (newed_item);
+
+ DbBoundType loaded_item = provider.FetchSingle (newed_item.PrimaryKey);
+ Assert.AreEqual (null, loaded_item.PublicStringField);
+ Assert.AreEqual (null, loaded_item.PublicStringProperty);
+ Assert.AreEqual (null, loaded_item.GetPrivateStringField ());
+ Assert.AreEqual (" foo ", loaded_item.GetPrivateStringProperty ());
+ }
[Test]
public void NullStringMembers ()
Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Query/QueryTermNode.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Query/QueryTermNode.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Query/QueryTermNode.cs Thu Jun 26 21:33:19 2008
@@ -73,6 +73,7 @@
if (term.Value == null) {
term.Field = null;
term.Value = QueryValue.CreateFromUserQuery (token, term.Field);
+ term.Operator = StringQueryValue.Contains;
}
return term;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]