Ejemplo n.º 1
0
        @Override
        public void serialize(GTScanRequest value, ByteBuffer out) {
          GTInfo.serializer.serialize(value.info, out);

          BytesUtil.writeVInt(value.ranges.size(), out);
          for (GTScanRange range : value.ranges) {
            serializeGTRecord(range.pkStart, out);
            serializeGTRecord(range.pkEnd, out);
            BytesUtil.writeVInt(range.fuzzyKeys.size(), out);
            for (GTRecord f : range.fuzzyKeys) {
              serializeGTRecord(f, out);
            }
          }

          ImmutableBitSet.serializer.serialize(value.columns, out);
          BytesUtil.writeByteArray(GTUtil.serializeGTFilter(value.filterPushDown, value.info), out);

          ImmutableBitSet.serializer.serialize(value.aggrGroupBy, out);
          ImmutableBitSet.serializer.serialize(value.aggrMetrics, out);
          BytesUtil.writeAsciiStringArray(value.aggrMetricsFuncs, out);
          BytesUtil.writeVInt(value.allowStorageAggregation ? 1 : 0, out);
          out.putDouble(value.aggCacheMemThreshold);
          BytesUtil.writeVInt(value.storageScanRowNumThreshold, out);
          BytesUtil.writeVInt(value.storagePushDownLimit, out);
          BytesUtil.writeVLong(value.startTime, out);
          BytesUtil.writeVLong(value.timeout, out);
          BytesUtil.writeUTFString(value.storageBehavior, out);
        }
Ejemplo n.º 2
0
        @Override
        public GTScanRequest deserialize(ByteBuffer in) {
          GTInfo sInfo = GTInfo.serializer.deserialize(in);

          List<GTScanRange> sRanges = Lists.newArrayList();
          int sRangesCount = BytesUtil.readVInt(in);
          for (int rangeIdx = 0; rangeIdx < sRangesCount; rangeIdx++) {
            GTRecord sPkStart = deserializeGTRecord(in, sInfo);
            GTRecord sPkEnd = deserializeGTRecord(in, sInfo);
            List<GTRecord> sFuzzyKeys = Lists.newArrayList();
            int sFuzzyKeySize = BytesUtil.readVInt(in);
            for (int i = 0; i < sFuzzyKeySize; i++) {
              sFuzzyKeys.add(deserializeGTRecord(in, sInfo));
            }
            GTScanRange sRange = new GTScanRange(sPkStart, sPkEnd, sFuzzyKeys);
            sRanges.add(sRange);
          }

          ImmutableBitSet sColumns = ImmutableBitSet.serializer.deserialize(in);
          TupleFilter sGTFilter = GTUtil.deserializeGTFilter(BytesUtil.readByteArray(in), sInfo);

          ImmutableBitSet sAggGroupBy = ImmutableBitSet.serializer.deserialize(in);
          ImmutableBitSet sAggrMetrics = ImmutableBitSet.serializer.deserialize(in);
          String[] sAggrMetricFuncs = BytesUtil.readAsciiStringArray(in);
          boolean sAllowPreAggr = (BytesUtil.readVInt(in) == 1);
          double sAggrCacheGB = in.getDouble();
          int storageScanRowNumThreshold = BytesUtil.readVInt(in);
          int storagePushDownLimit = BytesUtil.readVInt(in);
          long startTime = BytesUtil.readVLong(in);
          long timeout = BytesUtil.readVLong(in);
          String storageBehavior = BytesUtil.readUTFString(in);

          return new GTScanRequestBuilder()
              .setInfo(sInfo)
              .setRanges(sRanges)
              .setDimensions(sColumns)
              . //
              setAggrGroupBy(sAggGroupBy)
              .setAggrMetrics(sAggrMetrics)
              .setAggrMetricsFuncs(sAggrMetricFuncs)
              . //
              setFilterPushDown(sGTFilter)
              .setAllowStorageAggregation(sAllowPreAggr)
              .setAggCacheMemThreshold(sAggrCacheGB)
              . //
              setStorageScanRowNumThreshold(storageScanRowNumThreshold)
              .setStoragePushDownLimit(storagePushDownLimit)
              . //
              setStartTime(startTime)
              .setTimeout(timeout)
              .setStorageBehavior(storageBehavior)
              .createGTScanRequest();
        }
 private void initDebugString() {
   this.startKeyString = BytesUtil.toHex(this.startKey);
   this.stopKeyString = BytesUtil.toHex(this.stopKey);
   StringBuilder buf = new StringBuilder();
   for (Pair<byte[], byte[]> fuzzyKey : this.fuzzyKeys) {
     buf.append(BytesUtil.toHex(fuzzyKey.getFirst()));
     buf.append(" ");
     buf.append(BytesUtil.toHex(fuzzyKey.getSecond()));
     buf.append(System.lineSeparator());
   }
   this.fuzzyKeyString = buf.toString();
 }
