ant test -Dtestcase=TestDemoDocValue -Dtests.codec=SimpleText

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1409644 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2012-11-15 03:59:36 +00:00
parent 9a3c403b26
commit 88c85749bf
4 changed files with 27 additions and 4 deletions

View File

@ -24,6 +24,7 @@ import org.apache.lucene.codecs.LiveDocsFormat;
import org.apache.lucene.codecs.NormsFormat;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.SegmentInfoFormat;
import org.apache.lucene.codecs.SimpleDocValuesFormat;
import org.apache.lucene.codecs.StoredFieldsFormat;
import org.apache.lucene.codecs.TermVectorsFormat;
@ -88,4 +89,13 @@ public final class SimpleTextCodec extends Codec {
public LiveDocsFormat liveDocsFormat() {
return liveDocs;
}
// nocommit;
private final SimpleDocValuesFormat nocommit = new SimpleTextSimpleDocValuesFormat();
@Override
public SimpleDocValuesFormat simpleDocValuesFormat() {
return nocommit;
}
}

View File

@ -369,6 +369,7 @@ public class SimpleTextSimpleDocValuesFormat extends SimpleDocValuesFormat {
readLine();
assert startsWith(PATTERN);
field.pattern = stripPrefix(PATTERN);
field.dataStartFilePointer = data.getFilePointer();
data.seek(data.getFilePointer() + (1+field.pattern.length()) * maxDoc);
} else if (DocValues.isBytes(dvType)) {
readLine();
@ -377,6 +378,7 @@ public class SimpleTextSimpleDocValuesFormat extends SimpleDocValuesFormat {
readLine();
assert startsWith(PATTERN);
field.pattern = stripPrefix(PATTERN);
field.dataStartFilePointer = data.getFilePointer();
data.seek(data.getFilePointer() + (9+field.pattern.length()+field.maxLength) * maxDoc);
break;
} else if (DocValues.isSortedBytes(dvType)) {
@ -392,12 +394,13 @@ public class SimpleTextSimpleDocValuesFormat extends SimpleDocValuesFormat {
readLine();
assert startsWith(ORDPATTERN);
field.ordPattern = stripPrefix(ORDPATTERN);
field.dataStartFilePointer = data.getFilePointer();
// nocommit: we need to seek past the data section!!!!
} else if (DocValues.isFloat(dvType)) {
// nocommit
} else {
throw new AssertionError();
}
field.dataStartFilePointer = data.getFilePointer();
}
}
@ -515,7 +518,15 @@ public class SimpleTextSimpleDocValuesFormat extends SimpleDocValuesFormat {
// value from the wrong field ...
in.seek(field.dataStartFilePointer + (1+field.pattern.length())*docID);
SimpleTextUtil.readLine(in, scratch);
return decoder.parse(scratch.utf8ToString(), pos).longValue();
System.out.println("trying to parse number: " + scratch.utf8ToString());
// nocommit
long seekPos = field.dataStartFilePointer;
byte wholeFile[] = new byte[(int)(in.length()-seekPos)];
IndexInput foo = in.clone();
foo.seek(seekPos);
foo.readBytes(wholeFile, 0, wholeFile.length);
System.out.println("rest: " + new String(wholeFile, 0, wholeFile.length, "UTF-8"));
return field.minValue + decoder.parse(scratch.utf8ToString(), pos).longValue();
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}

View File

@ -147,7 +147,8 @@ final class DocFieldProcessor extends DocConsumer {
}
// close perDocConsumer during flush to ensure all files are flushed due to PerCodec CFS
IOUtils.close(perDocConsumer);
// nocommit
IOUtils.close(perDocConsumer, dvConsumer);
// Important to save after asking consumer to flush so
// consumer can alter the FieldInfo* if necessary. EG,

View File

@ -110,7 +110,8 @@ final class SegmentCoreReaders {
// TODO: since we don't write any norms file if there are no norms,
// kinda jaky to assume the codec handles the case of no norms file at all gracefully?!
norms = codec.normsFormat().docsProducer(segmentReadState);
perDocProducer = codec.docValuesFormat().docsProducer(segmentReadState);
// nocommit
perDocProducer = codec.simpleDocValuesFormat().fieldsProducer(segmentReadState);
fieldsReaderOrig = si.info.getCodec().storedFieldsFormat().fieldsReader(cfsDir, si.info, fieldInfos, context);