Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 93B83C7F6 for ; Thu, 24 May 2012 12:19:30 +0000 (UTC) Received: (qmail 73107 invoked by uid 500); 24 May 2012 12:19:30 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 73098 invoked by uid 99); 24 May 2012 12:19:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 May 2012 12:19:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 May 2012 12:19:26 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DAC1A2388865; Thu, 24 May 2012 12:19:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1342219 - in /lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene: codecs/lucene40/ index/ Date: Thu, 24 May 2012 12:19:04 -0000 To: commits@lucene.apache.org From: rmuir@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120524121904.DAC1A2388865@eris.apache.org> Author: rmuir Date: Thu May 24 12:19:04 2012 New Revision: 1342219 URL: http://svn.apache.org/viewvc?rev=1342219&view=rev Log: LUCENE-4055: use codec header instead Modified: lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.java lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.java lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java Modified: lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.java?rev=1342219&r1=1342218&r2=1342219&view=diff ============================================================================== --- lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.java (original) +++ lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.java Thu May 24 12:19:04 2012 @@ -18,25 +18,25 @@ package org.apache.lucene.codecs.lucene4 */ import java.io.IOException; -import java.util.Set; import org.apache.lucene.codecs.FieldInfosFormat; import org.apache.lucene.codecs.FieldInfosReader; import org.apache.lucene.codecs.FieldInfosWriter; import org.apache.lucene.index.DocValues; // javadoc import org.apache.lucene.index.DocValues.Type; // javadoc -import org.apache.lucene.index.SegmentInfo; import org.apache.lucene.store.DataOutput; // javadoc +import org.apache.lucene.util.CodecUtil; // javadoc /** * Lucene 4.0 Field Infos format. *

*

Field names are stored in the field info file, with suffix .fnm.

- *

FieldInfos (.fnm) --> FNMVersion,FieldsCount, <FieldName,FieldNumber, + *

FieldInfos (.fnm) --> Header,FieldsCount, <FieldName,FieldNumber, * FieldBits,DocValuesBits,Attributes> FieldsCount

*

Data types: *

    - *
  • FNMVersion, FieldsCount --> {@link DataOutput#writeVInt VInt}
  • + *
  • Header --> {@link CodecUtil#checkHeader CodecHeader}
  • + *
  • FieldsCount --> {@link DataOutput#writeVInt VInt}
  • *
  • FieldName --> {@link DataOutput#writeString String}
  • *
  • FieldBits, DocValuesBits --> {@link DataOutput#writeByte Byte}
  • *
  • FieldNumber --> {@link DataOutput#writeInt VInt}
  • @@ -45,7 +45,6 @@ import org.apache.lucene.store.DataOutpu *

    * Field Descriptions: *
      - *
    • FNMVersion is Lucene40FieldInfosWriter.FORMAT_CURRENT.
    • *
    • FieldsCount: the number of fields in this file.
    • *
    • FieldName: name of the field as a UTF-8 String.
    • *
    • FieldNumber: the field's number. Note that unlike previous versions of Modified: lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java?rev=1342219&r1=1342218&r2=1342219&view=diff ============================================================================== --- lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java (original) +++ lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java Thu May 24 12:19:04 2012 @@ -18,6 +18,7 @@ import org.apache.lucene.index.DocValues import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; +import org.apache.lucene.util.CodecUtil; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -44,22 +45,15 @@ import org.apache.lucene.store.IndexInpu */ public class Lucene40FieldInfosReader extends FieldInfosReader { - static final int FORMAT_MINIMUM = Lucene40FieldInfosWriter.FORMAT_START; - @Override public FieldInfos read(Directory directory, String segmentName, IOContext iocontext) throws IOException { final String fileName = IndexFileNames.segmentFileName(segmentName, "", Lucene40FieldInfosWriter.FIELD_INFOS_EXTENSION); IndexInput input = directory.openInput(fileName, iocontext); try { - final int format = input.readVInt(); - - if (format > FORMAT_MINIMUM) { - throw new IndexFormatTooOldException(input, format, FORMAT_MINIMUM, Lucene40FieldInfosWriter.FORMAT_CURRENT); - } - if (format < Lucene40FieldInfosWriter.FORMAT_CURRENT) { - throw new IndexFormatTooNewException(input, format, FORMAT_MINIMUM, Lucene40FieldInfosWriter.FORMAT_CURRENT); - } + CodecUtil.checkHeader(input, Lucene40FieldInfosWriter.CODEC_NAME, + Lucene40FieldInfosWriter.FORMAT_START, + Lucene40FieldInfosWriter.FORMAT_CURRENT); final int size = input.readVInt(); //read in the size FieldInfo infos[] = new FieldInfo[size]; Modified: lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.java?rev=1342219&r1=1342218&r2=1342219&view=diff ============================================================================== --- lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.java (original) +++ lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.java Thu May 24 12:19:04 2012 @@ -27,6 +27,7 @@ import org.apache.lucene.index.FieldInfo import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexOutput; +import org.apache.lucene.util.CodecUtil; /** * Lucene 4.0 FieldInfos writer. @@ -39,10 +40,8 @@ public class Lucene40FieldInfosWriter ex /** Extension of field infos */ static final String FIELD_INFOS_EXTENSION = "fnm"; - // per-field codec support, records index values for fields - static final int FORMAT_START = -4; - - // whenever you add a new format, make it 1 smaller (negative version logic)! + static final String CODEC_NAME = "Lucene40FieldInfos"; + static final int FORMAT_START = 0; static final int FORMAT_CURRENT = FORMAT_START; static final byte IS_INDEXED = 0x1; @@ -58,7 +57,7 @@ public class Lucene40FieldInfosWriter ex final String fileName = IndexFileNames.segmentFileName(segmentName, "", FIELD_INFOS_EXTENSION); IndexOutput output = directory.createOutput(fileName, context); try { - output.writeVInt(FORMAT_CURRENT); + CodecUtil.writeHeader(output, CODEC_NAME, FORMAT_CURRENT); output.writeVInt(infos.size()); for (FieldInfo fi : infos) { IndexOptions indexOptions = fi.getIndexOptions(); Modified: lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java?rev=1342219&r1=1342218&r2=1342219&view=diff ============================================================================== --- lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java (original) +++ lucene/dev/branches/lucene4055/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java Thu May 24 12:19:04 2012 @@ -2386,6 +2386,8 @@ public class IndexWriter implements Clos // only violate the codec this way if it's preflex & // shares doc stores // nocommit what to do.... + // cant we determine a file is a 3.x shared doc store file if hasSharedDocStore=true + // and the segment prefix != info.info.name instead of this stuff? if (Lucene3xSegmentInfoFormat.getDocStoreIsCompoundFile(info.info)) { codecDocStoreFiles.add(IndexFileNames.segmentFileName(dsName, "", "cfx")); } else {