<commit_before>package examples.auction;

import io.baratine.core.Lookup;
import io.baratine.core.OnInit;
import io.baratine.core.OnLookup;
import io.baratine.core.Result;
import io.baratine.core.Service;
import io.baratine.core.ServiceRef;
import io.baratine.core.Services;
import io.baratine.db.DatabaseService;

import javax.inject.Inject;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 */
@Service("pod://user/user")
public class UserManagerImpl implements UserManager
{
  private final static Logger log
    = Logger.getLogger(UserManagerImpl.class.getName());

  @Inject @Lookup("bardb:///")
  private DatabaseService _db;

  @Inject @Lookup("/identity-manager")
  private IdentityManager _identityManager;

  private ServiceRef _self;

  public UserManagerImpl()
  {
  }

  @OnInit
  public void onInit(Result<Boolean> result)
  {
    _self = Services.getCurrentService();

    try {
      // for production add salt
      _db.exec(
        "create table users(id varchar primary key, name varchar, value object) with hash '/user/$id",
        result.from(o -> o != null));
    } catch (Throwable t) {
      log.log(Level.FINE, t.getMessage(), t);
    }

    result.complete(true);
  }

  @OnLookup
  public Object lookup(String path)
  {
    String id = path.substring(1);

    log.finer("lookup user: " + id);

    return new UserImpl(_db, id);
  }
<commit_msg>add comments<commit_after>package examples.auction;

import io.baratine.core.Lookup;
import io.baratine.core.OnInit;
import io.baratine.core.OnLookup;
import io.baratine.core.Result;
import io.baratine.core.Service;
import io.baratine.core.ServiceRef;
import io.baratine.core.Services;
import io.baratine.db.DatabaseService;

import javax.inject.Inject;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 */
@Service("pod://user/user")
public class UserManagerImpl implements UserManager
{
  private final static Logger log
    = Logger.getLogger(UserManagerImpl.class.getName());

  @Inject @Lookup("bardb:///")
  private DatabaseService _db;

  @Inject @Lookup("/identity-manager")
  private IdentityManager _identityManager;

  private ServiceRef _self;

  public UserManagerImpl()
  {
  }

  @OnInit
  public void onInit(Result<Boolean> result)
  {
    _self = Services.getCurrentService();

    try {
      // for production add salt
      _db.exec(
        "create table users(id varchar primary key, name varchar, value object) with hash '/user/$id'",
        result.from(o -> o != null));
    } catch (Throwable t) {
      log.log(Level.FINE, t.getMessage(), t);
      //assume that exception is due to existing table and complete with true
      result.complete(true);
    }
  }

  @OnLookup
  public Object lookup(String path)
  {
    String id = path.substring(1);

    log.finer("lookup user: " + id);

    return new UserImpl(_db, id);
  }

{'fraction_non_alphanumeric': 0.12356421858684302, 'fraction_numerical': 0.0006961364427427776, 'mean_word_length': 3.5691573926868045, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '410339', 'n_tokens_mistral': 923, 'n_tokens_neox': 908, 'n_words': 217}