mirror of
https://github.com/google/nomulus.git
synced 2025-08-04 08:52:12 +02:00
Save bloom filters for premium list entries
This is the first step in the migration to remove the need to load all of the premium list entries every time the cache expires (which causes slow- downs). Once this is deployed, we can re-save all premium lists, creating the bloom filters, and then the next step will be to read from them to more efficiently determine if a label might be premium. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=147525017
This commit is contained in:
parent
cdadb54acd
commit
e8c5720826
8 changed files with 188 additions and 16 deletions
|
@ -15,6 +15,7 @@
|
|||
package google.registry.model.registry.label;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.label.PremiumList.getPremiumPrice;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
|
@ -54,13 +55,14 @@ public class PremiumListTest {
|
|||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
// createTld() overwrites the premium list, so call it first.
|
||||
createTld("tld");
|
||||
PremiumList pl = persistPremiumList(
|
||||
"tld",
|
||||
"lol,USD 999 # yup",
|
||||
"rich,USD 1999 #tada",
|
||||
"icann,JPY 100",
|
||||
"johnny-be-goode,USD 20.50");
|
||||
createTld("tld");
|
||||
persistResource(Registry.get("tld").asBuilder().setPremiumList(pl).build());
|
||||
}
|
||||
|
||||
|
@ -260,6 +262,17 @@ public class PremiumListTest {
|
|||
.isNotEqualTo(pl.getRevisionKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProbablePremiumLabels() throws Exception {
|
||||
PremiumList pl = PremiumList.get("tld").get();
|
||||
assertThat(pl.getRevision().probablePremiumLabels.mightContain("notpremium")).isFalse();
|
||||
for (String label : ImmutableList.of("rich", "lol", "johnny-be-goode", "icann")) {
|
||||
assertWithMessage(label + " should be a probable premium")
|
||||
.that(pl.getRevision().probablePremiumLabels.mightContain(label))
|
||||
.isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
/** Persists a premium list with a specified number of nonsense entries. */
|
||||
private PremiumList persistHumongousPremiumList(String name, int size) {
|
||||
String[] entries = new String[size];
|
||||
|
|
|
@ -742,6 +742,7 @@ class google.registry.model.registry.label.PremiumList$PremiumListEntry {
|
|||
class google.registry.model.registry.label.PremiumList$PremiumListRevision {
|
||||
@Id long revisionId;
|
||||
@Parent com.googlecode.objectify.Key<google.registry.model.registry.label.PremiumList> parent;
|
||||
com.google.common.hash.BloomFilter<java.lang.String> probablePremiumLabels;
|
||||
}
|
||||
enum google.registry.model.registry.label.ReservationType {
|
||||
ALLOWED_IN_SUNRISE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue