Support pagination using offsets instead of sortkey
We cannot guarantee that secondary index implementations (particularly the one used by googlesource.com) can efficiently paginate based on the sortkey, and in particular can both sort and reverse sort on the same field. This particular performance issue notwithstanding, searching is now generally fast enough that it is feasible just to skip the first N results when doing pagination. Add an option S= to QueryChanges to support starting at a nonzero offset. Note that we still have to fetch n+S results from the index in order to do visibility filtering, since if we skipped at the index layer we wouldn't know how many of the skipped elements would have matched later filtering. Drop the sortkey token suffix from the legacy anchor parser; there is no reliable way to convert it to an offset, and it's unlikely that users have permalinks to specific sortkey values. On the server side, remove the sortkey field from the current index version, and use pagination by offset instead of sortkey in the new version only. Continue to support sortkey queries against old index versions, to support online reindexing while clients have an older JS version. Change-Id: I6a82965db02c4d534e2107ca6ec91217085124d6
This commit is contained in:
@@ -115,10 +115,24 @@ public class ChangeField {
|
||||
}
|
||||
};
|
||||
|
||||
// Same value as UPDATED, but implementations truncated to minutes.
|
||||
@Deprecated
|
||||
/** Last update time since January 1, 1970. */
|
||||
public static final FieldDef<ChangeData, Timestamp> LEGACY_UPDATED =
|
||||
new FieldDef.Single<ChangeData, Timestamp>(
|
||||
"updated", FieldType.TIMESTAMP, true) {
|
||||
@Override
|
||||
public Timestamp get(ChangeData input, FillArgs args)
|
||||
throws OrmException {
|
||||
return input.change().getLastUpdatedOn();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** Last update time since January 1, 1970. */
|
||||
public static final FieldDef<ChangeData, Timestamp> UPDATED =
|
||||
new FieldDef.Single<ChangeData, Timestamp>(
|
||||
"updated", FieldType.TIMESTAMP, true) {
|
||||
"updated2", FieldType.TIMESTAMP, true) {
|
||||
@Override
|
||||
public Timestamp get(ChangeData input, FillArgs args)
|
||||
throws OrmException {
|
||||
@@ -152,6 +166,7 @@ public class ChangeField {
|
||||
* Redundant with {@link #UPDATED} and {@link #LEGACY_ID}, but secondary index
|
||||
* implementations may not be able to search over tuples of values.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final FieldDef<ChangeData, Long> SORTKEY =
|
||||
new FieldDef.Single<ChangeData, Long>(
|
||||
"sortkey2", FieldType.LONG, true) {
|
||||
|
||||
Reference in New Issue
Block a user