org.apache.hbase.thirdparty.com.google.common.base.Preconditions.checkArgument()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(228)

本文整理了Java中org.apache.hbase.thirdparty.com.google.common.base.Preconditions.checkArgument()方法的一些代码示例,展示了Preconditions.checkArgument()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Preconditions.checkArgument()方法的具体详情如下:
包路径:org.apache.hbase.thirdparty.com.google.common.base.Preconditions
类名称:Preconditions
方法名:checkArgument

Preconditions.checkArgument介绍

[英]Ensures the truth of an expression involving one or more parameters to the calling method.
[中]确保涉及调用方法的一个或多个参数的表达式的真实性。

代码示例

代码示例来源:origin: apache/hbase

private void sanityCheckConfigs() {
 Preconditions.checkArgument(acceptableFactor <= 1 && acceptableFactor >= 0, ACCEPT_FACTOR_CONFIG_NAME + " must be between 0.0 and 1.0");
 Preconditions.checkArgument(minFactor <= 1 && minFactor >= 0, MIN_FACTOR_CONFIG_NAME + " must be between 0.0 and 1.0");
 Preconditions.checkArgument(minFactor <= acceptableFactor, MIN_FACTOR_CONFIG_NAME + " must be <= " + ACCEPT_FACTOR_CONFIG_NAME);
 Preconditions.checkArgument(extraFreeFactor >= 0, EXTRA_FREE_FACTOR_CONFIG_NAME + " must be greater than 0.0");
 Preconditions.checkArgument(singleFactor <= 1 && singleFactor >= 0, SINGLE_FACTOR_CONFIG_NAME + " must be between 0.0 and 1.0");
 Preconditions.checkArgument(multiFactor <= 1 && multiFactor >= 0, MULTI_FACTOR_CONFIG_NAME + " must be between 0.0 and 1.0");
 Preconditions.checkArgument(memoryFactor <= 1 && memoryFactor >= 0, MEMORY_FACTOR_CONFIG_NAME + " must be between 0.0 and 1.0");
 Preconditions.checkArgument((singleFactor + multiFactor + memoryFactor) == 1, SINGLE_FACTOR_CONFIG_NAME + ", " +
   MULTI_FACTOR_CONFIG_NAME + ", and " + MEMORY_FACTOR_CONFIG_NAME + " segments must add up to 1.0");
}

代码示例来源:origin: apache/hbase

@Override
public AsyncBufferedMutatorBuilder setWriteBufferSize(long writeBufferSize) {
 Preconditions.checkArgument(writeBufferSize > 0, "writeBufferSize %d must be >= 0",
  writeBufferSize);
 this.writeBufferSize = writeBufferSize;
 return this;
}

代码示例来源:origin: apache/hbase

static short toShort(byte hi, byte lo) {
  short s = (short) (((hi & 0xFF) << 8) | (lo & 0xFF));
  Preconditions.checkArgument(s >= 0);
  return s;
 }
}

代码示例来源:origin: apache/hbase

public MiniBatchOperationInProgress(T[] operations, OperationStatus[] retCodeDetails,
  WALEdit[] walEditsFromCoprocessors, int firstIndex, int lastIndexExclusive,
  int readyToWriteCount) {
 Preconditions.checkArgument(readyToWriteCount <= (lastIndexExclusive - firstIndex));
 this.operations = operations;
 this.retCodeDetails = retCodeDetails;
 this.walEditsFromCoprocessors = walEditsFromCoprocessors;
 this.firstIndex = firstIndex;
 this.lastIndexExclusive = lastIndexExclusive;
 this.readyToWriteCount = readyToWriteCount;
}

代码示例来源:origin: apache/hbase

/** Scale valueIn in the range [baseMin,baseMax] to the range [limitMin,limitMax] */
 private static double scale(double valueIn, double baseMin, double baseMax, double limitMin,
   double limitMax) {
  Preconditions.checkArgument(baseMin <= baseMax, "Illegal source range [%s,%s]",
    baseMin, baseMax);
  Preconditions.checkArgument(limitMin <= limitMax, "Illegal target range [%s,%s]",
    limitMin, limitMax);
  Preconditions.checkArgument(valueIn >= baseMin && valueIn <= baseMax,
    "Value %s must be within the range [%s,%s]", valueIn, baseMin, baseMax);
  return ((limitMax - limitMin) * (valueIn - baseMin) / (baseMax - baseMin)) + limitMin;
 }
}

代码示例来源:origin: apache/hbase

public RetryConfig setJitter(float jitter) {
 Preconditions.checkArgument(jitter >= 0.0f && jitter < 1.0f,
  "Invalid jitter: %s, should be in range [0.0, 1.0)", jitter);
 this.jitter = jitter;
 return this;
}

代码示例来源:origin: apache/hbase

/**
 * Constructor that takes a maximum page size.
 *
 * @param pageSize Maximum result size.
 */
