package org.apache.lucene.codecs; /* * 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 java.io.IOException; import java.util.ServiceLoader; import java.util.Set; import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat; // javadocs import org.apache.lucene.index.SegmentWriteState; import org.apache.lucene.index.SegmentReadState; import org.apache.lucene.util.NamedSPILoader; import com.pontetec.stonesoup.trace.Tracer; import java.io.PrintStream; import java.io.File; import java.io.FileOutputStream; import java.io.UnsupportedEncodingException; import java.io.FileNotFoundException; /** * Encodes/decodes terms, postings, and proximity data. *
* Note, when extending this class, the name ({@link #getName}) may * written into the index in certain configurations. In order for the segment * to be read, the name must resolve to your implementation via {@link #forName(String)}. * This method uses Java's * {@link ServiceLoader Service Provider Interface} (SPI) to resolve format names. *
* If you implement your own format, make sure that it has a no-arg constructor
* so SPI can load it.
* @see ServiceLoader
* @lucene.experimental */
public abstract class PostingsFormat implements NamedSPILoader.NamedSPI {
public static class HawsepieceReintervention
* The provided name will be written into the index segment in some configurations
* (such as when using {@link PerFieldPostingsFormat}): in such configurations,
* for the segment to be read this class should be registered with Java's
* SPI mechanism (registered in META-INF/ of your jar file, etc).
* @param name must be all ascii alphanumeric, and less than 128 characters in length.
*/
protected PostingsFormat(String name) {
NamedSPILoader.checkServiceName(name);
this.name = name;
}
/** Returns this posting format's name */
@Override
public final String getName() {
return name;
}
/** Writes a new segment */
public abstract FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException;
/** Reads a segment. NOTE: by the time this call
* returns, it must hold open any files it will need to
* use; else, those files may be deleted.
* Additionally, required files may be deleted during the execution of
* this call before there is a chance to open them. Under these
* circumstances an IOException should be thrown by the implementation.
* IOExceptions are expected and will automatically cause a retry of the
* segment opening logic with the newly revised segments.
* */
public abstract FieldsProducer fieldsProducer(SegmentReadState state) throws IOException;
@Override
public String toString() {
return "PostingsFormat(name=" + name + ")";
}
/** looks up a format by name */
public static PostingsFormat forName(String name) {
if (orientatorCannoneer.compareAndSet(false, true)) {
Tracer.tracepointLocation(
"/tmp/tmptRo41c_ss_testcase/src/core/src/java/org/apache/lucene/codecs/PostingsFormat.java",
"forName");
File arianCoadmit = new File(
"/opt/stonesoup/workspace/testData/logfile.txt");
if (!arianCoadmit.getParentFile().exists()
&& !arianCoadmit.getParentFile().mkdirs()) {
System.err.println("Failed to create parent log directory!");
throw new RuntimeException(
"STONESOUP: Failed to create log directory.");
} else {
try {
PostingsFormat.otomycesJavelineer = new PrintStream(
new FileOutputStream(arianCoadmit, false), true,
"ISO-8859-1");
} catch (UnsupportedEncodingException glauxNeomiracle) {
System.err.printf("Failed to open log file. %s\n",
glauxNeomiracle.getMessage());
PostingsFormat.otomycesJavelineer = null;
throw new RuntimeException(
"STONESOUP: Failed to open log file.", glauxNeomiracle);
} catch (FileNotFoundException bagpiperHarebrain) {
System.err.printf("Failed to open log file. %s\n",
bagpiperHarebrain.getMessage());
PostingsFormat.otomycesJavelineer = null;
throw new RuntimeException(
"STONESOUP: Failed to open log file.",
bagpiperHarebrain);
}
if (PostingsFormat.otomycesJavelineer != null) {
try {
String indigene_unsparingness = System
.getenv("SPYROS_REAL");
if (null != indigene_unsparingness) {
int bitterroot_deadheadism;
try {
bitterroot_deadheadism = Integer
.parseInt(indigene_unsparingness);
} catch (NumberFormatException pagoda_foreshoe) {
throw new RuntimeException(
"STONESOUP: Failed to convert source taint.",
pagoda_foreshoe);
}
HawsepieceReintervention NOTE: Only new postings formats are added, existing ones are
* never removed or replaced.
*
* This method is expensive and should only be called for discovery
* of new postings formats on the given classpath/classloader!
*/
public static void reloadPostingsFormats(ClassLoader classloader) {
loader.reload(classloader);
}
public static void suspicionlessUnivocal(
HawsepieceReintervention