com.palantir.common.annotation.Output类的使用及代码示例

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

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

Output介绍

暂无

代码示例

代码示例来源:origin: palantir/atlasdb

/**
 * There will be size-1 bits set before there is a zero.
 * All the bits of value will or-ed (|=) onto the the passed byte[].
 * @param size must be <= 17 (but will most likely be 10 or 11 at most)
 */
private static void encodeVarLongForSize(long value, @Output byte[] ret, int size) {
  int end = 0;
  if (size > 8) {
    ret[0] = (byte)0xff;
    end = 1;
    size -= 8;
  }
  ret[end] = (byte)((0xff << (9-size)) & 0xff);
  int index = ret.length;
  while (index-- > end) {
    ret[index] |= (byte)((int)value & 0xff);
    value >>>= 8;
  }
}

代码示例来源:origin: palantir/atlasdb

@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
private <T extends AutoCloseable> Optional<T> initializeCloseable(
    Optional<T> closeableOptional, @Output List<AutoCloseable> closeables) {
  closeableOptional.ifPresent(closeables::add);
  return closeableOptional;
}

代码示例来源:origin: palantir/atlasdb

private void doNotSweepTable(TableReference table, @Output Map<TableReference, Double> scores) {
    scores.put(table, 0.0);
  }
}

代码示例来源:origin: palantir/atlasdb

private <T extends AutoCloseable> T initializeCloseable(
    Supplier<T> closeableSupplier, @Output List<AutoCloseable> closeables) {
  T ret = closeableSupplier.get();
  closeables.add(ret);
  return ret;
}

代码示例来源:origin: palantir/atlasdb

private static List<byte[]> persistAll(Iterable<? extends Persistable> persistables, @Output List<byte[]> output) {
    for (Persistable persistable : persistables) {
      output.add(persistable.persistToBytes());
    }
    return output;
  }
}

代码示例来源:origin: palantir/atlasdb

private static Set<Cell> cellsWithConstantColumn(@Output Set<Cell> collector, Iterable<byte[]> rows, byte[] col) {
  for (byte[] row : rows) {
    collector.add(Cell.create(row, col));
  }
  return collector;
}

代码示例来源:origin: palantir/atlasdb

private void getLatestVersionOfCell(byte[] row, Key key, Iterator<Entry<Key, byte[]>> cellIter, long timestamp,
                  @Output Map<Cell, Value> result) {
  Entry<Key, byte[]> lastEntry = null;
  while (cellIter.hasNext()) {
    Entry<Key, byte[]> curEntry = cellIter.next();
    if (curEntry.getKey().ts >= timestamp) {
      break;
    }
    lastEntry = curEntry;
  }
  if (lastEntry != null) {
    long ts = lastEntry.getKey().ts;
    byte[] value = lastEntry.getValue();
    result.put(Cell.create(row, key.col), Value.createWithCopyOfData(value, ts));
  }
}

代码示例来源:origin: palantir/atlasdb

private static void extractTimestampResults(@Output Multimap<Cell, Long> ret,
                      Map<ByteBuffer, List<ColumnOrSuperColumn>> results) {
  for (Entry<ByteBuffer, List<ColumnOrSuperColumn>> result : results.entrySet()) {
    byte[] row = CassandraKeyValueServices.getBytesFromByteBuffer(result.getKey());
    for (ColumnOrSuperColumn col : result.getValue()) {
      Pair<byte[], Long> pair = CassandraKeyValueServices.decomposeName(col.column);
      ret.put(Cell.create(row, pair.lhSide), pair.rhSide);
    }
  }
}

代码示例来源:origin: palantir/atlasdb

private boolean internalCopyRow(RowResult<byte[]> rr,
                  long maxBytes,
                  @Output Map<Cell, byte[]> writeMap,
                  @Output MutableLong bytesPut,
                  @Output Mutable<byte[]> lastRowName) {
    Map<Cell, byte[]> values = rowTransform.apply(rr);
    writeMap.putAll(values);

    for (Map.Entry<Cell, byte[]> e : values.entrySet()) {
      bytesPut.add(e.getValue().length + Cells.getApproxSizeOfCell(e.getKey()));
    }

    if (bytesPut.longValue() >= maxBytes) {
      lastRowName.set(rr.getRowName());
      return false;
    }
    return true;
  }
}

