<commit_before>package edu.wheaton.simulator.statistics;

import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.ImmutableTable;
import com.google.common.collect.TreeBasedTable;

/**
 * @author akonwi
 */
 
public class Database {

	/**
	 * TODO: Make a TreeBasedtable of Snapshots
	 * TODO: Create instance of ImmutableTable from treetable
	 * TODO: Outside access to database will refer to ImmutableTable 
	 * 		 to ensure database is not changed
	 */
	
	private TreeBasedTable<EntityID, Integer, EntitySnapshot> treeTable;
	
	private ImmutableTable<EntityID, Integer, EntitySnapshot> database;
	
	public Database() {
		treeTable = TreeBasedTable.create(); // create table
		 /**
		 * the following is a foobar EntitySnapshot and details
		 */
		EntityID id = new EntityID("akon", 1);
		Map<String, FieldSnapshot> defaults = new HashMap<String, FieldSnapshot>();
		EntityPrototype pro = new EntityPrototype("agent", defaults);
		InteractionDescription inter = new InteractionDescription();
		EntitySnapshot snap = new AgentSnapshot(id, new HashMap<String, Object>(), 1, pro, inter);
		
		treeTable.put(id, 1, snap); // put snapshot into table
		
		/**
		 * once finished adding all snapshots, build Immutable table 
		 */
		database = new ImmutableTable.Builder<EntityID, Integer, EntitySnapshot>().putAll(treeTable).build();
		
		database.get(id, 1).id(); // Test database
	}
	
	public static void main(String[] args) {
		Database db = new Database();
	}
}<commit_msg>adding a putEntity() to Database class<commit_after>package edu.wheaton.simulator.statistics;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

import com.google.common.collect.ImmutableTable;
import com.google.common.collect.TreeBasedTable;
import com.sun.org.apache.bcel.internal.classfile.Field;

import edu.wheaton.simulator.gridentities.GridEntity;

/**
 * This class is an abstraction of a database which is represented by
 * a Table, provided by the Guava libraries
 * 
 * @author akonwi
 */
 
public class Database {

	/**
	 * TODO: Make a TreeBasedtable of Snapshots
	 * TODO: Create instance of ImmutableTable from treetable
	 * TODO: Outside access to database will refer to ImmutableTable 
	 * 		 to ensure database is not changed
	 */
	
	private TreeBasedTable<EntityID, Integer, EntitySnapshot> treeTable;
	
	private ImmutableTable<EntityID, Integer, EntitySnapshot> database;
	
	public Database() {
		treeTable = TreeBasedTable.create(); // create table
		 /**
		 * the following is a foobar EntitySnapshot and details
		 */
		EntityID id = new EntityID("akon", 1);
		HashMap<String, FieldSnapshot> defaults = new HashMap<String, FieldSnapshot>();
		HashMap<String, FieldSnapshot> fields = new HashMap<String, FieldSnapshot>();
		EntityPrototype prototype = new EntityPrototype("agent", defaults);
		InteractionDescription interaction = new InteractionDescription();
		EntitySnapshot snap = new AgentSnapshot(id, fields, 1, prototype, interaction);
		
		treeTable.put(id, 1, snap); // put snapshot into table
		
		/**
		 * once finished adding all snapshots, build Immutable table 
		 */
		database = new ImmutableTable.Builder<EntityID, Integer, EntitySnapshot>().putAll(treeTable).build();
		
		database.get(id, 1).id(); // Test database
	}
	
	public static void main(String[] args) {
		Database db = new Database();
	}	
	
	public void putEntity(GridEntity entity, int step) {
		EntityID id = entity.getID();
		
		/**
		 * all the fields of the agent
		 */
		ArrayList<Field> entityFields = entity.getFields();
		
		/*
		 * map of the fields to save in entitySnapShot
		 */
		HashMap<String, FieldSnapshot> fieldsForSnap = new HashMap<String, FieldSnapshot>();
		
		/*
		 * fill the fieldsForSnap		
		 */
		Iterator<Field> it = entityFields.iterator();
		while(it.hasNext()) {
			Field current = it.next();
			FieldSnapshot snap = new FieldSnapshot(current.getName(), current.getType(), current.getValue());
			fieldsForSnap.put(current.getName(), snap);
		}
		
		/*
		 * Create protoype
		 * Because this requires me having the initial set of fields,
		 * I think the Observer class should record those on when the
		 * user defines them. Then have a getter method that returns
		 * the 'default fields'
		 * 
		 * Observer class could also possibly create a prototype
		 * because it will have first access to the 'categoryName' and
		 * with the Fields, it can make a map<String, FieldSnapshot>
		 */
	}
}
{'fraction_non_alphanumeric': 0.10303030303030303, 'fraction_numerical': 0.0017957351290684624, 'mean_word_length': 4.0693970420932875, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '524027', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1195, 'n_words': 407}