@@ -0,0 +1,3027 @@
+package org.apache.lucene.index;%0A%0A/**%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Aimport org.apache.lucene.search.Similarity;%0Aimport org.apache.lucene.util.ReaderUtil;%0A%0A/**%0A * Exposes flex API, merged from flex API of sub-segments.%0A * This is useful when you're interacting with an %7B@link%0A * IndexReader%7D implementation that consists of sequential%0A * sub-readers (eg DirectoryReader or %7B@link%0A * MultiReader%7D).%0A *%0A * %3Cp%3E%3Cb%3ENOTE%3C/b%3E: for multi readers, you'll get better%0A * performance by gathering the sub readers using %7B@link%0A * ReaderUtil#gatherSubReaders%7D and then operate per-reader,%0A * instead of using this class.%0A *%0A * @lucene.experimental%0A */%0Apublic class MultiNorms %7B%0A  /**%0A   * Warning: this is heavy! Do not use in a loop, or implement norms()%0A   * in your own reader with this (you should likely cache the result).%0A   */%0A  public static byte%5B%5D norms(IndexReader r, String field) throws IOException %7B%0A    final IndexReader%5B%5D subs = r.getSequentialSubReaders();%0A    if (subs == null) %7B%0A      // already an atomic reader%0A      return r.norms(field);%0A    %7D else if (subs.length == 0 %7C%7C !r.hasNorms(field)) %7B%0A      // no norms%0A      return null;%0A    %7D else if (subs.length == 1) %7B%0A      return norms(subs%5B0%5D, field);%0A    %7D else %7B%0A      // TODO: optimize more maybe%0A      byte norms%5B%5D = new byte%5Br.maxDoc()%5D;%0A      final List%3CIndexReader%3E leaves = new ArrayList%3CIndexReader%3E();%0A      ReaderUtil.gatherSubReaders(leaves, r);%0A      int end = 0;%0A      for (IndexReader leaf : leaves) %7B%0A        int start = end;%0A        leaf.norms(field, norms, start);%0A        end += leaf.maxDoc();%0A      %7D%0A      return norms;%0A    %7D%0A  %7D%0A  %0A  /**%0A   * Warning: this is heavy! Do not use in a loop, or implement norms()%0A   * in your own reader with this (you should likely cache the result).%0A   */%0A  public static void norms(IndexReader r, String field, byte%5B%5D bytes, int offset)%0A      throws IOException %7B%0A    // TODO: optimize more maybe%0A    byte%5B%5D norms = norms(r, field);%0A    if (norms == null) %7B%0A      Arrays.fill(bytes, offset, bytes.length, Similarity.getDefault().encodeNormValue(1.0f));%0A    %7D else %7B%0A      System.arraycopy(norms, 0, bytes, offset, r.maxDoc());%0A    %7D%0A  %7D%0A%7D%0A

add MultiNorms (forgot to svn add)