代码示例来源:origin: palantir/atlasdb

private void flushCurrentRow(@Output List<RowResult<Value>> results) {
  getCurrentRowResult().ifPresent(results::add);
  currentRowCells = RangeHelpers.newColumnMap();
}

代码示例来源:origin: palantir/atlasdb

private void copyOldRangesFromPreviousMap(
    RangeAndValue latestRangeAndValue,
    @Output ImmutableRangeMap.Builder<Long, T> builder) {
  timestampMappings()
      .stream()
      .filter(rangeAndValue -> !rangeAndValue.equals(latestRangeAndValue))
      .forEach(rangeAndValue -> builder.put(rangeAndValue.longRange(), rangeAndValue.value()));
}

代码示例来源:origin: palantir/atlasdb

private void scheduleSweepRowTask(@Output List<Future<CqlResult>> futures,
    int queryId,
    int rowIndex,
    AtomicInteger nextRowToQuery,
    List<byte[]> rows,
    ExecutorService executor) {
  if (rowIndex >= rows.size()) {
    return;
  }
  byte[] row = rows.get(rowIndex);
  Callable<CqlResult> task = () -> {
    CqlResult cqlResult = queryExecutor.executePrepared(queryId, ImmutableList.of(ByteBuffer.wrap(row)));
    if (!Thread.interrupted()) {
      scheduleSweepRowTask(futures, queryId, nextRowToQuery.getAndIncrement(), nextRowToQuery, rows,
          executor);
    }
    return cqlResult;
  };
  try {
    Future<CqlResult> future = executor.submit(task);
    futures.set(rowIndex, future);
  } catch (RejectedExecutionException e) {
    // RejectedExecutionException are expected.
    // The executor is shutdown when we already fetched all the values we were interested
    // for the current iteration.
    log.trace("Rejecting row {} because executor is closed", rows.get(rowIndex));
  }
}

代码示例来源:origin: palantir/atlasdb

private boolean internalCopyRow(RowResult<byte[]> rr,
                  long maxBytes,
                  Transaction writeT,
                  @Output MutableLong bytesPut,
                  @Output Mutable<byte[]> lastRowName) {
    Map<Cell, byte[]> values = rowTransform.apply(rr);
    writeT.put(destTable, values);

    for (Map.Entry<Cell, byte[]> e : values.entrySet()) {
      bytesPut.add(e.getValue().length + Cells.getApproxSizeOfCell(e.getKey()));
    }

    if (bytesPut.longValue() >= maxBytes) {
      lastRowName.set(rr.getRowName());
      return false;
    }
    return true;
  }
}

代码示例来源:origin: palantir/atlasdb

/**
 * This will add any local writes for this row to the result map.
 * <p>
 * If an empty value was written as a delete, this will also be included in the map.
 */
private void extractLocalWritesForRow(
    @Output ImmutableMap.Builder<Cell, byte[]> result,
    SortedMap<Cell, byte[]> writes,
    byte[] row,
    ColumnSelection columnSelection) {
  Cell lowCell = Cells.createSmallestCellForRow(row);
  Iterator<Entry<Cell, byte[]>> it = writes.tailMap(lowCell).entrySet().iterator();
  while (it.hasNext()) {
    Entry<Cell, byte[]> entry = it.next();
    Cell cell = entry.getKey();
    if (!Arrays.equals(row, cell.getRowName())) {
      break;
    }
    if (columnSelection.allColumnsSelected()
        || columnSelection.getSelectedColumns().contains(cell.getColumnName())) {
      result.put(cell, entry.getValue());
    }
  }
}

代码示例来源:origin: palantir/atlasdb

private void fillOverflowValues(ConnectionSupplier conns,
                TableReference tableRef,
                Map<Cell, OverflowValue> overflowValues,
                @Output Map<Cell, Value> values) {
  Iterator<Entry<Cell, OverflowValue>> overflowIterator = overflowValues.entrySet().iterator();
  while (overflowIterator.hasNext()) {
    Entry<Cell, OverflowValue> entry = overflowIterator.next();
    Value value = values.get(entry.getKey());
    if (value != null && value.getTimestamp() > entry.getValue().ts()) {
      overflowIterator.remove();
    }
  }
  Map<Long, byte[]> resolvedOverflowValues = overflowValueLoader.loadOverflowValues(
      conns,
      tableRef,
      Collections2.transform(overflowValues.values(), OverflowValue::id));
  for (Entry<Cell, OverflowValue> entry : overflowValues.entrySet()) {
    Cell cell = entry.getKey();
    OverflowValue ov = entry.getValue();
    byte[] val = resolvedOverflowValues.get(ov.id());
    Preconditions.checkNotNull(val, "Failed to load overflow data: cell=%s, overflowId=%s", cell, ov.id());
    values.put(cell, Value.create(val, ov.ts()));
  }
}

