<commit_before>package com.tightdb;

import java.nio.ByteBuffer;
import java.util.Date;

import com.tightdb.lib.IRowsetBase;

/**
 * This class represents a view of a particular table. We can think of
 * a tableview is a subset of a table. It contains less than or 
 * equal to the number of entries of a table. A table view is often a
 * result of a query. 
 * 
 * The view don't copy data from the table, but merely has a list of 
 * row-references into the original table with the real data.
 * 
 * The class serves as a base class of all table view. It is a raw level table view, users 
 * are not encouraged to use this class. Instead users are advised to use 
 * the generated subclass version of the table.
 * 
 * Let us assume we are going to keep track of a table to store the employees 
 * of a company or an organization.
 * 
 * Following is a small example how to use the autogenerated class of the 
 * tableview. For that purpose we will first define the spec of an employee 
 * entity
 * 
 * 	@Table
 *	public class employee {
 *		String name;
 *		long age;
 *		boolean hired;
 *		byte[] imageData;
 *	}
 * 
 * Once this class is compiled along with TightDB annotation processor
 * this will produce following classes.
 * 
 * 1. Employee
 * 2. EmployeeTable
 * 3. EmployeeView.
 * 
 * In this class context our interest is EmployeeView which will be inherited from
 * this class.
 * 
 * The generated class will have more specialized method to do operations on TableView.
 * 
 */
public class TableViewBase implements IRowsetBase {
	/**
	 * Creates a TableViewBase for the TableBase table. The constructor
	 * implicitly create the native object tableview which is the backbone
	 * of this class.
	 * 
	 * @param table The table.
	 */
	public TableViewBase(TableBase table){
		this.table = table;
		this.tableView = null;
		this.nativePtr = createNativeTableView(table, table.nativePtr);
		if (this.nativePtr == 0) 
			throw new OutOfMemoryError("Out of native memory.");
	}

	/**
	 * Creates a TableViewBase with a Java Object Table and a already created
	 * native reference to a TableView. This method is not supposed to be 
	 * called by a user of this db. It is for internal use only.
	 * 
	 * @param table The table.
	 * @param nativePtr pointer to table.
	 */
	protected TableViewBase(TableBase table, long nativePtr){
		this.table = table;
		this.tableView = null;
		this.nativePtr = nativePtr;
	}
	
	/**
	 * Creates a TableView with already created Java TableView Object and a 
	 * native native TableView object reference. The method is not supposed to
	 * be called by the user of the db. The method is for internal use only.
	 * 
	 * @param tableView A table view.
	 * @param nativePtr pointer to table.
	 */
	public TableViewBase(TableViewBase tableView, long nativePtr){
		this.table = null;
		this.tableView = tableView;
		this.nativePtr = nativePtr;
	}
	
	/**
	 * Checks whether this table is empty or not.
	 * 
	 * @return true if empty, otherwise false.
	 */
	public boolean isEmpty(){
		return nativeSize(nativePtr) != 0;
	}

	/**
	 * Get the number of entries/rows of this table. 
	 * 
	 * @return The number of rows.
	 */
	public long size(){
		return nativeSize(nativePtr);
	}

	protected native long nativeSize(long nativeViewPtr);
	
	/**
	 * Get the value of the particular (integer) cell.
	 * 
	 * @param columnIndex 0 based index value of the column.
	 * @param rowIndex 0 based row value of the column.
	 * @return value of the particular cell.
	 */
	public long getLong(long columnIndex, long rowIndex){<commit_msg>Fixed bug in "isEmpty" method of a View.<commit_after>package com.tightdb;

import java.nio.ByteBuffer;
import java.util.Date;

import com.tightdb.lib.IRowsetBase;

/**
 * This class represents a view of a particular table. We can think of
 * a tableview is a subset of a table. It contains less than or 
 * equal to the number of entries of a table. A table view is often a
 * result of a query. 
 * 
 * The view don't copy data from the table, but merely has a list of 
 * row-references into the original table with the real data.
 * 
 * The class serves as a base class of all table view. It is a raw level table view, users 
 * are not encouraged to use this class. Instead users are advised to use 
 * the generated subclass version of the table.
 * 
 * Let us assume we are going to keep track of a table to store the employees 
 * of a company or an organization.
 * 
 * Following is a small example how to use the autogenerated class of the 
 * tableview. For that purpose we will first define the spec of an employee 
 * entity
 * 
 * 	@Table
 *	public class employee {
 *		String name;
 *		long age;
 *		boolean hired;
 *		byte[] imageData;
 *	}
 * 
 * Once this class is compiled along with TightDB annotation processor
 * this will produce following classes.
 * 
 * 1. Employee
 * 2. EmployeeTable
 * 3. EmployeeView.
 * 
 * In this class context our interest is EmployeeView which will be inherited from
 * this class.
 * 
 * The generated class will have more specialized method to do operations on TableView.
 * 
 */
public class TableViewBase implements IRowsetBase {
	/**
	 * Creates a TableViewBase for the TableBase table. The constructor
	 * implicitly create the native object tableview which is the backbone
	 * of this class.
	 * 
	 * @param table The table.
	 */
	public TableViewBase(TableBase table){
		this.table = table;
		this.tableView = null;
		this.nativePtr = createNativeTableView(table, table.nativePtr);
		if (this.nativePtr == 0) 
			throw new OutOfMemoryError("Out of native memory.");
	}

	/**
	 * Creates a TableViewBase with a Java Object Table and a already created
	 * native reference to a TableView. This method is not supposed to be 
	 * called by a user of this db. It is for internal use only.
	 * 
	 * @param table The table.
	 * @param nativePtr pointer to table.
	 */
	protected TableViewBase(TableBase table, long nativePtr){
		this.table = table;
		this.tableView = null;
		this.nativePtr = nativePtr;
	}
	
	/**
	 * Creates a TableView with already created Java TableView Object and a 
	 * native native TableView object reference. The method is not supposed to
	 * be called by the user of the db. The method is for internal use only.
	 * 
	 * @param tableView A table view.
	 * @param nativePtr pointer to table.
	 */
	public TableViewBase(TableViewBase tableView, long nativePtr){
		this.table = null;
		this.tableView = tableView;
		this.nativePtr = nativePtr;
	}
	
	/**
	 * Checks whether this table is empty or not.
	 * 
	 * @return true if empty, otherwise false.
	 */
	public boolean isEmpty(){
		return size() == 0;
	}

	/**
	 * Get the number of entries/rows of this table. 
	 * 
	 * @return The number of rows.
	 */
	public long size() {
		return nativeSize(nativePtr);
	}

	protected native long nativeSize(long nativeViewPtr);
	
	/**
	 * Get the value of the particular (integer) cell.
	 * 
	 * @param columnIndex 0 based index value of the column.
	 * @param rowIndex 0 based row value of the column.
	 * @return value of the particular cell.
	 */
	public long getLong(long columnIndex, long rowIndex){
{'fraction_non_alphanumeric': 0.07394415602637856, 'fraction_numerical': 0.0019643608811561668, 'mean_word_length': 3.207792207792208, 'pattern_counts': {'":': 0, '<': 3, '<?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': '518681', 'n_tokens_mistral': 2145, 'n_tokens_neox': 1938, 'n_words': 948}