Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.CompletableFuture;
import java.util.function.IntFunction;

Expand All @@ -25,14 +24,14 @@
import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexer;
import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper;
import org.hibernate.search.util.impl.test.data.TextContent;
import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex;
import org.hibernate.search.util.impl.test.annotation.TestForIssue;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import com.google.common.io.Resources;
import org.awaitility.Awaitility;

/**
Expand All @@ -51,10 +50,7 @@ public class IndexIndexerLargeDocumentsIT {
private static final String GREAT_EXPECTATIONS;
static {
try {
GREAT_EXPECTATIONS = Resources.toString(
IndexIndexerLargeDocumentsIT.class.getResource( "/great_expectations.txt" ),
StandardCharsets.UTF_8
);
GREAT_EXPECTATIONS = TextContent.greatExpectations().read();
}
catch (IOException e) {
throw new UncheckedIOException( e );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import java.io.IOException;

import org.hibernate.search.integrationtest.performance.backend.base.testsupport.filesystem.TemporaryFileHolder;

import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
Expand All @@ -19,14 +17,14 @@
@State(Scope.Benchmark)
public class DatasetHolder {

@Param({ Datasets.HIBERNATE_DEV_ML_2016_01 })
@Param({ Datasets.GREAT_EXPECTATIONS })
private String dataset;

private Dataset datasetInstance;

@Setup(Level.Trial)
public void setup(TemporaryFileHolder temporaryFileHolder) throws IOException {
datasetInstance = Datasets.createDataset( dataset, temporaryFileHolder.getCacheDirectory() );
public void setup() throws IOException {
datasetInstance = Datasets.createDataset( dataset );
}

public Dataset getDataset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,36 @@
*/
package org.hibernate.search.integrationtest.performance.backend.base.testsupport.dataset;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.List;

public final class Datasets {
import org.hibernate.search.util.impl.test.data.TextContent;

public static final String CONSTANT_TEXT = "constant-text";
import com.google.common.io.CharSource;

public static final String HIBERNATE_DEV_ML_2016_01 = "hibernate-dev-ml-2016-01";
public final class Datasets {

private static final String DATASET_CACHE_DIRECTORY = "dataset";
public static final String CONSTANT_TEXT = "constant-text";

private static final URI HIBERNATE_DEV_MAILING_LIST_URI =
URI.create( "https://lists.jboss.org/pipermail/hibernate-dev/2016-January.txt" );
public static final String GREAT_EXPECTATIONS = "hibernate-dev-ml-2016-01";

private Datasets() {
}

public static Dataset createDataset(String name, Path cacheDirectory)
public static Dataset createDataset(String name)
throws IOException {
switch ( name ) {
case CONSTANT_TEXT:
return new ConstantDataset();
case HIBERNATE_DEV_ML_2016_01:
Path path = fetch( name, HIBERNATE_DEV_MAILING_LIST_URI, cacheDirectory );
return new SampleDataset( parseMailingListDigest( path ) );
case GREAT_EXPECTATIONS:
return new SampleDataset( parseSimple( TextContent.greatExpectations() ) );
default:
throw new IllegalArgumentException( "Unknown dataset: " + name );
}
}

private static Path fetch(String name, URI uri, Path cacheDirectory) throws IOException {
Path datasetCacheDirectory = cacheDirectory.resolve( DATASET_CACHE_DIRECTORY );
if ( !Files.exists( datasetCacheDirectory ) ) {
Files.createDirectory( datasetCacheDirectory );
}

Path outputPath = datasetCacheDirectory.resolve( name );
if ( Files.exists( outputPath ) ) {
return outputPath;
}

try ( InputStream input = uri.toURL().openStream();
ReadableByteChannel inputChannel = Channels.newChannel( input );
FileChannel outputChannel = FileChannel.open(
outputPath, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW ) ) {
outputChannel.transferFrom( inputChannel, 0, Long.MAX_VALUE );
}
return outputPath;
}

private static List<SampleDataset.DataSample> parseMailingListDigest(Path path) throws IOException {
try ( BufferedReader reader = Files.newBufferedReader( path ) ) {
return new MailingListDigestParser( reader ).parse();
}
private static List<SampleDataset.DataSample> parseSimple(CharSource charSource) throws IOException {
return charSource.readLines( new SimpleDataSampleParser() );
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public void populate(MappedIndex index, DocumentElement documentElement, long do

public static class DataSample {

private final String shortText;
private final String longText;
private final int numeric;
final String shortText;
final String longText;
final int numeric;

public DataSample(String shortText, String longText, int numeric) {
// Just in case something turned wrong during sample generation
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.search.integrationtest.performance.backend.base.testsupport.dataset;

import java.util.ArrayList;
import java.util.List;

import com.google.common.io.LineProcessor;

final class SimpleDataSampleParser implements LineProcessor<List<SampleDataset.DataSample>> {

private static final int LINES_PER_SAMPLE = 10;

private final List<SampleDataset.DataSample> result = new ArrayList<>();

private int currentSampleId = 0;
private int currentLineCount = 0;
private String currentSampleFirstLine = null;
private final StringBuilder currentSampleWholeText = new StringBuilder();

@Override
public boolean processLine(String line) {
if ( line.isEmpty() ) {
return true;
}
if ( currentLineCount == 0 ) {
currentSampleFirstLine = line;
}
else {
currentSampleWholeText.append( "\n" );
}
currentSampleWholeText.append( line );
++currentLineCount;
if ( currentLineCount >= LINES_PER_SAMPLE ) {
pushCurrentSample();
}
return true;
}

@Override
public List<SampleDataset.DataSample> getResult() {
pushCurrentSample();
return result;
}

private void pushCurrentSample() {
if ( currentLineCount == 0 ) {
return;
}

result.add( new SampleDataset.DataSample(
currentSampleFirstLine, currentSampleWholeText.toString(), currentSampleId
) );
++this.currentSampleId;

currentLineCount = 0;
currentSampleFirstLine = null;
currentSampleWholeText.setLength( 0 );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@
@State(Scope.Benchmark)
public class TemporaryFileHolder {

/**
* Set this system property to an alternative path if you want
* cache files (downloads) to be stored in a specific place
* (other than "/tmp/" + TEST_DIR_PREFIX + "cache-path").
*/
private static final String CACHE_PATH_PROPERTY_KEY = "cache-path";

/**
* Set this system property to an alternative path if you want
* index files to be stored in a specific place
Expand All @@ -51,10 +44,6 @@ public void cleanUp() throws IOException {
deleteAll( toCleanUp );
}

public Path getCacheDirectory() throws IOException {
return getTemporaryDirectory( CACHE_PATH_PROPERTY_KEY, false );
}

public Path getIndexesDirectory() throws IOException {
return getTemporaryDirectory( INDEXES_PATH_PROPERTY_KEY, true );
}
Expand Down
Loading