代码示例来源:origin: palantir/atlasdb

public static void copy(
    TransactionManager txManager,
    ExecutorService exec,
    Iterable<LockRefreshToken> lockTokens,
    final TableReference srcTable,
    final TableReference dstTable,
    int batchSize,
    int threadCount,
    @Output CopyStats stats) throws InterruptedException {
  copyExternal(exec, srcTable, dstTable, batchSize, threadCount, stats, (request, range) ->
      txManager.runTaskWithRetry(tx -> copyInternal(tx, srcTable, dstTable, request, range)));
}

代码示例来源:origin: palantir/atlasdb

private void computeNextStartPosition(byte[] lastColName,
                   @Output List<RowResult<Value>> results) {
  firstRowStartColumnInclusive = RangeRequests.getNextStartRowUnlessTerminal(reverse, lastColName);
  // We need to handle the edge case where the column was lexicographically last
  if (firstRowStartColumnInclusive == null) {
    flushCurrentRow(results);
    currentRowName = RangeRequests.getNextStartRowUnlessTerminal(reverse, currentRowName);
    firstRowStartColumnInclusive = PtBytes.EMPTY_BYTE_ARRAY;
    if (currentRowName == null) {
      endOfResults = true;
    }
  }
}

代码示例来源:origin: palantir/atlasdb

private <T> void getWithPostFiltering(TableReference tableRef,
                   Map<Cell, Value> rawResults,
                   @Output ImmutableMap.Builder<Cell, T> results,
                   Function<Value, T> transformer) {
  long bytes = 0;

代码示例来源:origin: palantir/atlasdb

private void adjustStreamStoreScores(TableReference valueTable,
    @Output Map<TableReference, Double> scores,
    Map<TableReference, SweepPriority> tableToSweepPriority) {
  TableReference indexTable = StreamTableType.getIndexTableFromValueTable(valueTable);
  if (!scores.containsKey(indexTable)) {
    // unlikely, but don't alter the score of something that hasn't been included as a candidate
    return;
  }
  long lastSweptTimeOfValueTable = getLastSweptTime(valueTable, tableToSweepPriority);
  long lastSweptTimeOfIndexTable = getLastSweptTime(indexTable, tableToSweepPriority);
  if (lastSweptTimeOfValueTable >= lastSweptTimeOfIndexTable) {
    // We want to sweep the value table but haven't yet done the index table.  Do the index table first.
    scores.put(indexTable, scores.get(valueTable));
    doNotSweepTable(valueTable, scores);
  } else if (System.currentTimeMillis() - lastSweptTimeOfIndexTable <= INDEX_TO_VALUE_TABLE_SLEEP_TIME) {
    // We've done the index table recently:
    // 1) wait a bit before we do the value table so that the unreadable timestamp has passed (wait > 1 hour).
    // 2) ensure we don't sweep index table again as we could starve the value table if index sweeps too often
    doNotSweepTable(valueTable, scores);
    doNotSweepTable(indexTable, scores);
  } else {
    // The index table has been swept long enough ago that we can now sweep the value table
  }
}

代码示例来源:origin: palantir/atlasdb

@SuppressWarnings({"CheckReturnValue"}) // Consume all remaining values of iterator.
private static <T> void collectValueForTimestamp(byte[] col,
                         Iterator<Entry<Key, byte[]>> timestampValues,
                         @Output ImmutableSortedMap.Builder<byte[], T> results,
                         RangeRequest range,
                         ResultProducer<T> resultProducer) {
  T result = null;
  if (range.containsColumn(col)) {
    result = resultProducer.apply(timestampValues);
  }
  // exhaust remaining entries
  Iterators.size(timestampValues);
  if (result != null) {
    results.put(col, result);
  }
}

相关文章

Output类方法