當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteString.isEmpty方法代碼示例

本文整理匯總了Java中com.google.protobuf.ByteString.isEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteString.isEmpty方法的具體用法?Java ByteString.isEmpty怎麽用?Java ByteString.isEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.protobuf.ByteString的用法示例。


在下文中一共展示了ByteString.isEmpty方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: rightCompareTo

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
private static int rightCompareTo(ByteString lhs, ByteString rhs) {
  requireNonNull(lhs, "lhs is null");
  requireNonNull(rhs, "rhs is null");

  // both infinite
  if (lhs.isEmpty() && rhs.isEmpty()) {
    return 0;
  }
  if (lhs.isEmpty()) {
    return 1;
  }
  if (rhs.isEmpty()) {
    return -1;
  }

  return Comparables.wrap(lhs).compareTo(Comparables.wrap(rhs));
}
 
開發者ID:pingcap,項目名稱:tikv-client-lib-java,代碼行數:18,代碼來源:RangeSplitter.java

示例2: switchMatchModeActor

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
private ActorRef switchMatchModeActor(ApiRequest request) {
    ByteString matchMode = request.getArgs(0);
    if (matchMode == null || matchMode.isEmpty()) {
        throw new IllegalArgumentException("Arg : matchMode must be input.");
    }

    return selectMatchModeActorRef(MATCH_MODE.forNumber(Integer.valueOf(matchMode.toStringUtf8())));
}
 
開發者ID:freedompy,項目名稱:commelina,代碼行數:9,代碼來源:MatchBackend.java

示例3: getDatabase

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
public TiDBInfo getDatabase(long id) {
  ByteString dbKey = encodeDatabaseID(id);
  ByteString json = hashGet(KEY_DB, dbKey);
  if (json == null || json.isEmpty()) {
    return null;
  }
  return parseFromJson(json, TiDBInfo.class);
}
 
開發者ID:pingcap,項目名稱:tikv-client-lib-java,代碼行數:9,代碼來源:CatalogTransaction.java

示例4: makeRange

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
public static Range makeRange(ByteString startKey, ByteString endKey) {
  if (startKey.isEmpty() && endKey.isEmpty()) {
    return Range.all();
  }
  if (startKey.isEmpty()) {
    return Range.lessThan(Comparables.wrap(endKey));
  } else if (endKey.isEmpty()) {
    return Range.atLeast(Comparables.wrap(startKey));
  }
  return Range.closedOpen(Comparables.wrap(startKey), Comparables.wrap(endKey));
}
 
開發者ID:pingcap,項目名稱:tikv-client-lib-java,代碼行數:12,代碼來源:KeyRangeUtils.java

示例5: get

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
@Override
public V get(K key) {
  try {
    ByteString value = client.get(storeId, ByteString.copyFrom(keySerializer.serialize(key)));
    if (value != null && !value.isEmpty()) {
      return valueSerializer.deserialize(value.toByteArray());
    } else {
      return null;
    }
  } catch (RpcException e) {
    throw new DatastoreException(format("Failed to get from store id: %s, config: %s", getStoreId(), getConfig().toString()), e);
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:14,代碼來源:RemoteKVStore.java

示例6: advance

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
private void advance() {
  ByteString data = ByteString.EMPTY;
  while (iterator.hasNext() && data.isEmpty()) {
    data = iterator.next();
  }
  input = data.newInput();
}
 
開發者ID:bazelbuild,項目名稱:bazel-buildfarm,代碼行數:8,代碼來源:ByteStringIteratorInputStream.java

示例7: readBlob

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
private void readBlob(
    ReadRequest request,
    StreamObserver<ReadResponse> responseObserver) {
  String resourceName = request.getResourceName();

  Instance instance;
  try {
    instance = instances.getFromBlob(resourceName);
  } catch (InstanceNotFoundException ex) {
    responseObserver.onError(BuildFarmInstances.toStatusException(ex));
    return;
  }

  Digest digest = UrlPath.parseBlobDigest(resourceName);

  ByteString blob = instance.getBlob(
      digest, request.getReadOffset(), request.getReadLimit());
  if (blob == null) {
    responseObserver.onError(new StatusException(Status.NOT_FOUND));
    return;
  }

  while (!blob.isEmpty()) {
    ByteString chunk;
    if (blob.size() < DEFAULT_CHUNK_SIZE) {
      chunk = blob;
      blob = ByteString.EMPTY;
    } else {
      chunk = blob.substring(0, (int) DEFAULT_CHUNK_SIZE);
      blob = blob.substring((int) DEFAULT_CHUNK_SIZE);
    }
    responseObserver.onNext(ReadResponse.newBuilder()
        .setData(chunk)
        .build());
  }

  responseObserver.onCompleted();
}
 
開發者ID:bazelbuild,項目名稱:bazel-buildfarm,代碼行數:39,代碼來源:ByteStreamService.java

示例8: split

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
public static List<Coprocessor.KeyRange> split(Coprocessor.KeyRange range, int splitFactor) {
  if (splitFactor > 32 || splitFactor <= 0 || (splitFactor & (splitFactor - 1)) != 0) {
    throw new TiClientInternalException(
        "splitFactor must be positive integer power of 2 and no greater than 16");
  }

  ByteString startKey = range.getStart();
  ByteString endKey = range.getEnd();
  // we don't cut infinite
  if (startKey.isEmpty() || endKey.isEmpty()) {
    return ImmutableList.of(range);
  }

  ImmutableList.Builder<Coprocessor.KeyRange> resultList = ImmutableList.builder();
  int maxSize = Math.max(startKey.size(), endKey.size());
  int i;

  for (i = 0; i < maxSize; i++) {
    byte sb = i < startKey.size() ? startKey.byteAt(i) : 0;
    byte eb = i < endKey.size() ? endKey.byteAt(i) : 0;
    if (sb != eb) {
      break;
    }
  }

  ByteString sRemaining = i < startKey.size() ? startKey.substring(i) : ByteString.EMPTY;
  ByteString eRemaining = i < endKey.size() ? endKey.substring(i) : ByteString.EMPTY;

  CodecDataInput cdi = new CodecDataInput(sRemaining);
  int uss = cdi.readPartialUnsignedShort();

  cdi = new CodecDataInput(eRemaining);
  int ues = cdi.readPartialUnsignedShort();

  int delta = (ues - uss) / splitFactor;
  if (delta <= 0) {
    return ImmutableList.of(range);
  }

  ByteString prefix = startKey.size() > endKey.size() ?
                      startKey.substring(0, i) : endKey.substring(0, i);
  ByteString newStartKey = startKey;
  ByteString newEndKey;
  for (int j = 0; j < splitFactor; j++) {
    uss += delta;
    if (j == splitFactor - 1) {
      newEndKey = endKey;
    } else {
      CodecDataOutput cdo = new CodecDataOutput();
      cdo.writeShort(uss);
      newEndKey = prefix.concat(cdo.toByteString());
    }
    resultList.add(makeCoprocRange(newStartKey, newEndKey));
    newStartKey = newEndKey;
  }

  return resultList.build();
}
 
開發者ID:pingcap,項目名稱:tikv-client-lib-java,代碼行數:59,代碼來源:KeyRangeUtils.java


注:本文中的com.google.protobuf.ByteString.isEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。