|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SetBasedFieldSelector | Line # 24 | 8 | 4 | 100% |
1.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (2) | |||
| Result | |||
|
1.0
|
org.apache.lucene.index.TestFieldsReader.testLazyFields
org.apache.lucene.index.TestFieldsReader.testLazyFields
|
1 PASS | |
|
0.85714287
|
org.apache.lucene.index.TestFieldsReader.testLazyPerformance
org.apache.lucene.index.TestFieldsReader.testLazyPerformance
|
1 PASS | |
| 1 | package org.apache.lucene.document; | |
| 2 | ||
| 3 | import java.util.Set; | |
| 4 | /** | |
| 5 | * Copyright 2004 The Apache Software Foundation | |
| 6 | * | |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 8 | * you may not use this file except in compliance with the License. | |
| 9 | * You may obtain a copy of the License at | |
| 10 | * | |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 12 | * | |
| 13 | * Unless required by applicable law or agreed to in writing, software | |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 16 | * See the License for the specific language governing permissions and | |
| 17 | * limitations under the License. | |
| 18 | */ | |
| 19 | ||
| 20 | /** | |
| 21 | * Declare what fields to load normally and what fields to load lazily | |
| 22 | * | |
| 23 | **/ | |
| 24 | public class SetBasedFieldSelector implements FieldSelector { | |
| 25 | ||
| 26 | private Set fieldsToLoad; | |
| 27 | private Set lazyFieldsToLoad; | |
| 28 | ||
| 29 | ||
| 30 | ||
| 31 | /** | |
| 32 | * Pass in the Set of {@link Field} names to load and the Set of {@link Field} names to load lazily. If both are null, the | |
| 33 | * Document will not have any {@link Field} on it. | |
| 34 | * @param fieldsToLoad A Set of {@link String} field names to load. May be empty, but not null | |
| 35 | * @param lazyFieldsToLoad A Set of {@link String} field names to load lazily. May be empty, but not null | |
| 36 | */ | |
| 37 | 2 |
public SetBasedFieldSelector(Set fieldsToLoad, Set lazyFieldsToLoad) { |
| 38 | 2 | this.fieldsToLoad = fieldsToLoad; |
| 39 | 2 | this.lazyFieldsToLoad = lazyFieldsToLoad; |
| 40 | } | |
| 41 | ||
| 42 | /** | |
| 43 | * Indicate whether to load the field with the given name or not. If the {@link Field#name()} is not in either of the | |
| 44 | * initializing Sets, then {@link org.apache.lucene.document.FieldSelectorResult#NO_LOAD} is returned. If a Field name | |
| 45 | * is in both <code>fieldsToLoad</code> and <code>lazyFieldsToLoad</code>, lazy has precedence. | |
| 46 | * | |
| 47 | * @param fieldName The {@link Field} name to check | |
| 48 | * @return The {@link FieldSelectorResult} | |
| 49 | */ | |
| 50 | 612 |
public FieldSelectorResult accept(String fieldName) { |
| 51 | 612 | FieldSelectorResult result = FieldSelectorResult.NO_LOAD; |
| 52 | 612 | if (fieldsToLoad.contains(fieldName) == true){ |
| 53 | 2 | result = FieldSelectorResult.LOAD; |
| 54 | } | |
| 55 | 612 | if (lazyFieldsToLoad.contains(fieldName) == true){ |
| 56 | 54 | result = FieldSelectorResult.LAZY_LOAD; |
| 57 | } | |
| 58 | 612 | return result; |
| 59 | } | |
| 60 | } | |
|
||||||||||