com.palantir.atlasdb.transaction.api.Transaction.get()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(122)

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

Transaction.get介绍

[英]Creates a visitable that scans the provided range.
[中]

代码示例

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

@Override
public byte[] getCheckpoint(String extraId, long rangeId, Transaction tx) {
  Cell cell = getCell(extraId, rangeId);
  byte[] value = tx.get(checkpointTable, ImmutableSet.of(cell)).get(cell);
  return fromDb(value);
}

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

private String getCell(Transaction txn, TableReference tableRef, String rowName, String columnName) {
  Cell cell = createCell(rowName, columnName);
  Map<Cell, byte[]> map = txn.get(tableRef, ImmutableSet.of(cell));
  byte[] valueBytes = map.get(cell);
  return valueBytes != null ? PtBytes.toString(valueBytes) : null;
}

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

public Map<BlobsRow, byte[]> getDatas(Collection<BlobsRow> rows) {
  Map<Cell, BlobsRow> cells = Maps.newHashMapWithExpectedSize(rows.size());
  for (BlobsRow row : rows) {
    cells.put(Cell.create(row.persistToBytes(), PtBytes.toCachedBytes("d")), row);
  }
  Map<Cell, byte[]> results = t.get(tableRef, cells.keySet());
  Map<BlobsRow, byte[]> ret = Maps.newHashMapWithExpectedSize(results.size());
  for (Entry<Cell, byte[]> e : results.entrySet()) {
    byte[] val = Data.BYTES_HYDRATOR.hydrateFromBytes(e.getValue()).getValue();
    ret.put(cells.get(e.getKey()), val);
  }
  return ret;
}

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

@Override
public Map<Cell, byte[]> get(TableReference tableRef, Set<Cell> cells) {
  checkTableName(tableRef);
  return delegate().get(tableRef, cells);
}

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

private Map<Cell, byte[]> getCellsInner(ConsecutiveNarrowTable table) {
  final int getCellsSize = 1000;
  return table.getTransactionManager().runTaskThrowOnConflict(txn -> {
    Set<Cell> request = table.getCellsRequest(getCellsSize);
    Map<Cell, byte[]> result = txn.get(table.getTableRef(), request);
    Preconditions.checkState(result.size() == getCellsSize,
        "expected %s cells, found %s cells", getCellsSize, result.size());
    return result;
  });
}

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

private Map<Cell, byte[]> getSingleCellInner(ConsecutiveNarrowTable table) {
  return table.getTransactionManager().runTaskThrowOnConflict(txn -> {
    Set<Cell> request = table.getCellsRequest(1);
    Map<Cell, byte[]> result = txn.get(table.getTableRef(), request);
    byte[] rowName = Iterables.getOnlyElement(result.entrySet()).getKey().getRowName();
    int rowNumber = Ints.fromByteArray(rowName);
    int expectRowNumber = ConsecutiveNarrowTable.rowNumber(Iterables.getOnlyElement(request).getRowName());
    Preconditions.checkState(rowNumber == expectRowNumber,
        "Start Row %s, row number %s", expectRowNumber, rowNumber);
    return result;
  });
}

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

@Benchmark
@Threads(1)
@Warmup(time = 25, timeUnit = TimeUnit.SECONDS)
@Measurement(time = 180, timeUnit = TimeUnit.SECONDS)
public Object getAllColumnsExplicitly(ModeratelyWideRowTable table) {
  return table.getTransactionManager().runTaskThrowOnConflict(txn -> {
    Map<Cell, byte[]> result = txn.get(table.getTableRef(), table.getAllCells());
    Preconditions.checkState(result.values().size() == table.getNumCols(),
        "Should be %s columns, but were: %s", table.getNumCols(), result.values().size());
    return result;
  });
}

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

@Override
public TableCellVal getCells(TransactionToken token,
    final TableCell cells) {
  return runReadOnly(token, transaction -> {
    Map<Cell, byte[]> values = transaction.get(getTableRef(cells.getTableName()),
        ImmutableSet.copyOf(cells.getCells()));
    return new TableCellVal(cells.getTableName(), values);
  });
}

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

public Map<TestHashComponentsStreamValueRow, byte[]> getValues(Collection<TestHashComponentsStreamValueRow> rows) {
  Map<Cell, TestHashComponentsStreamValueRow> cells = Maps.newHashMapWithExpectedSize(rows.size());
  for (TestHashComponentsStreamValueRow row : rows) {
    cells.put(Cell.create(row.persistToBytes(), PtBytes.toCachedBytes("v")), row);
  }
  Map<Cell, byte[]> results = t.get(tableRef, cells.keySet());
  Map<TestHashComponentsStreamValueRow, byte[]> ret = Maps.newHashMapWithExpectedSize(results.size());
  for (Entry<Cell, byte[]> e : results.entrySet()) {
    byte[] val = Value.BYTES_HYDRATOR.hydrateFromBytes(e.getValue()).getValue();
    ret.put(cells.get(e.getKey()), val);
  }
  return ret;
}

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

public Map<TestHashComponentsStreamMetadataRow, com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata> getMetadatas(Collection<TestHashComponentsStreamMetadataRow> rows) {
  Map<Cell, TestHashComponentsStreamMetadataRow> cells = Maps.newHashMapWithExpectedSize(rows.size());
  for (TestHashComponentsStreamMetadataRow row : rows) {
    cells.put(Cell.create(row.persistToBytes(), PtBytes.toCachedBytes("md")), row);
  }
  Map<Cell, byte[]> results = t.get(tableRef, cells.keySet());
  Map<TestHashComponentsStreamMetadataRow, com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata> ret = Maps.newHashMapWithExpectedSize(results.size());
  for (Entry<Cell, byte[]> e : results.entrySet()) {
    com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata val = Metadata.BYTES_HYDRATOR.hydrateFromBytes(e.getValue()).getValue();
    ret.put(cells.get(e.getKey()), val);
  }
  return ret;
}

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

