<commit_before>package com.tightdb.refdoc;

import java.io.FileNotFoundException;
import java.io.PrintWriter;

import com.tightdb.*;

public class DynTableExamples {

    public static void main(String[] args) throws FileNotFoundException  {
        
        
        // Constructor
        constrcutorExample();


        //Table schema methods
        addColumnExample();
        removeColumnExample();
        renameColumnExample();
        getColumnCountExample();
        getColumnNameExample();
        getColumnIndexExample();
        getColumnTypeExample();

        // Table methods:
        isValidExample();
        sizeExample();
        isEmptyExample();
        clearExample();
        //TODO getSortedViewExample();
        //TODO optimizeExample();
        //TODO setIndexExample();
        //TODO hasIndexExample();


        // Columns methods: 
        adjustExample();


        // Rows methods:
        addAtExample();
        addAtExample();
        setRowExample();
        removeExample();
        removeLastExample();
        addEmptyRowExample();
        addEmptyRowsExample();


        // Cells methods:
        getExamples();
        setExamples();
        //TODO getSubtableSize();
        //TODO clearSubtable

        
        // Searching methods:
        findFirstExamples();
        findAllExample();
        getDistinctViewExample();
        whereExample();

        // Aggregates methods:
        sumExample();
        maximumExample();
        minimumExample();
        averageExample();

        // Dump methods:
        toJsonExample();
    }
    
    
    // ******************************************
    // Constructor methods
    // ******************************************
    
    
    public static void constrcutorExample(){
        // @@Example: ex_java_dyn_table_constructor_plain @@
        // Create new table in memory
        Table table = new Table();
        // @@EndExample@@
        
        
        Group group = new Group();
        // @@Example: ex_java_dyn_table_constructor_group @@
        // Get table from group. If table does not exist in the group, it is created
        Table table2 = group.getTable("tableName");
        // @@EndExample@@
    }

    
    // ******************************************
    // Table schema methods
    // ******************************************

