forked from mdodsworth/lucene-solr
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LUCENE-3077: fix trapping DV sugar field ctors
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1336617 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
1 parent
632fac4
commit 421ee98
Showing
33 changed files
with
984 additions
and
307 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
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
49 changes: 49 additions & 0 deletions
49
lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.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,49 @@ | ||
package org.apache.lucene.document; | ||
|
||
/** | ||
* 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. | ||
*/ | ||
|
||
import org.apache.lucene.index.DocValues; | ||
|
||
/** | ||
* <p> | ||
* This class provides a {@link Field} that enables storing | ||
* of a per-document byte value for scoring, sorting or value retrieval. Here's an | ||
* example usage: | ||
* | ||
* <pre> | ||
* document.add(new ByteDocValuesField(name, (byte) 22)); | ||
* </pre> | ||
* | ||
* <p> | ||
* If you also need to store the value, you should add a | ||
* separate {@link StoredField} instance. | ||
* */ | ||
|
||
public class ByteDocValuesField extends Field { | ||
|
||
public static final FieldType TYPE = new FieldType(); | ||
static { | ||
TYPE.setDocValueType(DocValues.Type.FIXED_INTS_8); | ||
TYPE.freeze(); | ||
} | ||
|
||
public ByteDocValuesField(String name, byte value) { | ||
super(name, TYPE); | ||
fieldsData = Byte.valueOf(value); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.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,66 @@ | ||
package org.apache.lucene.document; | ||
|
||
/** | ||
* 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. | ||
*/ | ||
|
||
import org.apache.lucene.index.DocValues; | ||
import org.apache.lucene.util.BytesRef; | ||
|
||
/** | ||
* <p> | ||
* This class provides a {@link Field} that enables storing | ||
* of a per-document {@link BytesRef} value. The values are | ||
* stored indirectly, such that many documents sharing the | ||
* same value all point to a single copy of the value, which | ||
* is a good fit when the fields share values. If values | ||
* are (mostly) unique it's better to use {@link | ||
* StraightBytesDocValuesField}. Here's an example usage: | ||
* | ||
* <pre> | ||
* document.add(new DerefBytesDocValuesField(name, new BytesRef("hello"))); | ||
* </pre> | ||
* | ||
* <p> | ||
* If you also need to store the value, you should add a | ||
* separate {@link StoredField} instance. | ||
* */ | ||
|
||
public class DerefBytesDocValuesField extends Field { | ||
|
||
// TODO: ideally indexer figures out var vs fixed on its own!? | ||
public static final FieldType TYPE_FIXED_LEN = new FieldType(); | ||
static { | ||
TYPE_FIXED_LEN.setDocValueType(DocValues.Type.BYTES_FIXED_DEREF); | ||
TYPE_FIXED_LEN.freeze(); | ||
} | ||
|
||
public static final FieldType TYPE_VAR_LEN = new FieldType(); | ||
static { | ||
TYPE_VAR_LEN.setDocValueType(DocValues.Type.BYTES_VAR_DEREF); | ||
TYPE_VAR_LEN.freeze(); | ||
} | ||
|
||
public DerefBytesDocValuesField(String name, BytesRef bytes) { | ||
super(name, TYPE_VAR_LEN); | ||
fieldsData = bytes; | ||
} | ||
|
||
public DerefBytesDocValuesField(String name, BytesRef bytes, boolean isFixedLength) { | ||
super(name, isFixedLength ? TYPE_FIXED_LEN : TYPE_VAR_LEN); | ||
fieldsData = bytes; | ||
} | ||
} |
131 changes: 0 additions & 131 deletions
131
lucene/core/src/java/org/apache/lucene/document/DocValuesField.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.