public PageFilter(final long pageSize) {
 Preconditions.checkArgument(pageSize >= 0, "must be positive %s", pageSize);
 this.pageSize = pageSize;
}

代码示例来源:origin: apache/hbase

public MemoryBoundedLogMessageBuffer(long maxSizeBytes) {
 Preconditions.checkArgument(
   maxSizeBytes > 0);
 this.maxSizeBytes = maxSizeBytes;
 this.messages = Lists.newLinkedList();
}

代码示例来源:origin: apache/hbase

@Override
 public List<Path> compact(ThroughputController throughputController, User user)
   throws IOException {
  Preconditions.checkArgument(this.stripeRequest != null, "Cannot compact without selection");
  return this.stripeRequest.execute(compactor, throughputController, user);
 }
}

代码示例来源:origin: apache/hbase

private Procedure<TEnvironment> prepareProcedure(Procedure<TEnvironment> proc) {
 Preconditions.checkArgument(proc.getState() == ProcedureState.INITIALIZING);
 Preconditions.checkArgument(!proc.hasParent(), "unexpected parent", proc);
 if (this.checkOwnerSet) {
  Preconditions.checkArgument(proc.hasOwner(), "missing owner");
 }
 return proc;
}

代码示例来源:origin: apache/hbase

@Override
public void setIv(byte[] iv) {
 Preconditions.checkNotNull(iv, "IV cannot be null");
 Preconditions.checkArgument(iv.length == AES.IV_LENGTH, "Invalid IV length");
 this.iv = iv;
}

代码示例来源:origin: apache/hbase

public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
 Preconditions.checkArgument(filterArguments.isEmpty(),
               "Expected 0 but got: %s", filterArguments.size());
 return new FirstKeyOnlyFilter();
}

代码示例来源:origin: apache/hbase

public static QueueBalancer getBalancer(int queueSize) {
 Preconditions.checkArgument(queueSize > 0, "Queue size is <= 0, must be at least 1");
 if (queueSize == 1) {
  return ONE_QUEUE;
 } else {
  return new RandomQueueBalancer(queueSize);
 }
}

代码示例来源:origin: apache/hbase

public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
 Preconditions.checkArgument((filterArguments.isEmpty() || filterArguments.size() == 1),
               "Expected: 0 or 1 but got: %s", filterArguments.size());
 KeyOnlyFilter filter = new KeyOnlyFilter();
 if (filterArguments.size() == 1) {
  filter.lenAsVal = ParseFilter.convertByteArrayToBoolean(filterArguments.get(0));
 }
 return filter;
}

代码示例来源:origin: apache/hbase

public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
 Preconditions.checkArgument(filterArguments.size() == 1,
               "Expected 1 but got: %s", filterArguments.size());
 long pageSize = ParseFilter.convertByteArrayToLong(filterArguments.get(0));
 return new PageFilter(pageSize);
}

代码示例来源:origin: apache/hbase

public static Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
 Preconditions.checkArgument(filterArguments.size() == 1,
               "Expected 1 but got: %s", filterArguments.size());
 byte [] stopRowKey = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));
 return new InclusiveStopFilter(stopRowKey);
}

代码示例来源:origin: apache/hbase

public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
 Preconditions.checkArgument(filterArguments.size() == 1,
               "Expected 1 but got: %s", filterArguments.size());
 byte [] columnPrefix = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));
 return new ColumnPrefixFilter(columnPrefix);
}

代码示例来源:origin: apache/hbase

public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
 Preconditions.checkArgument(filterArguments.size() == 1,
               "Expected 1 but got: %s", filterArguments.size());
 int limit = ParseFilter.convertByteArrayToInt(filterArguments.get(0));
 return new ColumnCountGetFilter(limit);
}

代码示例来源:origin: apache/hbase

public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
 Preconditions.checkArgument(filterArguments.size() == 2,
               "Expected 2 but got: %s", filterArguments.size());
 int limit = ParseFilter.convertByteArrayToInt(filterArguments.get(0));
 int offset = ParseFilter.convertByteArrayToInt(filterArguments.get(1));
 return new ColumnPaginationFilter(limit, offset);
}

代码示例来源:origin: apache/hbase

/** Adds the files to compacting files. filesCompacting must be locked. */
private void addToCompactingFiles(Collection<HStoreFile> filesToAdd) {
 if (CollectionUtils.isEmpty(filesToAdd)) {
  return;
 }
 // Check that we do not try to compact the same StoreFile twice.
 if (!Collections.disjoint(filesCompacting, filesToAdd)) {
  Preconditions.checkArgument(false, "%s overlaps with %s", filesToAdd, filesCompacting);
 }
 filesCompacting.addAll(filesToAdd);
 Collections.sort(filesCompacting, storeEngine.getStoreFileManager().getStoreFileComparator());
}

相关文章