当前位置: 首页>>代码示例>>Java>>正文


Java BoundType.valueOf方法代码示例

本文整理汇总了Java中com.google.common.collect.BoundType.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java BoundType.valueOf方法的具体用法?Java BoundType.valueOf怎么用?Java BoundType.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.BoundType的用法示例。


在下文中一共展示了BoundType.valueOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bt

import com.google.common.collect.BoundType; //导入方法依赖的package包/类
private BoundType bt(JsonPrimitive p) {
  try {
    return BoundType.valueOf(p.toString());
  } catch (Throwable t) {
    return BoundType.CLOSED;
  }
}
 
开发者ID:OpenSocial,项目名称:activitystreams,代码行数:8,代码来源:Adapters.java

示例2: getTimeRangeWhereClause

import com.google.common.collect.BoundType; //导入方法依赖的package包/类
@Override
public String getTimeRangeWhereClause(CubeQueryContext cubeQueryContext, String tableName,
  Set<FactPartition> rangeParts) throws LensException {
  if (rangeParts.size() == 0) {
    return "";
  }
  //Flag to check if only between range needs to be used
  boolean useBetweenOnly = cubeQueryContext.getConf().getBoolean(CubeQueryConfUtil.BETWEEN_ONLY_TIME_RANGE_WRITER,
    CubeQueryConfUtil.DEFAULT_BETWEEN_ONLY_TIME_RANGE_WRITER);

  //Fetch the date start and end bounds from config
  BoundType startBound = BoundType.valueOf(cubeQueryContext.getConf().get(CubeQueryConfUtil.START_DATE_BOUND_TYPE,
    CubeQueryConfUtil.DEFAULT_START_BOUND_TYPE));
  BoundType endBound = BoundType.valueOf(cubeQueryContext.getConf().get(CubeQueryConfUtil.END_DATE_BOUND_TYPE,
    CubeQueryConfUtil.DEFAULT_END_BOUND_TYPE));

  StringBuilder partStr = new StringBuilder();
  if (!useBetweenOnly && rangeParts.size() == 1) {
    partStr.append("(");
    String partFilter =
      TimeRangeUtils.getTimeRangePartitionFilter(rangeParts.iterator().next(), cubeQueryContext, tableName);
    partStr.append(partFilter);
    partStr.append(")");
  } else {
    TreeSet<FactPartition> parts = new TreeSet<>();
    FactPartition first = null;
    for (FactPartition part : rangeParts) {
      if (part.hasContainingPart()) {
        throw new LensException(LensCubeErrorCode.CANNOT_USE_TIMERANGE_WRITER.getLensErrorInfo(),
          "Partition has containing part");
      }
      if (first == null) {
        first = part;
      } else {
        // validate partcol, update period are same for both
        if (!first.getPartCol().equalsIgnoreCase(part.getPartCol())) {
          throw new LensException(LensCubeErrorCode.CANNOT_USE_TIMERANGE_WRITER.getLensErrorInfo(),
            "Part columns are different in partitions");
        }
        if (!first.getPeriod().equals(part.getPeriod())) {
          throw new LensException(LensCubeErrorCode.CANNOT_USE_TIMERANGE_WRITER.getLensErrorInfo(),
            "Partitions are in different update periods");
        }
      }
      parts.add(part);
    }

    FactPartition start = parts.first();
    FactPartition end = parts.last();

    if (startBound.equals(BoundType.OPEN)) {
      start = start.previous();
    }

    if (endBound.equals(BoundType.OPEN)) {
      end = end.next();
    }

    String partCol = start.getPartCol();
    if (!cubeQueryContext.shouldReplaceTimeDimWithPart()) {
      partCol = cubeQueryContext.getTimeDimOfPartitionColumn(partCol);
    }

    partStr.append(" (").append(tableName).append(".").append(partCol).append(" BETWEEN '")
      .append(start.getFormattedPartSpec()).append("' AND '").append(end.getFormattedPartSpec()).append("') ");
  }
  return partStr.toString();
}
 
开发者ID:apache,项目名称:lens,代码行数:69,代码来源:BetweenTimeRangeWriter.java


注:本文中的com.google.common.collect.BoundType.valueOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。