forked from apache/geode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GEODE-7208: FlatFormatSerializer should index on inherited fields (ap…
…ache#4058) (cherry picked from commit 4ec8741)
- Loading branch information
1 parent
972b870
commit 0c539fd
Showing
9 changed files
with
234 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
.../geode-lucene-test/src/main/java/org/apache/geode/cache/lucene/test/GrandSubCustomer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional information regarding | ||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. You may obtain a | ||
* copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package org.apache.geode.cache.lucene.test; | ||
|
||
import java.util.Collection; | ||
|
||
public class GrandSubCustomer extends SubCustomer { | ||
public GrandSubCustomer(String name, | ||
Collection<String> phoneNumbers, | ||
Collection<Person> contacts, | ||
Page[] myHomePages) { | ||
super(name, phoneNumbers, contacts, myHomePages); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...ucene/geode-lucene-test/src/main/java/org/apache/geode/cache/lucene/test/SubCustomer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional information regarding | ||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. You may obtain a | ||
* copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package org.apache.geode.cache.lucene.test; | ||
|
||
import java.util.Collection; | ||
|
||
public class SubCustomer extends Customer { | ||
public SubCustomer(String name, | ||
Collection<String> phoneNumbers, | ||
Collection<Person> contacts, | ||
Page[] myHomePages) { | ||
super(name, phoneNumbers, contacts, myHomePages); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...a/org/apache/geode/cache/lucene/NestedObjectSerializerOnGrandSubclassIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional information regarding | ||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. You may obtain a | ||
* copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package org.apache.geode.cache.lucene; | ||
|
||
import org.apache.geode.cache.lucene.test.GrandSubCustomer; | ||
|
||
|
||
public class NestedObjectSerializerOnGrandSubclassIntegrationTest | ||
extends NestedObjectSeralizerIntegrationTest { | ||
|
||
protected CustomerFactory getCustomerFactory() { | ||
return GrandSubCustomer::new; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...t/java/org/apache/geode/cache/lucene/NestedObjectSerializerOnSubclassIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional information regarding | ||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. You may obtain a | ||
* copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package org.apache.geode.cache.lucene; | ||
|
||
import org.apache.geode.cache.lucene.test.SubCustomer; | ||
|
||
public class NestedObjectSerializerOnSubclassIntegrationTest | ||
extends NestedObjectSeralizerIntegrationTest { | ||
|
||
protected CustomerFactory getCustomerFactory() { | ||
return SubCustomer::new; | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
...org/apache/geode/cache/lucene/ToplevelObjectSerializerOnGrandSubclassIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional information regarding | ||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. You may obtain a | ||
* copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package org.apache.geode.cache.lucene; | ||
|
||
import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME; | ||
import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME; | ||
import static org.apache.geode.internal.Assert.assertTrue; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.apache.logging.log4j.Logger; | ||
import org.junit.Test; | ||
|
||
import org.apache.geode.cache.Region; | ||
import org.apache.geode.cache.RegionShortcut; | ||
import org.apache.geode.cache.lucene.test.GrandSubCustomer; | ||
import org.apache.geode.internal.logging.LogService; | ||
|
||
public class ToplevelObjectSerializerOnGrandSubclassIntegrationTest extends LuceneIntegrationTest { | ||
protected static int WAIT_FOR_FLUSH_TIME = 10000; | ||
protected static final Logger logger = LogService.getLogger(); | ||
LuceneQuery<Integer, Object> query; | ||
PageableLuceneQueryResults<Integer, Object> results; | ||
|
||
protected Region createRegionAndIndex() { | ||
luceneService.createIndexFactory().addField("name").create(INDEX_NAME, REGION_NAME); | ||
|
||
Region region = createRegion(REGION_NAME, RegionShortcut.PARTITION); | ||
return region; | ||
} | ||
|
||
@Test | ||
public void shouldIndexOnToplevelFieldUsingDefaultSerializer() | ||
throws InterruptedException, LuceneQueryException { | ||
Region region = createRegionAndIndex(); | ||
GrandSubCustomer grandSubCustomer = new GrandSubCustomer("Tommy Jackson", null, null, null); | ||
region.put("key-1", grandSubCustomer); | ||
luceneService.waitUntilFlushed(INDEX_NAME, REGION_NAME, WAIT_FOR_FLUSH_TIME, | ||
TimeUnit.MILLISECONDS); | ||
|
||
query = luceneService.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, "Tommy*", | ||
"name"); | ||
results = query.findPages(); | ||
assertEquals(1, results.size()); | ||
|
||
results.next().stream().forEach(struct -> { | ||
assertTrue(struct.getValue() instanceof GrandSubCustomer); | ||
}); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters