Commit Graph

388 Commits

Author SHA1 Message Date
Par Winzell 44789e36ee Pointer equality between Doubles does not seem like a good idea. 2009-04-13 17:28:37 +00:00
Par Winzell d860091612 Forgot the main evaluator class in the previous commit. Hee. 2009-04-13 17:27:51 +00:00
Par Winzell 859b357d7b Give Depot the ability to evaluate SQL expressions without contacting the database. This code is not yet tied into anything, but possible applications, in increasing order of amazingness:
*) We do not currently invalidate cached keysets even when we know for a fact that the associated records have changed (and exactly how they've changed). By storing along with each cached keyset the query datastructure that was used to fetch the keys, we can use the SQLExpression evaluator to do a secondary invalidation sweep over the records when they're requested and make sure they still match the WHERE clause of the original query. If they don't, we toss'em from the cached keyset. This basically means we can trust our cached keysets much more and increase the amount of time we keep them around in the cache.

 *) Extending the first idea, we can do more than lazily invalidate parts of cached collections. We can, in fact, automatically adjust every relevant cached collection each time a record is deleted, inserted or modified. In theory, we could guarantee perpetual veracity of all cached collection queries. It's not a given that this is in every way a good idea, but it's a very interesting one to investigate.

As part of this change, ExpressionVisitor methods have to return a value. Slightly less elegant, but of greater general utility.
2009-04-13 17:19:01 +00:00
Par Winzell b8ac3750eb The MultiKey is a lot of complicated code to optimize an obscure situation. I know it's obscure because there's not a single use of this class anywhere that I can find. 2009-04-13 15:56:00 +00:00
Par Winzell 03ca344984 Don't freak out on empty In()'s, just scold the developer. 2009-04-10 18:11:13 +00:00
Par Winzell a4dc9860de Fix index creation for MySQL. 2009-04-08 18:52:08 +00:00
Par Winzell 9df2415678 There was never a good reason to do the SQL parameter binding as a second ExpressionVisitor recursion, and duplicating the logic structures for each visitor was getting increasingly cumbersome. Just encapsulate the binding actions and list'em up as we generate the SQL, then just iterate over them simple-like in the second pass. This permanently gets rid of anything BindVisitorish. 2009-04-01 05:48:11 +00:00
Par Winzell b2bd4b51f7 Oops. We were not taking the size of the matched-against column into account at all. That's not intuitive. The more precise the match, the higher we want to rank it. 2009-03-29 19:55:24 +00:00
Par Winzell 34599bc760 Adapt Depot's full-text search capabilities for PostgreSQL 8.3. This is a fairly minimal change, excepting support for associating FullTextIndex configurations with PostgreSQL search configurations. The legacy stuff to support 8.2 is unlikely to last long. 2009-03-26 20:14:45 +00:00
Andrzej Kapolka 51e43b6545 Fix bug that was adding extra commas for non-required computed
columns.
2009-03-25 00:11:55 +00:00
Michael Bayne 398164f2df Changed some Thread.dumpStack() calls into stack traces properly logged via the
logging system.
2009-03-24 18:49:03 +00:00
Par Winzell e62608a69f Let's make sure the overriding subclasses have something to override. Java 6 hid this from me. 2009-03-18 19:21:56 +00:00
Par Winzell fa7d2c0a7f 1) Broaden FullText to include ranking abilities along with matching, 2) Implement CASE WHEN ELSE END, 3) Let the people do 1 + 2 + 3 rathern 1 + (2 + 3), and so forth. 2009-03-18 19:01:20 +00:00
Michael Bayne 830e830100 Nixed these two updatePartial() convenience methods because they are
dangerous. The "key" (which identifies the rows you want to change) was
[ColumnExp, Comparable, ...] and the data that you would be changing was
[ColumnExp, Object]. So if you happened to pass a comparable object as the
first value you wanted to change, say:

updatePartial(FooRecord.class, FooRecord.FOO_ID, 5, FooRecord.BAR_ID, 6,
              FooRecord.BAZ, "biffle")

