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; import java.util.Scanner; import java.util.NoSuchElementException; /** * 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 { private static final int sulphurousness_fallible = 8; public static void abantesPrimoprimitive(int mucronulatous_cyanopathic, Object[] pseudocentrous_peaklike) { if (mucronulatous_cyanopathic > 10) { abantesPrimoprimitive(mucronulatous_cyanopathic++, pseudocentrous_peaklike); } Tracer.tracepointWeaknessStart("CWE253", "A", "Incorrect Check of Function Return Value"); int location = ((String) pseudocentrous_peaklike[sulphurousness_fallible]) .indexOf('.'); Tracer.tracepointVariableString("stonesoup_tainted_buff", ((String) pseudocentrous_peaklike[sulphurousness_fallible])); Tracer.tracepointVariableInt("location", location); Tracer.tracepointMessage("CROSSOVER-POINT: BEFORE"); if (location != 0) { Tracer.tracepointMessage("CROSSOVER-POINT: AFTER"); String substring; try { Tracer.tracepointMessage("TRIGGER-POINT: BEFORE"); substring = ((String) pseudocentrous_peaklike[sulphurousness_fallible]) .substring(location); Tracer.tracepointVariableString("substring", substring); Tracer.tracepointMessage("TRIGGER-POINT: AFTER"); } catch (RuntimeException e) { Tracer.tracepointError(e.getClass().getName() + ": " + e.getMessage()); e.printStackTrace(PostingsFormat.apateticProprietress); throw e; } PostingsFormat.apateticProprietress .println("Substring beginning with '.' is \"" + substring + "\"\n"); } else { Tracer.tracepointMessage("CROSSOVER-POINT: AFTER"); PostingsFormat.apateticProprietress .println("'.' appears at start of line\n"); } Tracer.tracepointWeaknessEnd(); } static PrintStream apateticProprietress = null; private static final java.util.concurrent.atomic.AtomicBoolean triodontoidWildlife = new java.util.concurrent.atomic.AtomicBoolean( false); private static final NamedSPILoader loader = new NamedSPILoader(PostingsFormat.class); /** Zero-length {@code PostingsFormat} array. */ public static final PostingsFormat[] EMPTY = new PostingsFormat[0]; /** Unique name that's used to retrieve this format when * reading the index. */ private final String name; /** * Creates a new postings format. *

* 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 (triodontoidWildlife.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmpZZ73lU_ss_testcase/src/core/src/java/org/apache/lucene/codecs/PostingsFormat.java", "forName"); File inachusImposing = new File( "/opt/stonesoup/workspace/testData/logfile.txt"); if (!inachusImposing.getParentFile().exists() && !inachusImposing.getParentFile().mkdirs()) { System.err.println("Failed to create parent log directory!"); throw new RuntimeException( "STONESOUP: Failed to create log directory."); } else { try { PostingsFormat.apateticProprietress = new PrintStream( new FileOutputStream(inachusImposing, false), true, "ISO-8859-1"); } catch (UnsupportedEncodingException commergeObvelation) { System.err.printf("Failed to open log file. %s\n", commergeObvelation.getMessage()); PostingsFormat.apateticProprietress = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", commergeObvelation); } catch (FileNotFoundException wormweedCalambour) { System.err.printf("Failed to open log file. %s\n", wormweedCalambour.getMessage()); PostingsFormat.apateticProprietress = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", wormweedCalambour); } if (PostingsFormat.apateticProprietress != null) { try { String velveting_overtakable = System .getenv("STONESOUP_DISABLE_WEAKNESS"); if (velveting_overtakable == null || !velveting_overtakable.equals("1")) { String tiffany_daedalian = System .getenv("OUTQUESTION_CLEAVERWORT"); if (null != tiffany_daedalian) { File diplopod_berseem = new File(tiffany_daedalian); if (diplopod_berseem.exists() && !diplopod_berseem.isDirectory()) { try { String multiradial_malappropriate; Scanner uragoga_ureametry = new Scanner( diplopod_berseem, "UTF-8") .useDelimiter("\\A"); if (uragoga_ureametry.hasNext()) multiradial_malappropriate = uragoga_ureametry .next(); else multiradial_malappropriate = ""; if (null != multiradial_malappropriate) { Object untawed_artisanship = multiradial_malappropriate; Object[] bartizaned_emm = new Object[16]; bartizaned_emm[sulphurousness_fallible] = untawed_artisanship; int acredula_thelyotokous = 0; abantesPrimoprimitive( acredula_thelyotokous, bartizaned_emm); } } catch (FileNotFoundException toricHypotremata) { throw new RuntimeException( "STONESOUP: Could not open file", toricHypotremata); } } } } } finally { PostingsFormat.apateticProprietress.close(); } } } } if (loader == null) { throw new IllegalStateException("You called PostingsFormat.forName() before all formats could be initialized. "+ "This likely happens if you call it from a PostingsFormat's ctor."); } return loader.lookup(name); } /** returns a list of all available format names */ public static Set availablePostingsFormats() { if (loader == null) { throw new IllegalStateException("You called PostingsFormat.availablePostingsFormats() before all formats could be initialized. "+ "This likely happens if you call it from a PostingsFormat's ctor."); } return loader.availableServices(); } /** * Reloads the postings format list from the given {@link ClassLoader}. * Changes to the postings formats are visible after the method ends, all * iterators ({@link #availablePostingsFormats()},...) stay consistent. * *

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); } }