本文整理了Java中com.palantir.common.annotation.Output.<init>()
方法的一些代码示例,展示了Output.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Output.<init>()
方法的具体详情如下:
包路径:com.palantir.common.annotation.Output
类名称:Output
方法名:<init>
暂无
代码示例来源: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 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
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 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);
}
}
代码示例来源:origin: palantir/atlasdb
public static void diff(final TransactionManager txManager,
ExecutorService exec,
final TableReference plusTable,
final TableReference minusTable,
int batchSize,
int threadCount,
@Output DiffStats stats,
final DiffVisitor visitor) throws InterruptedException {
DiffStrategy diffStrategy = txManager.runTaskWithRetry(t ->
getDiffStrategy(t, plusTable, minusTable, batchSize));
diffExternal(diffStrategy, exec, plusTable, minusTable, batchSize, threadCount, stats,
(request, range, strategy) -> txManager.runTaskWithRetry(t ->
diffInternal(t, plusTable, minusTable, request, range, strategy, visitor)));
}
代码示例来源:origin: palantir/atlasdb
private byte[] internalCopyRange(BatchingVisitable<RowResult<byte[]>> bv,
final long maxBytes,
@Output final Map<Cell, byte[]> writeMap) {
final Mutable<byte[]> lastRowName = Mutables.newMutable(null);
final MutableLong bytesPut = new MutableLong(0L);
bv.batchAccept(readBatchSize, AbortingVisitors.batching(
// Replacing this with a lambda results in an unreported exception compile error
// even though no exception can be thrown :-(
new AbortingVisitor<RowResult<byte[]>, RuntimeException>() {
@Override
public boolean visit(RowResult<byte[]> rr) throws RuntimeException {
return KvsRangeMigrator.this.internalCopyRow(rr, maxBytes, writeMap, bytesPut, lastRowName);
}
}));
return lastRowName.get();
}
代码示例来源:origin: palantir/atlasdb
private void addNewRanges(
long lowerBoundForNewVersion,
T newValue,
RangeAndValue<T> latestRangeAndValue,
@Output ImmutableRangeMap.Builder<Long, T> builder) {
builder.put(Range.closedOpen(latestRangeAndValue.longRange().lowerEndpoint(), lowerBoundForNewVersion),
latestRangeAndValue.value());
builder.put(Range.atLeast(lowerBoundForNewVersion), newValue);
}
内容来源于网络,如有侵权,请联系作者删除!