Ejemplo n.º 1
0
  int internalAddRow(SqlStatement stmt, int column) throws SQLException {
    RolapMember member = null;
    if (getCurrMember() != null) {
      member = getCurrMember();
    } else {
      boolean checkCacheStatus = true;
      final List<SqlStatement.Accessor> accessors = stmt.getAccessors();
      for (int i = 0; i <= levelDepth; i++) {
        RolapLevel childLevel = levels[i];
        if (childLevel.isAll()) {
          member = memberBuilder.allMember();
          continue;
        }

        if (childLevel.isParentChild()) {
          column++;
        }

        Object value = accessors.get(column++).get();
        if (value == null) {
          value = RolapUtil.sqlNullValue;
        }
        Object captionValue;
        if (childLevel.hasCaptionColumn()) {
          captionValue = accessors.get(column++).get();
        } else {
          captionValue = null;
        }
        RolapMember parentMember = member;
        Object key = cache.makeKey(parentMember, value);
        member = cache.getMember(key, checkCacheStatus);
        checkCacheStatus = false; /* Only check the first time */
        if (member == null) {
          if (constraint instanceof RolapNativeCrossJoin.NonEmptyCrossJoinConstraint
              && childLevel.isParentChild()) {
            member = castToNonEmptyCJConstraint(constraint).findMember(value);
          }
          if (member == null) {
            member =
                memberBuilder.makeMember(
                    parentMember, childLevel, value, captionValue, parentChild, stmt, key, column);
          }
        }

        // Skip over the columns consumed by makeMember
        if (!childLevel.getOrdinalExp().equals(childLevel.getKeyExp())) {
          ++column;
        }
        column += childLevel.getProperties().length;
      }
      setCurrMember(member);
    }
    getList().add(member);
    return column;
  }
Ejemplo n.º 2
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();
   }
 }