<commit_before>package org.basex.examples.query;

import org.basex.core.Context;
import org.basex.core.cmd.Add;
import org.basex.core.cmd.CreateDB;
import org.basex.core.cmd.XQuery;

/**
 * This class adds and retrieves documents in a collection.
 *
 * @author Workgroup DBIS, University of Konstanz 2005-10, ISC License
 * @author BaseX Team
 */
public final class CollStressTest {
  /** Global context. */
  private static final Context CONTEXT = new Context();
  /** Number of documents to be added. */
  private static final int SIZE = 1000;

  /**
   * Runs the example code.
   * @param args (ignored) command-line arguments
   * @throws Exception exception
   */
  public static void main(final String[] args) throws Exception {
    System.out.println("=== CollectionTest ===");

    // Create test database
    System.out.println("\n* Create test database.");
    final CreateDB cmd = new CreateDB("test");
    cmd.execute(CONTEXT);
    System.out.print(cmd.info());

    // Add documents
    for(int i = 0; i < SIZE; i++) {
      new Add("<xml/>", Integer.toString(i)).execute(CONTEXT);
    }
    System.out.print("\n* " + SIZE + " documents added.");

    // Find documents
    for(int i = 0; i < SIZE; i++) {
      new XQuery("collection('test/" + i + "')").execute(CONTEXT);
    }
    System.out.print("\n* " + SIZE + " documents queries.");
  }
}<commit_msg>back2life (but last42day)... - CollStressTest updated<commit_after>package org.basex.examples.query;

import org.basex.core.Context;
import org.basex.core.cmd.Add;
import org.basex.core.cmd.Close;
import org.basex.core.cmd.CreateDB;
import org.basex.core.cmd.DropDB;
import org.basex.core.cmd.XQuery;
import org.basex.util.Performance;

/**
 * This class adds and retrieves documents in a collection.
 *
 * @author Workgroup DBIS, University of Konstanz 2005-10, ISC License
 * @author BaseX Team
 */
public final class CollStressTest {
  /** Global context. */
  private static final Context CONTEXT = new Context();
  /** Number of documents to be added. */
  private static final int SIZE = 500;

  /**
   * Runs the example code.
   * @param args (ignored) command-line arguments
   * @throws Exception exception
   */
  public static void main(final String[] args) throws Exception {
    System.out.println("=== CollectionTest ===");

    // Create test database
    System.out.println("\n* Create test database.");
    final CreateDB cmd = new CreateDB("test");
    cmd.execute(CONTEXT);
    System.out.print(cmd.info());

    // Add documents
    for(int i = 0; i < SIZE; i++) {
      new Add("<xml/>", Integer.toString(i)).execute(CONTEXT);
    }
    System.out.println("\n* " + SIZE + " documents added.");

    // Request specific documents
    Performance perf = new Performance();
    for(int i = 0; i < SIZE; i++) {
      new XQuery("collection('test/" + i + "')").execute(CONTEXT);
    }
    System.out.println("\n* " + SIZE + " documents accessed in " + perf);

    // Loop through all documents
    new XQuery("for $i in 0 to " + (SIZE - 1) + " " +
      "return collection(concat('test/', $i))").execute(CONTEXT);
    System.out.println("\n* " + SIZE + " documents accessed in " + perf);

    // Close database
    new Close().execute(CONTEXT);

    // Loop through all documents (open database by XQuery processor)
    new XQuery("for $i in 0 to " + (SIZE - 1) + " " +
      "return collection(concat('test/', $i))").execute(CONTEXT);
    System.out.println("\n* " + SIZE + " documents accessed in " + perf);

    new DropDB("test").execute(CONTEXT);
  }
}
{'fraction_non_alphanumeric': 0.1540197461212976, 'fraction_numerical': 0.00846262341325811, 'mean_word_length': 3.132867132867133, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6343515', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1076, 'n_words': 316}