Methods Summary |
---|
public void | add(org.apache.lucene.document.Document doc)Adds field info for a Document.
Enumeration fields = doc.fields();
while (fields.hasMoreElements()) {
Field field = (Field) fields.nextElement();
add(field.name(), field.isIndexed(), field.isTermVectorStored());
}
|
public void | add(java.util.Collection names, boolean isIndexed)Assumes the field is not storing term vectors
Iterator i = names.iterator();
int j = 0;
while (i.hasNext()) {
add((String)i.next(), isIndexed);
}
|
public void | add(java.lang.String name, boolean isIndexed)Calls three parameter add with false for the storeTermVector parameter
add(name, isIndexed, false);
|
public void | add(java.lang.String name, boolean isIndexed, boolean storeTermVector)If the field is not yet known, adds it. If it is known, checks to make
sure that the isIndexed flag is the same as was given previously for this
field. If not - marks it as being indexed. Same goes for storeTermVector
FieldInfo fi = fieldInfo(name);
if (fi == null) {
addInternal(name, isIndexed, storeTermVector);
} else {
if (fi.isIndexed != isIndexed) {
fi.isIndexed = true; // once indexed, always index
}
if (fi.storeTermVector != storeTermVector) {
fi.storeTermVector = true; // once vector, always vector
}
}
|
public void | addIndexed(java.util.Collection names, boolean storeTermVectors)
Iterator i = names.iterator();
int j = 0;
while (i.hasNext()) {
add((String)i.next(), true, storeTermVectors);
}
|
private void | addInternal(java.lang.String name, boolean isIndexed, boolean storeTermVector)
FieldInfo fi =
new FieldInfo(name, isIndexed, byNumber.size(), storeTermVector);
byNumber.add(fi);
byName.put(name, fi);
|
public org.apache.lucene.index.FieldInfo | fieldInfo(java.lang.String fieldName)
return (FieldInfo) byName.get(fieldName);
|
public org.apache.lucene.index.FieldInfo | fieldInfo(int fieldNumber)
return (FieldInfo) byNumber.get(fieldNumber);
|
public java.lang.String | fieldName(int fieldNumber)
return fieldInfo(fieldNumber).name;
|
public int | fieldNumber(java.lang.String fieldName)
FieldInfo fi = fieldInfo(fieldName);
if (fi != null)
return fi.number;
else
return -1;
|
public boolean | hasVectors()
boolean hasVectors = false;
for (int i = 0; i < size(); i++) {
if (fieldInfo(i).storeTermVector)
hasVectors = true;
}
return hasVectors;
|
private void | read(org.apache.lucene.store.InputStream input)
int size = input.readVInt();//read in the size
for (int i = 0; i < size; i++) {
String name = input.readString().intern();
byte bits = input.readByte();
boolean isIndexed = (bits & 0x1) != 0;
boolean storeTermVector = (bits & 0x2) != 0;
addInternal(name, isIndexed, storeTermVector);
}
|
public int | size()
return byNumber.size();
|
public void | write(org.apache.lucene.store.Directory d, java.lang.String name)
OutputStream output = d.createFile(name);
try {
write(output);
} finally {
output.close();
}
|
public void | write(org.apache.lucene.store.OutputStream output)
output.writeVInt(size());
for (int i = 0; i < size(); i++) {
FieldInfo fi = fieldInfo(i);
byte bits = 0x0;
if (fi.isIndexed) bits |= 0x1;
if (fi.storeTermVector) bits |= 0x2;
output.writeString(fi.name);
//Was REMOVE
//output.writeByte((byte)(fi.isIndexed ? 1 : 0));
output.writeByte(bits);
}
|