public Map<TwoColumnsRow, Long> getFoos(Collection<TwoColumnsRow> rows) {
  Map<Cell, TwoColumnsRow> cells = Maps.newHashMapWithExpectedSize(rows.size());
  for (TwoColumnsRow row : rows) {
    cells.put(Cell.create(row.persistToBytes(), PtBytes.toCachedBytes("f")), row);
  }
  Map<Cell, byte[]> results = t.get(tableRef, cells.keySet());
  Map<TwoColumnsRow, Long> ret = Maps.newHashMapWithExpectedSize(results.size());
  for (Entry<Cell, byte[]> e : results.entrySet()) {
    Long val = Foo.BYTES_HYDRATOR.hydrateFromBytes(e.getValue()).getValue();
    ret.put(cells.get(e.getKey()), val);
  }
  return ret;
}

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

public Map<StreamTestStreamMetadataRow, com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata> getMetadatas(Collection<StreamTestStreamMetadataRow> rows) {
  Map<Cell, StreamTestStreamMetadataRow> cells = Maps.newHashMapWithExpectedSize(rows.size());
  for (StreamTestStreamMetadataRow row : rows) {
    cells.put(Cell.create(row.persistToBytes(), PtBytes.toCachedBytes("md")), row);
  }
  Map<Cell, byte[]> results = t.get(tableRef, cells.keySet());
  Map<StreamTestStreamMetadataRow, com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata> ret = Maps.newHashMapWithExpectedSize(results.size());
  for (Entry<Cell, byte[]> e : results.entrySet()) {
    com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata val = Metadata.BYTES_HYDRATOR.hydrateFromBytes(e.getValue()).getValue();
    ret.put(cells.get(e.getKey()), val);
  }
  return ret;
}

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

public void deleteJson(Iterable<UserProfileRow> rows) {
  byte[] col = PtBytes.toCachedBytes("j");
  Set<Cell> cells = Cells.cellsWithConstantColumn(Persistables.persistAll(rows), col);
  Map<Cell, byte[]> results = t.get(tableRef, cells);
  deleteCookiesIdxRaw(results);
  t.delete(tableRef, cells);
}

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

public void deleteCreate(Iterable<UserProfileRow> rows) {
  byte[] col = PtBytes.toCachedBytes("c");
  Set<Cell> cells = Cells.cellsWithConstantColumn(Persistables.persistAll(rows), col);
  Map<Cell, byte[]> results = t.get(tableRef, cells);
  deleteCreatedIdxRaw(results);
  t.delete(tableRef, cells);
}

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

public void deleteMetadata(Iterable<UserProfileRow> rows) {
  byte[] col = PtBytes.toCachedBytes("m");
  Set<Cell> cells = Cells.cellsWithConstantColumn(Persistables.persistAll(rows), col);
  Map<Cell, byte[]> results = t.get(tableRef, cells);
  deleteUserBirthdaysIdxRaw(results);
  t.delete(tableRef, cells);
}

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

@Test
public void readTransactionSucceedsIfConditionSucceeds() {
  serializableTxManager.runTaskWithConditionReadOnly(PreCommitConditions.NO_OP,
      (tx, condition) -> tx.get(TABLE, ImmutableSet.of(TEST_CELL)));
  TransactionOutcomeMetricsAssert.assertThat(transactionOutcomeMetrics)
      .hasSuccessfulCommits(1);
}

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

@Test
public void testIgnoresOrphanedSweepSentinel() {
  Cell cell = Cell.create(PtBytes.toBytes("row1"), PtBytes.toBytes("column1"));
  keyValueService.addGarbageCollectionSentinelValues(TABLE, ImmutableSet.of(cell));
  Transaction txn = txManager.createNewTransaction();
  assertThat(txn.get(TABLE, ImmutableSet.of(cell)), is(ImmutableMap.of()));
}

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

@Test
public void readTransactionFailsIfConditionFails() {
  try {
    serializableTxManager.runTaskWithConditionReadOnly(ALWAYS_FAILS_CONDITION,
        (tx, condition) -> tx.get(TABLE, ImmutableSet.of(TEST_CELL)));
    fail();
  } catch (TransactionFailedRetriableException e) {
    assertThat(e.getMessage(), containsString("Condition failed"));
  }
  TransactionOutcomeMetricsAssert.assertThat(transactionOutcomeMetrics)
      .hasFailedCommits(1);
}

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

public void deleteFoo(Iterable<TwoColumnsRow> rows) {
  byte[] col = PtBytes.toCachedBytes("f");
  Set<Cell> cells = Cells.cellsWithConstantColumn(Persistables.persistAll(rows), col);
  Map<Cell, byte[]> results = t.get(tableRef, cells);
  deleteFooToIdCondIdxRaw(results);
  deleteFooToIdIdxRaw(results);
  t.delete(tableRef, cells);
}

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

public void deleteValue(Iterable<DataRow> rows) {
  byte[] col = PtBytes.toCachedBytes("v");
  Set<Cell> cells = Cells.cellsWithConstantColumn(Persistables.persistAll(rows), col);
  Map<Cell, byte[]> results = t.get(tableRef, cells);
  deleteIndex1IdxRaw(results);
  deleteIndex2IdxRaw(results);
  deleteIndex3IdxRaw(results);
  deleteIndex4IdxRaw(results);
  t.delete(tableRef, cells);
}

相关文章