Esempio n. 1
0
  public SegmentCacheManager(MondrianServer server) {
    this.server = server;
    ACTOR = new Actor();
    thread = new Thread(ACTOR, "mondrian.rolap.agg.SegmentCacheManager$ACTOR");
    thread.setDaemon(true);
    thread.start();

    // Create the index registry.
    this.indexRegistry = new SegmentCacheIndexRegistry();

    // Add a local cache, if needed.
    if (!MondrianProperties.instance().DisableCaching.get()) {
      final MemorySegmentCache cache = new MemorySegmentCache();
      segmentCacheWorkers.add(new SegmentCacheWorker(cache, thread));
    }

    // Add an external cache, if configured.
    final List<SegmentCache> externalCache = SegmentCacheWorker.initCache();
    for (SegmentCache cache : externalCache) {
      // Create a worker for this external cache
      segmentCacheWorkers.add(new SegmentCacheWorker(cache, thread));
      // Hook up a listener so it can update
      // the segment index.
      cache.addListener(new AsyncCacheListener(this, server));
    }

    compositeCache = new CompositeSegmentCache(segmentCacheWorkers);
  }
  /**
   * Creates a MondrianOlap4jCellSetAxisMetaData.
   *
   * @param cellSetMetaData Cell set axis metadata
   * @param queryAxis Query axis
   */
  MondrianOlap4jCellSetAxisMetaData(
      MondrianOlap4jCellSetMetaData cellSetMetaData, QueryAxis queryAxis) {
    if (queryAxis == null) {
      queryAxis =
          new QueryAxis(
              false,
              null,
              AxisOrdinal.StandardAxisOrdinal.SLICER,
              QueryAxis.SubtotalVisibility.Undefined);
    }
    this.queryAxis = queryAxis;
    this.cellSetMetaData = cellSetMetaData;

    // populate property list
    for (Id id : queryAxis.getDimensionProperties()) {
      propertyList.add(Property.StandardMemberProperty.valueOf(id.toStringArray()[0]));
    }
  }
Esempio n. 3
0
 public List<SegmentHeader> getSegmentHeaders() {
   // Special case 0 and 1 workers, for which the 'union' operation
   // is trivial.
   switch (workers.size()) {
     case 0:
       return Collections.emptyList();
     case 1:
       return workers.get(0).getSegmentHeaders();
     default:
       final List<SegmentHeader> list = new ArrayList<SegmentHeader>();
       final Set<SegmentHeader> set = new HashSet<SegmentHeader>();
       for (SegmentCacheWorker worker : workers) {
         for (SegmentHeader header : worker.getSegmentHeaders()) {
           if (set.add(header)) {
             list.add(header);
           }
         }
       }
       return list;
   }
 }
 public List<Hierarchy> getHierarchies() {
   if (queryAxis.getAxisOrdinal().isFilter()) {
     // Slicer contains all dimensions not mentioned on other axes.
     // The list contains the default hierarchy of
     // each dimension not already in the slicer or in another axes.
     Set<Dimension> dimensionSet = new HashSet<Dimension>();
     for (CellSetAxisMetaData cellSetAxisMetaData : cellSetMetaData.getAxesMetaData()) {
       for (Hierarchy hierarchy : cellSetAxisMetaData.getHierarchies()) {
         dimensionSet.add(hierarchy.getDimension());
       }
     }
     List<Hierarchy> hierarchyList = new ArrayList<Hierarchy>();
     for (Dimension dimension : cellSetMetaData.getCube().getDimensions()) {
       if (dimensionSet.add(dimension)) {
         hierarchyList.add(dimension.getDefaultHierarchy());
       }
     }
     // In case a dimension has multiple hierarchies, return the
     // declared type of the slicer expression. For example, if the
     // WHERE clause contains [Time].[Weekly].[1997].[Week 6], the
     // slicer should contain [Time].[Weekly] not the default hierarchy
     // [Time].
     for (Hierarchy hierarchy : getHierarchiesNonFilter()) {
       if (hierarchy.getDimension().getHierarchies().size() == 1) {
         continue;
       }
       for (int i = 0; i < hierarchyList.size(); i++) {
         Hierarchy hierarchy1 = hierarchyList.get(i);
         if (hierarchy1.getDimension().equals(hierarchy.getDimension())
             && hierarchy1 != hierarchy) {
           hierarchyList.set(i, hierarchy);
         }
       }
     }
     return hierarchyList;
   } else {
     return getHierarchiesNonFilter();
   }
 }
 /**
  * Returns the hierarchies on a non-filter axis.
  *
  * @return List of hierarchies, never null
  */
 private List<Hierarchy> getHierarchiesNonFilter() {
   final Exp exp = queryAxis.getSet();
   if (exp == null) {
     return Collections.emptyList();
   }
   Type type = exp.getType();
   if (type instanceof SetType) {
     type = ((SetType) type).getElementType();
   }
   final MondrianOlap4jConnection olap4jConnection =
       cellSetMetaData.olap4jStatement.olap4jConnection;
   if (type instanceof TupleType) {
     final TupleType tupleType = (TupleType) type;
     List<Hierarchy> hierarchyList = new ArrayList<Hierarchy>();
     for (Type elementType : tupleType.elementTypes) {
       hierarchyList.add(olap4jConnection.toOlap4j(elementType.getHierarchy()));
     }
     return hierarchyList;
   } else {
     return Collections.singletonList((Hierarchy) olap4jConnection.toOlap4j(type.getHierarchy()));
   }
 }