Ejemplo n.º 4
0
 private GTRecord deserializeGTRecord(ByteBuffer in, GTInfo sInfo) {
   int colLength = BytesUtil.readVInt(in);
   ByteArray[] sCols = new ByteArray[colLength];
   for (int i = 0; i < colLength; i++) {
     sCols[i] = ByteArray.importData(in);
   }
   return new GTRecord(sInfo, sCols);
 }
 /** the reverse of dictIdToString(), returns integer ID */
 public static int stringToDictId(String str) {
   try {
     byte[] bytes = str.getBytes("ISO-8859-1");
     return BytesUtil.readUnsigned(bytes, 0, bytes.length);
   } catch (UnsupportedEncodingException e) {
     // never happen
     return 0;
   }
 }
Ejemplo n.º 6
0
        @Override
        public GTScanRequest deserialize(ByteBuffer in) {
          GTInfo sInfo = GTInfo.serializer.deserialize(in);

          List<GTScanRange> sRanges = Lists.newArrayList();
          int sRangesCount = BytesUtil.readVInt(in);
          for (int rangeIdx = 0; rangeIdx < sRangesCount; rangeIdx++) {
            GTRecord sPkStart = deserializeGTRecord(in, sInfo);
            GTRecord sPkEnd = deserializeGTRecord(in, sInfo);
            List<GTRecord> sFuzzyKeys = Lists.newArrayList();
            int sFuzzyKeySize = BytesUtil.readVInt(in);
            for (int i = 0; i < sFuzzyKeySize; i++) {
              sFuzzyKeys.add(deserializeGTRecord(in, sInfo));
            }
            GTScanRange sRange = new GTScanRange(sPkStart, sPkEnd, sFuzzyKeys);
            sRanges.add(sRange);
          }

          ImmutableBitSet sColumns = ImmutableBitSet.serializer.deserialize(in);
          TupleFilter sGTFilter = GTUtil.deserializeGTFilter(BytesUtil.readByteArray(in), sInfo);

          ImmutableBitSet sAggGroupBy = ImmutableBitSet.serializer.deserialize(in);
          ImmutableBitSet sAggrMetrics = ImmutableBitSet.serializer.deserialize(in);
          String[] sAggrMetricFuncs = BytesUtil.readAsciiStringArray(in);
          boolean sAllowPreAggr = (BytesUtil.readVInt(in) == 1);
          double sAggrCacheGB = in.getDouble();

          return new GTScanRequest(
              sInfo,
              sRanges,
              sColumns,
              sAggGroupBy,
              sAggrMetrics,
              sAggrMetricFuncs,
              sGTFilter,
              sAllowPreAggr,
              sAggrCacheGB);
        }
Ejemplo n.º 7
0
        @Override
        public void serialize(GTScanRequest value, ByteBuffer out) {
          GTInfo.serializer.serialize(value.info, out);

          BytesUtil.writeVInt(value.ranges.size(), out);
          for (GTScanRange range : value.ranges) {
            serializeGTRecord(range.pkStart, out);
            serializeGTRecord(range.pkEnd, out);
            BytesUtil.writeVInt(range.fuzzyKeys.size(), out);
            for (GTRecord f : range.fuzzyKeys) {
              serializeGTRecord(f, out);
            }
          }

          ImmutableBitSet.serializer.serialize(value.columns, out);
          BytesUtil.writeByteArray(GTUtil.serializeGTFilter(value.filterPushDown, value.info), out);

          ImmutableBitSet.serializer.serialize(value.aggrGroupBy, out);
          ImmutableBitSet.serializer.serialize(value.aggrMetrics, out);
          BytesUtil.writeAsciiStringArray(value.aggrMetricsFuncs, out);
          BytesUtil.writeVInt(value.allowPreAggregation ? 1 : 0, out);
          out.putDouble(value.aggrCacheGB);
        }
Ejemplo n.º 8
0
 private void serializeGTRecord(GTRecord gtRecord, ByteBuffer out) {
   BytesUtil.writeVInt(gtRecord.cols.length, out);
   for (ByteArray col : gtRecord.cols) {
     col.exportData(out);
   }
 }