Esempio n. 1
0
  /**
   * @param bytes
   * @return cuboid ID
   */
  public long split(byte[] bytes) {
    this.bufferSize = 0;
    int offset = 0;

    if (enableSharding) {
      // extract shard
      SplittedBytes shardSplit = this.splitBuffers[this.bufferSize++];
      shardSplit.length = RowConstants.ROWKEY_SHARDID_LEN;
      System.arraycopy(bytes, offset, shardSplit.value, 0, RowConstants.ROWKEY_SHARDID_LEN);
      offset += RowConstants.ROWKEY_SHARDID_LEN;
      // lastSplittedShard = Bytes.toShort(shardSplit.value, 0, shardSplit.length);
    }

    // extract cuboid id
    SplittedBytes cuboidIdSplit = this.splitBuffers[this.bufferSize++];
    cuboidIdSplit.length = RowConstants.ROWKEY_CUBOIDID_LEN;
    System.arraycopy(bytes, offset, cuboidIdSplit.value, 0, RowConstants.ROWKEY_CUBOIDID_LEN);
    offset += RowConstants.ROWKEY_CUBOIDID_LEN;

    lastSplittedCuboidId = Bytes.toLong(cuboidIdSplit.value, 0, cuboidIdSplit.length);
    Cuboid cuboid = Cuboid.findById(cubeDesc, lastSplittedCuboidId);

    // rowkey columns
    for (int i = 0; i < cuboid.getColumns().size(); i++) {
      TblColRef col = cuboid.getColumns().get(i);
      int colLength = colIO.getColumnLength(col);
      SplittedBytes split = this.splitBuffers[this.bufferSize++];
      split.length = colLength;
      System.arraycopy(bytes, offset, split.value, 0, colLength);
      offset += colLength;
    }

    return lastSplittedCuboidId;
  }
Esempio n. 2
0
  public void logQuery(final SQLRequest request, final SQLResponse response) {
    final String user = SecurityContextHolder.getContext().getAuthentication().getName();
    final Set<String> realizationNames = new HashSet<String>();
    final Set<Long> cuboidIds = new HashSet<Long>();
    float duration = response.getDuration() / (float) 1000;

    if (!response.isHitCache() && null != OLAPContext.getThreadLocalContexts()) {
      for (OLAPContext ctx : OLAPContext.getThreadLocalContexts()) {
        Cuboid cuboid = ctx.storageContext.getCuboid();
        if (cuboid != null) {
          // Some queries do not involve cuboid, e.g. lookup table query
          cuboidIds.add(cuboid.getId());
        }

        if (ctx.realization != null) {
          String realizationName = ctx.realization.getName();
          realizationNames.add(realizationName);
        }
      }
    }

    int resultRowCount = 0;
    if (!response.getIsException() && response.getResults() != null) {
      resultRowCount = response.getResults().size();
    }

    String newLine = System.getProperty("line.separator");
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(newLine);
    stringBuilder
        .append("==========================[QUERY]===============================")
        .append(newLine);
    stringBuilder.append("SQL: ").append(request.getSql()).append(newLine);
    stringBuilder.append("User: "******"Success: ")
        .append((null == response.getExceptionMessage()))
        .append(newLine);
    stringBuilder.append("Duration: ").append(duration).append(newLine);
    stringBuilder.append("Project: ").append(request.getProject()).append(newLine);
    stringBuilder.append("Realization Names: ").append(realizationNames).append(newLine);
    stringBuilder.append("Cuboid Ids: ").append(cuboidIds).append(newLine);
    stringBuilder.append("Total scan count: ").append(response.getTotalScanCount()).append(newLine);
    stringBuilder.append("Result row count: ").append(resultRowCount).append(newLine);
    stringBuilder.append("Accept Partial: ").append(request.isAcceptPartial()).append(newLine);
    stringBuilder.append("Is Partial Result: ").append(response.isPartial()).append(newLine);
    stringBuilder.append("Hit Cache: ").append(response.isHitCache()).append(newLine);
    stringBuilder.append("Message: ").append(response.getExceptionMessage()).append(newLine);
    stringBuilder
        .append("==========================[QUERY]===============================")
        .append(newLine);

    logger.info(stringBuilder.toString());
  }
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((cubeSeg == null) ? 0 : cubeSeg.hashCode());
   result = prime * result + ((cuboid == null) ? 0 : cuboid.hashCode());
   result = prime * result + ((fuzzyKeyString == null) ? 0 : fuzzyKeyString.hashCode());
   result = prime * result + ((startKeyString == null) ? 0 : startKeyString.hashCode());
   result = prime * result + ((stopKeyString == null) ? 0 : stopKeyString.hashCode());
   return result;
 }
 public HBaseKeyRange(
     Collection<TblColRef> dimensionColumns,
     Collection<ColumnValueRange> andDimensionRanges,
     CubeSegment cubeSeg,
     CubeDesc cubeDesc) {
   this.cubeSeg = cubeSeg;
   long cuboidId = this.calculateCuboidID(cubeDesc, dimensionColumns);
   this.cuboid = Cuboid.findById(cubeDesc, cuboidId);
   this.flatOrAndFilter = Lists.newLinkedList();
   this.flatOrAndFilter.add(andDimensionRanges);
   init(andDimensionRanges);
   initDebugString();
 }
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   HBaseKeyRange other = (HBaseKeyRange) obj;
   if (cubeSeg == null) {
     if (other.cubeSeg != null) return false;
   } else if (!cubeSeg.equals(other.cubeSeg)) return false;
   if (cuboid == null) {
     if (other.cuboid != null) return false;
   } else if (!cuboid.equals(other.cuboid)) return false;
   if (fuzzyKeyString == null) {
     if (other.fuzzyKeyString != null) return false;
   } else if (!fuzzyKeyString.equals(other.fuzzyKeyString)) return false;
   if (startKeyString == null) {
     if (other.startKeyString != null) return false;
   } else if (!startKeyString.equals(other.startKeyString)) return false;
   if (stopKeyString == null) {
     if (other.stopKeyString != null) return false;
   } else if (!stopKeyString.equals(other.stopKeyString)) return false;
   return true;
 }