    public static void addColumnExample(){
        // @@Example: ex_java_dyn_table_add_column_1 @@
        Table table1 = new Table();

        // Add a String column called 'name' and an int column called 'age'
        table1.addColumn(ColumnType.STRING, "name");
        table1.addColumn(ColumnType.INTEGER, "age");
        // @@EndExample@@

        // @@Example: ex_java_dyn_table_add_column_2 @@
        Table table2 = new Table();

        table2.addColumn(ColumnType.STRING, "colName0");
        table2.addColumn(ColumnType.INTEGER, "colName1"); // Converts to a long in java
        table2.addColumn(ColumnType.FLOAT, "colName2");
        table2.addColumn(ColumnType.DOUBLE, "colName3");
        table2.addColumn(ColumnType.BOOLEAN, "colName4");
        table2.addColumn(ColumnType.DATE, "colName5");
        table2.addColumn(ColumnType.BINARY, "colName6");
        table2.addColumn(ColumnType.TABLE, "colName7"); // Subtables
        table2.addColumn(ColumnType.MIXED, "colName8"); // Any of the above values
        // @@EndExample@@

        // @@Example: ex_java_dyn_table_add_column_3 @@
        Table table3 = new Table();

        table3.addColumn(ColumnType.INTEGER, "id");
        long subtableColIndex = table3.addColumn(ColumnType.TABLE, "events");

        // To add columns to the subtable use TableSchema
        TableSchema subtableSchema = table3.getSubTableSchema(subtableColIndex);

        // Now simply add columns using addColumn on the TableSchema object
        subtableSchema.addColumn(ColumnType.STRING, "desc");
        subtableSchema.addColumn(ColumnType.DATE, "date");
        // @@EndExample@@

        // @@Example: ex_java_dyn_table_add_column_4 @@
        Table table4 = new Table();

        for (long i=0; i<10000;i++){
            table4.addColumn(ColumnType.INTEGER, "col" + i);
        }
        // @@EndExample@@

        // @@Example: ex_java_dyn_table_add_column_5 @@
        Table table5 = new Table();
        
        // Although it's possible to have empty names or the same names multiple times, 
        // looking up columns based on the name, will only give you the first column with that name. 
        // But if you don't care about looking up columns by name, you don't have to set a name.
        table5.addColumn(ColumnType.STRING, "val");
        table5.addColumn(ColumnType.INTEGER, "val");
        table5.addColumn(ColumnType.DOUBLE, "val");
        table5.addColumn(ColumnType.STRING, ""); // Empty string are also allowed
        table5.addColumn(ColumnType.STRING, ""); 
        
        try { 
            table5.addColumn(ColumnType.STRING, null); // Null are not allowed as column name
        } 
        catch(NullPointerException e) { <commit_msg>avoid line breaks in webpage<commit_after>package com.tightdb.refdoc;

import java.io.FileNotFoundException;
import java.io.PrintWriter;

import com.tightdb.*;

public class DynTableExamples {

    public static void main(String[] args) throws FileNotFoundException  {
        
        
        // Constructor
        constrcutorExample();


        //Table schema methods
        addColumnExample();
        removeColumnExample();
        renameColumnExample();
        getColumnCountExample();
        getColumnNameExample();
        getColumnIndexExample();
        getColumnTypeExample();

        // Table methods:
        isValidExample();
        sizeExample();
        isEmptyExample();
        clearExample();
        //TODO getSortedViewExample();
        //TODO optimizeExample();
        //TODO setIndexExample();
        //TODO hasIndexExample();


        // Columns methods: 
        adjustExample();


        // Rows methods:
        addAtExample();
        addAtExample();
        setRowExample();
        removeExample();
        removeLastExample();
        addEmptyRowExample();
        addEmptyRowsExample();


        // Cells methods:
        getExamples();
        setExamples();
        //TODO getSubtableSize();
        //TODO clearSubtable

        
        // Searching methods:
        findFirstExamples();
        findAllExample();
        getDistinctViewExample();
        whereExample();

        // Aggregates methods:
        sumExample();
        maximumExample();
        minimumExample();
        averageExample();

        // Dump methods:
        toJsonExample();
    }
    
    
    // ******************************************
    // Constructor methods
    // ******************************************
    
    
    public static void constrcutorExample(){
        // @@Example: ex_java_dyn_table_constructor_plain @@
        // Create new table in memory
        Table table = new Table();
        // @@EndExample@@
        
        
        Group group = new Group();
        // @@Example: ex_java_dyn_table_constructor_group @@
        // Get table from group. If table does not exist in the group, it is created
        Table table2 = group.getTable("tableName");
        // @@EndExample@@
    }

    
    // ******************************************
    // Table schema methods
    // ******************************************

    public static void addColumnExample(){
        // @@Example: ex_java_dyn_table_add_column_1 @@
        Table table1 = new Table();

        // Add a String column called 'name' and an int column called 'age'
        table1.addColumn(ColumnType.STRING, "name");
        table1.addColumn(ColumnType.INTEGER, "age");
        // @@EndExample@@

        // @@Example: ex_java_dyn_table_add_column_2 @@
        Table table2 = new Table();

        table2.addColumn(ColumnType.STRING, "colName0");
        table2.addColumn(ColumnType.INTEGER, "colName1"); // Converts to a long in java
        table2.addColumn(ColumnType.FLOAT, "colName2");
        table2.addColumn(ColumnType.DOUBLE, "colName3");
        table2.addColumn(ColumnType.BOOLEAN, "colName4");
        table2.addColumn(ColumnType.DATE, "colName5");
        table2.addColumn(ColumnType.BINARY, "colName6");
        table2.addColumn(ColumnType.TABLE, "colName7"); // Subtables
        table2.addColumn(ColumnType.MIXED, "colName8"); // Any of the above values
        // @@EndExample@@

        // @@Example: ex_java_dyn_table_add_column_3 @@
        Table table3 = new Table();

        table3.addColumn(ColumnType.INTEGER, "id");
        long subtableColIndex = table3.addColumn(ColumnType.TABLE, "events");

        // To add columns to the subtable use TableSchema
        TableSchema subtableSchema = table3.getSubTableSchema(subtableColIndex);

        // Now simply add columns using addColumn on the TableSchema object
        subtableSchema.addColumn(ColumnType.STRING, "desc");
        subtableSchema.addColumn(ColumnType.DATE, "date");
        // @@EndExample@@

        // @@Example: ex_java_dyn_table_add_column_4 @@
        Table table4 = new Table();

        for (long i=0; i<10000;i++){
            table4.addColumn(ColumnType.INTEGER, "col" + i);
        }
        // @@EndExample@@

        // @@Example: ex_java_dyn_table_add_column_5 @@
        Table table5 = new Table();
        
        // Although it's possible to have empty names or the same names multiple times, 
        // looking up columns based on the name, will only give you the first column 
        // with that name. 
        // But if you don't care about looking up columns by name, 
        // you don't have to set a name.
        table5.addColumn(ColumnType.STRING, "val");
        table5.addColumn(ColumnType.INTEGER, "val");
        table5.addColumn(ColumnType.DOUBLE, "val");
        table5.addColumn(ColumnType.STRING, ""); // Empty string are also allowed
        table5.addColumn(ColumnType.STRING, ""); 
        
        try { 
            table5.addColumn(ColumnType.STRING, null); // Null are not allowed as column name
        } 
        catch(NullPointerException e) { 
{'fraction_non_alphanumeric': 0.14003731709712267, 'fraction_numerical': 0.009231071393498968, 'mean_word_length': 2.271442338580148, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4556793', 'n_tokens_mistral': 2812, 'n_tokens_neox': 2667, 'n_words': 644}