the compiler would think you wanted to use FOO_ID and BAR_ID as a key rather
than FOO_ID as a key and BAR_ID as something to be updated. Either way, it's
not clear what you want, so it should go. Now you have to create a Key():

updatePartial(new Key<FooRecord>(FooRecord.clsas, FooRecord.FOO_ID, 5,
                                 FooRecord.BAR_ID, 6),
              FooRecord.BAZ, "biffle")

or

updatePartial(new Key<FooRecord>(FooRecord.clsas, FooRecord.FOO_ID, 5),
              FooRecord.BAR_ID, 6, FooRecord.BAZ, "biffle")

None of our code was doing this anyway. We were already using Key everywhere or
the (Class, Comparable) method for records with a single column as primary key.
2009-03-10 23:30:36 +00:00
Michael Bayne a9dc596d3e Javadoc fixes, make deleteAll() do the right thing if you pass a KeySet into
the WhereClause-only version.
2009-03-03 23:40:55 +00:00
Par Winzell bb510ca506 Allow for distinguishing long-term caching from brief caching. For example, a public list of high scores may well lag 5 minutes behind database updates, whereas responses in a forum thread should perhaps never be more than 10 seconds out of date. The exact numbers are up to to the ehcache.xml configuration. 2009-02-06 16:09:10 +00:00
Michael Bayne ce03952b3c Javadoc fix, unused import nix. 2009-02-03 01:46:29 +00:00
Par Winzell db3dd861f4 Lose the spammy debug logging, collect some histogram information instead. These are not currently hooked up to Depot's Stat mechanism. 2009-02-02 18:14:26 +00:00
Par Winzell 3b65bc9b01 The 50 ms warning triggers every couple of thousand stores for a relatively large cache, usually with times in the 60-70 ms range which is certainly acceptable as long as they're that rare. Let's bump it to 100 ms since we're still on guard for gremlins. 2009-01-29 16:38:52 +00:00
Par Winzell efb2799167 Let's accept ColumnExp's or Strings for field identifiers and handle SQLExpression field values too. 2009-01-28 18:32:42 +00:00
Par Winzell 495399fc66 A little more information in our paranoid logging. 2009-01-28 05:54:23 +00:00
Par Winzell 4cab181df0 We'll use a ConcurrentHashMap for the bin, and then the enumerator will make a copy of it for returning. 2009-01-26 22:20:48 +00:00
Par Winzell 5a93e48e4d Oops. Let's actually wire these guys up... 2009-01-25 00:16:09 +00:00
Par Winzell bbcf7c8607 Don't try to build the old EHCacheAdapter either, if we don't have ehcache. 2009-01-24 23:26:46 +00:00
Par Winzell 9119cc9313 Update the test too. 2009-01-24 23:11:46 +00:00
Par Winzell 9e41b41994 Bring back the old EHCacheAdapter for transitional use until we can figure out what's up with the new one. Also, the enumeration API changed again. 2009-01-24 22:54:03 +00:00
Par Winzell 918405ec02 While investigating problems, add much paranoid profiling. Also let's do an explicit keyset copy during enumeration rather than the fancy concurrent hashmaps and iterable mappings. Finally, let's fully synchronize the other maps we're using. 2009-01-24 18:53:42 +00:00
Par Winzell db33c89b66 Get rid of some awful debug bits. 2009-01-23 19:51:12 +00:00
Par Winzell fc52b277a3 The CacheAdapter interface has changed:
* No more CacheBins, operations happen directly on the adapter.
 * Each cache write must supply a CacheCategory value that identifies its type. Current values are RECORD, KEYSET and RESULT. We will probably need a MISC or USER or something along those lines, too.

The EHCache adapter has been entirely rewritten:
 * Each CacheCategory maps to one EHCache, which means there are only a very few EHCaches, and we know what they are. We expect these to be declared in ehcache.xml rather than programmatically generated as before.
 * Elements inside each EHCache are indexed by (cacheId, elementKey) tuples.

