<commit_before>/*******************************************************************************
 *
 *    Copyright (C) 2015-2017 the BBoxDB project
 *  
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *  
 *      http://www.apache.org/licenses/LICENSE-2.0
 *  
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License. 
 *    
 *******************************************************************************/
package org.bboxdb.tools.experiments;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Random;

public class TestBoundingBoxQuery implements Runnable {

	/**
	 * The file to import
	 */
	protected final String filename;
	
	/**
	 * The format of the input file
	 */
	protected String format;

	/**
	 * The sampling size
	 */
	protected final static double SAMPLING_SIZE = 1d;

	/**
	 * The random for our samples
	 */
	protected final Random random;

	/**
	 * The dimension of the input data
	 */
	protected int dataDimension = -1;
	
	/**
	 * The tablename to query
	 */
	protected final String tablename;
	
	public TestBoundingBoxQuery(final String filename, final String format, final String tablename) {
		this.filename = filename;
		this.format = format;
		this.tablename = tablename;
		this.random = new Random(System.currentTimeMillis());
	}
	
	@Override
	public void run() {
		System.out.format("Reading %s\n", filename);
		final List<Double> experimentSize = Arrays.asList(0.1, 0.2, 0.5, 1.0);
		experimentSize.forEach(e -> runExperiment(e));
	}

	/**
	 * Run the experiment with the max dimension soze
	 * @param sampleSize
	 * @throws IOException 
	 */
	protected void runExperiment(final double maxDimensionSize) {
		System.out.println("# Simulating with max dimension size: " + maxDimensionSize);
	
	}

	
	/**
	 * Main * Main * Main
	 */
	public static void main(final String[] args) throws IOException {
		
		// Check parameter
		if(args.length != 3) {
			System.err.println("Usage: programm <filename> <format> <table>");
			System.exit(-1);
		}
		
		final String filename = Objects.requireNonNull(args[0]);
		final String format = Objects.requireNonNull(args[1]);
		final String table = Objects.requireNonNull(args[2]);
		
		final TestBoundingBoxQuery testSplit = new TestBoundingBoxQuery(filename, format, table);
		testSplit.run();
	}

}<commit_msg>Updated experiment<commit_after>/*******************************************************************************
 *
 *    Copyright (C) 2015-2017 the BBoxDB project
 *  
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *  
 *      http://www.apache.org/licenses/LICENSE-2.0
 *  
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License. 
 *    
 *******************************************************************************/
package org.bboxdb.tools.experiments;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Random;

import org.bboxdb.network.client.BBoxDB;
import org.bboxdb.network.client.BBoxDBCluster;
import org.bboxdb.storage.entity.BoundingBox;
import org.bboxdb.storage.entity.DoubleInterval;

public class TestBoundingBoxQuery implements Runnable {

	/**
	 * The file to import
	 */
	protected final String filename;
	
	/**
	 * The format of the input file
	 */
	protected String format;
	
	/**
	 * The endpoint name
	 */
	protected String endpoint;
	
	/**
	 * The cluster name
	 */
	protected String cluster;
	
	/**
	 * The tablename to query
	 */
	protected final String tablename;
	
	/**
	 * The random for our samples
	 */
	protected final Random random;

	/**
	 * The amont of queries
	 */
	protected final static int QUERIES = 100000;
	

	
	public TestBoundingBoxQuery(final String filename, final String format, 
			final String endpoint, String cluster, String tablename) {
		this.filename = filename;
		this.format = format;
		this.endpoint = endpoint;
		this.cluster = cluster;
		this.tablename = tablename;
		this.random = new Random(System.currentTimeMillis());
	}
	
	@Override
	public void run() {
		System.out.format("# Reading %s\n", filename);
		final BoundingBox boundingBox = ExperimentHelper.determineBoundingBox(filename, format);
		
		System.out.println("Connecting to BBoxDB cluster");
		final BBoxDB bboxDBConnection = new BBoxDBCluster(endpoint, cluster);

		final List<Double> experimentSize = Arrays.asList(0.1, 0.2, 0.5, 1.0);
		experimentSize.forEach(e -> runExperiment(e, boundingBox, bboxDBConnection));
	}

	/**
	 * Run the experiment with the max dimension soze
	 * @param boundingBox 
	 * @param bboxDBConnection 
	 * @param sampleSize
	 * @throws IOException 
	 */
	protected void runExperiment(final double maxDimensionSize, final BoundingBox boundingBox, 
			final BBoxDB bboxDBConnection) {
		
		System.out.println("# Simulating with max dimension size: " + maxDimensionSize);
		for(int i = 0; i < QUERIES; i++) {
			
			final List<DoubleInterval> bboxIntervals = new ArrayList<>();
			// Determine query bounding box
			for(int dimension = 0; dimension < boundingBox.getDimension(); dimension++) {
				final double dataExtent = boundingBox.getExtent(dimension);
				final double bboxExtent = random.nextDouble() % dataExtent;
				final double bboxStartPos = boundingBox.getCoordinateLow(dimension) + bboxExtent;
				
				final double bboxEndPos = bboxStartPos 
						+ (dataExtent / 100 * maxDimensionSize) * random.nextDouble() % 1;
				
				final DoubleInterval doubleInterval = new DoubleInterval(bboxStartPos, bboxEndPos);
				bboxIntervals.add(doubleInterval);
			}
			
			final BoundingBox queryBox = new BoundingBox(bboxIntervals);
			System.out.println("Executing query with bounding box: " + queryBox);
		}
	}
	
	/**
	 * Main * Main * Main
	 */
	public static void main(final String[] args) throws IOException {
		
		// Check parameter
		if(args.length != 5) {
			System.err.println("Usage: programm <filename> <format> <endpoint> <cluster> <table>");
			System.exit(-1);
		}
		
		final String filename = Objects.requireNonNull(args[0]);
		final String format = Objects.requireNonNull(args[1]);
		final String endpoint = Objects.requireNonNull(args[2]);
		final String cluster = Objects.requireNonNull(args[3]);
		final String table = Objects.requireNonNull(args[4]);
		
		final TestBoundingBoxQuery experiment = new TestBoundingBoxQuery(filename, format, endpoint, 
				cluster, table);
		
		experiment.run();
	}

}
{'fraction_non_alphanumeric': 0.1409673418768086, 'fraction_numerical': 0.009094667217858619, 'mean_word_length': 3.85809906291834, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5629648', 'n_tokens_mistral': 2277, 'n_tokens_neox': 2002, 'n_words': 634}