Package de.linwave.gtm.query

Source Code of de.linwave.gtm.query.NumericTest

package de.linwave.gtm.query;

import java.util.Calendar;
import java.util.Date;

import org.odbms.OP;
import org.odbms.ObjectContainer;
import org.odbms.ObjectSet;
import org.odbms.Query;

import de.linwave.gtm.GTM;

public class NumericTest
{
  private static final ObjectContainer db = GTM.getInstance();
  private static final Calendar cal = Calendar.getInstance();
  private static final Date currentTime = cal.getTime();

  LogEntry e1;
  LogEntry e2;

  private void create()
  {
    for (int i = 0; i <= 1000; i++) {
      LogEntry entry = new LogEntry("LogEntry number " + i);
      db.store(entry);
      if (i == 500)
        e1 = entry;
      if (i == 750)
        e2 = entry;

      if (i % 1000 == 0)
        System.out.println(entry);
    }

  }

  private void query()
  {
    Query q1 = db.query(LogEntry.class);
    // q1.constrain("date", OP.GREATER, currentTime);
    q1.constrain("date", OP.RANGE, e1.getDate().getTime(), e2.getDate().getTime());

    ObjectSet<LogEntry> entries = q1.execute();

    int cnt = 0;
    for (LogEntry entry : entries) {
      cnt++;
      System.out.println(entry + " exists=" + entry.getFile().exists());
    }

    q1.printConstraintInfo();
    db.printCacheStatistics();

  }

  public static void main(String[] args)
  {
    db.deleteClass(LogEntry.class);
    // IndexUtils.dropIndex(LogEntry.class, "date");
    // IndexUtils.addIndex(LogEntry.class, "date");

    NumericTest test = new NumericTest();
    test.create();
    test.query();
  }
}
TOP

Related Classes of de.linwave.gtm.query.NumericTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.