public void BeforeClass()
{
NoDocs = AtLeast(4096);
Distance = (1L << 60) / NoDocs;
Directory = NewDirectory();
RandomIndexWriter writer = new RandomIndexWriter(Random(), Directory, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(TestUtil.NextInt(Random(), 100, 1000)).SetMergePolicy(NewLogMergePolicy()));
FieldType storedLong = new FieldType(LongField.TYPE_NOT_STORED);
storedLong.Stored = true;
storedLong.Freeze();
FieldType storedLong8 = new FieldType(storedLong);
storedLong8.NumericPrecisionStep = 8;
FieldType storedLong4 = new FieldType(storedLong);
storedLong4.NumericPrecisionStep = 4;
FieldType storedLong6 = new FieldType(storedLong);
storedLong6.NumericPrecisionStep = 6;
FieldType storedLong2 = new FieldType(storedLong);
storedLong2.NumericPrecisionStep = 2;
FieldType storedLongNone = new FieldType(storedLong);
storedLongNone.NumericPrecisionStep = int.MaxValue;
FieldType unstoredLong = LongField.TYPE_NOT_STORED;
FieldType unstoredLong8 = new FieldType(unstoredLong);
unstoredLong8.NumericPrecisionStep = 8;
FieldType unstoredLong6 = new FieldType(unstoredLong);
unstoredLong6.NumericPrecisionStep = 6;
FieldType unstoredLong4 = new FieldType(unstoredLong);
unstoredLong4.NumericPrecisionStep = 4;
FieldType unstoredLong2 = new FieldType(unstoredLong);
unstoredLong2.NumericPrecisionStep = 2;
LongField field8 = new LongField("field8", 0L, storedLong8), field6 = new LongField("field6", 0L, storedLong6), field4 = new LongField("field4", 0L, storedLong4), field2 = new LongField("field2", 0L, storedLong2), fieldNoTrie = new LongField("field" + int.MaxValue, 0L, storedLongNone), ascfield8 = new LongField("ascfield8", 0L, unstoredLong8), ascfield6 = new LongField("ascfield6", 0L, unstoredLong6), ascfield4 = new LongField("ascfield4", 0L, unstoredLong4), ascfield2 = new LongField("ascfield2", 0L, unstoredLong2);
Document doc = new Document();
// add fields, that have a distance to test general functionality
doc.Add(field8);
doc.Add(field6);
doc.Add(field4);
doc.Add(field2);
doc.Add(fieldNoTrie);
// add ascending fields with a distance of 1, beginning at -noDocs/2 to test the correct splitting of range and inclusive/exclusive
doc.Add(ascfield8);
doc.Add(ascfield6);
doc.Add(ascfield4);
doc.Add(ascfield2);
// Add a series of noDocs docs with increasing long values, by updating the fields
for (int l = 0; l < NoDocs; l++)
{
long val = Distance * l + StartOffset;
field8.LongValue = val;
field6.LongValue = val;
field4.LongValue = val;
field2.LongValue = val;
fieldNoTrie.LongValue = val;
val = l - (NoDocs / 2);
ascfield8.LongValue = val;
ascfield6.LongValue = val;
ascfield4.LongValue = val;
ascfield2.LongValue = val;
writer.AddDocument(doc);
}
Reader = writer.Reader;
Searcher = NewSearcher(Reader);
writer.Dispose();
}