The main purpose of this refactor is to sort all Records into a single EHCache, which we can then make really, really large, and then let the LRU mechanism sort out what should be in memory and what shouldn't. The previous implementation would make no ram allocation distinction between busy records and ones rarely read.
2009-01-23 16:12:11 +00:00
Par Winzell 07d848a3a0 Oops, we need to replicate what Depot does elsewhere to construct a database-unique identifier for the index. 2009-01-23 15:17:51 +00:00
Par Winzell c654606a2d Add a convenience migration for dropping indexes. 2009-01-23 15:05:08 +00:00
Par Winzell 0569f8f8ff The buildIndex() magic expects an array of colums, not a list. 2009-01-22 16:43:21 +00:00
Par Winzell 7dbc58d426 Function and Literal expressions can be non-deterministic but in most cases they are safe, and giving them proper toString()'s will help caching quite a bit. 2009-01-21 21:39:48 +00:00
Par Winzell 017d9242ac Better log message. 2009-01-12 15:13:34 +00:00
Par Winzell 062a8efcac Let the EHCache adapter be a little more configurable. 2009-01-10 01:47:11 +00:00
Par Winzell a5de1295f9 Let the EHCache adapter be a little more configurable. 2009-01-10 01:46:50 +00:00
Michael Bayne a8b3e24e87 Allow caching to be skipped for single record loads, ensure that we don't cache
DepotMigrationHistoryRecord.
2009-01-09 21:40:30 +00:00
Michael Bayne c46535cffd Nixed unused imports, variables. 2009-01-08 22:15:46 +00:00
Michael Bayne 53358e74c9 Nixed unused import. 2009-01-08 22:08:35 +00:00
Par Winzell 60c681ff74 Introduce a new cache strategy that does collection queries in two stages, but does not cache the keyset. This is a safe strategy, and we use it in places where an out-of-date result set is dangerous or annoying. 2009-01-08 18:22:40 +00:00
Michael Bayne 87b547743c Moved some implemention detail clauses into impl.claus. I'd like to move
SelectClause in there as well, but peskily two things on MSOY are using it to
do subselects. I'd prefer there was some less "reaching into the internals" way
to do subselects.
2009-01-08 02:31:28 +00:00
Michael Bayne a9c992bb44 Great big revampage: no more strings anywhere. It's all ColumnExps all the way
down (well, all the way to the public API anyway).

Revamped index creation while I was in there because that was one of the big
string users. Now you just put @Index on the field you want indexed, and if you
want a multi-column index you do things with a magical static method just like
we do for complex (function) indices.

@UniqueConstraint may still go away since it's basically exactly the same thing
as @Index(unique=true), so it's kind of pointless to support both.
2009-01-08 02:10:54 +00:00
Michael Bayne a66f15e355 Minor edits. 2009-01-07 19:36:43 +00:00
Par Winzell f5fc65f1e1 More cache configuration options for findAll(), especially a new CONTENTS strategy which will cache the entire result set of the supplied query, without the restrictions of the KEYS approach. This is very lovely and perhaps a little scary. 2009-01-07 19:32:24 +00:00
Par Winzell 269a3ffb92 Let's make this an insertion-ordered set so that all logically identical queries get assigned table abbreviations in the same order. This is mostly cosmetic, but has no significant cost. 2009-01-01 17:10:34 +00:00
Par Winzell 68aac7fd11 Progress notification during migration soothes the soul. 2009-01-01 15:47:42 +00:00
Par Winzell c41534c7e6 We need these two fellows for the previous patch to make sense. 2008-12-31 00:59:28 +00:00
Par Winzell 0ccd8bdb82 Extend our Index annotation to accept a 'complex' attribute. If an index ixFoo is marked complex for a given record, Depot will call the static method ixFooDefinition on that record class and expect a List<Tuple<SQLExpression, OrderBy.Order>> return value.
The purpose of all this is to create function (or expression, rather) indexes, which PostgreSQL does quite happily.
2008-12-31 00:25:29 +00:00
Michael Bayne e3aed39330 Document our thrown exceptions. 2008-12-16 00:00:52 +00:00
Par Winzell 44fd01cc2d Switch to nulls here, too, making migration work right for HSQLDB. 2008-12-10 23:02:34 +00:00