Package net.sf.ehcache.search

Examples of net.sf.ehcache.search.Results


  public D get(ObjectIdentifiable objectId, VersionCorrection versionCorrection) {
    ArgumentChecker.notNull(objectId, "objectId");
    ArgumentChecker.notNull(versionCorrection, "versionCorrection");

    // Search through attributes for specified oid, versions/corrections
    Results results = getUidToDocumentCache().createQuery()
        .includeKeys().includeValues()
        .includeAttribute(getUidToDocumentCache().getSearchAttribute("ObjectId"))
        .includeAttribute(getUidToDocumentCache().getSearchAttribute("VersionFromInstant"))
        .includeAttribute(getUidToDocumentCache().getSearchAttribute("VersionToInstant"))
        .includeAttribute(getUidToDocumentCache().getSearchAttribute("CorrectionFromInstant"))
        .includeAttribute(getUidToDocumentCache().getSearchAttribute("CorrectionToInstant"))
        .addCriteria(getUidToDocumentCache().getSearchAttribute("ObjectId").eq(objectId.toString()))
        .addCriteria(getUidToDocumentCache().getSearchAttribute("VersionFromInstant")
            .le(versionCorrection.withLatestFixed(InstantExtractor.MAX_INSTANT).getVersionAsOf().toString()))
        .addCriteria(getUidToDocumentCache().getSearchAttribute("VersionToInstant")
            .gt(versionCorrection.withLatestFixed(InstantExtractor.MAX_INSTANT.minusNanos(1)).getVersionAsOf().toString()))
        .addCriteria(getUidToDocumentCache().getSearchAttribute("CorrectionFromInstant")
            .le(versionCorrection.withLatestFixed(InstantExtractor.MAX_INSTANT).getCorrectedTo().toString()))
        .addCriteria(getUidToDocumentCache().getSearchAttribute("CorrectionToInstant")
            .gt(versionCorrection.withLatestFixed(InstantExtractor.MAX_INSTANT.minusNanos(1)).getCorrectedTo().toString()))
        .execute();

    // Found a matching cached document
    if (results.size() == 1 && results.all().get(0).getValue() != null) {
      @SuppressWarnings("unchecked")
      D result = (D) results.all().get(0).getValue();

      // Debug: check result against underlying
      if (TEST_AGAINST_UNDERLYING) {
        D check = getUnderlying().get(objectId, versionCorrection);
        if (!result.equals(check)) {
          s_logger.error(getUidToDocumentCache().getName() + " returned:\n" + result + "\nbut the underlying master returned:\n" + check);
        }
      }

      // Return cached value
      return result;

    // No cached document found, fetch from underlying by oid/vc instead
    // Note: no self-populating by oid/vc, and no caching of misses by oid/vc
    } else if (results.size() == 0) {
      // Get from underlying by oid/vc, throwing exception if not there
      D result = _underlying.get(objectId, versionCorrection);

      // Explicitly insert in cache
      getUidToDocumentCache().put(new Element(result.getUniqueId(), result));
View Full Code Here


  //-------------------------------------------------------------------------

  private void cleanCaches(ObjectId objectId, Instant fromVersion, Instant toVersion) {

    Results results = getUidToDocumentCache().createQuery().includeKeys()
        .includeAttribute(getUidToDocumentCache().getSearchAttribute("ObjectId"))
        .includeAttribute(getUidToDocumentCache().getSearchAttribute("VersionFromInstant"))
        .includeAttribute(getUidToDocumentCache().getSearchAttribute("VersionToInstant"))
        .addCriteria(getUidToDocumentCache().getSearchAttribute("ObjectId")
                         .eq(objectId.toString()))
        .addCriteria(getUidToDocumentCache().getSearchAttribute("VersionFromInstant")
                         .le((fromVersion != null ? fromVersion : InstantExtractor.MIN_INSTANT).toString()))
        .addCriteria(getUidToDocumentCache().getSearchAttribute("VersionToInstant")
                         .ge((toVersion != null ? toVersion : InstantExtractor.MAX_INSTANT).toString()))
        .execute();

    for (Result result : results.all()) {
      getUidToDocumentCache().remove(result.getKey());
    }
  }
View Full Code Here

    /**
     * {@inheritDoc}.
     */
    public Results executeQuery(final StoreQuery query) {
        Results rv = null;
        try {
            rv = executeWithExecutor(new Callable<Results>() {
                public Results call() throws Exception {
                    return nonstopActiveDelegateHolder.getUnderlyingTerracottaStore().executeQuery(query);
                }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public Results executeQuery(StoreQuery query) {
        Results results = underlyingStore.executeQuery(query);
        if (results instanceof TxSearchResults) {
            // don't re-wrap needlessly
            return results;
        }
        return new TxSearchResults(underlyingStore.executeQuery(query));
View Full Code Here

            throw new SearchException(msg);
        }

        if (isStatisticsEnabled()) {
            long start = System.currentTimeMillis();
            Results results = this.compoundStore.executeQuery(query);
            sampledCacheStatistics.notifyCacheSearch(System.currentTimeMillis() - start);
            return results;
        }

        return this.compoundStore.executeQuery(query);
View Full Code Here

TOP

Related Classes of net.sf.ehcache.search.Results

Copyright © 2018 www.massapicom. 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.