当前位置: 首页>>代码示例>>Java>>正文


Java KeyRange类代码示例

本文整理汇总了Java中com.google.cloud.spanner.KeyRange的典型用法代码示例。如果您正苦于以下问题:Java KeyRange类的具体用法?Java KeyRange怎么用?Java KeyRange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


KeyRange类属于com.google.cloud.spanner包,在下文中一共展示了KeyRange类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMutationSerialization

import com.google.cloud.spanner.KeyRange; //导入依赖的package包/类
@Test
public void testMutationSerialization() throws IOException, ClassNotFoundException, NoSuchMethodException,
		SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
{
	Mutation original = Mutation.newInsertBuilder("FOO").set("BAR").to("test").build();
	Mutation deserialized = serializeDeserialize(original);
	assertEquals(original, deserialized);

	original = Mutation.newUpdateBuilder("FOO").set("BAR").to("bla").build();
	deserialized = serializeDeserialize(original);
	assertEquals(original, deserialized);

	original = Mutation.delete("FOO", Key.of("bla"));
	deserialized = serializeDeserialize(original);
	assertEquals(original, deserialized);

	original = Mutation.delete("FOO", KeySet.all());
	deserialized = serializeDeserialize(original);
	assertEquals(original, deserialized);

	original = Mutation.delete("FOO", KeySet.range(KeyRange.closedClosed(Key.of("foo"), Key.of("bar"))));
	deserialized = serializeDeserialize(original);
	assertEquals(original, deserialized);
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:25,代码来源:XATransactionTest.java

示例2: testDeletes

import com.google.cloud.spanner.KeyRange; //导入依赖的package包/类
@Test
public void testDeletes() throws Exception {
  encodeAndVerify(g(Mutation.delete("test", Key.of(1L))));
  encodeAndVerify(g(Mutation.delete("test", Key.of((Long) null))));

  KeySet allTypes = KeySet.newBuilder()
      .addKey(Key.of(1L))
      .addKey(Key.of((Long) null))
      .addKey(Key.of(1.2))
      .addKey(Key.of((Double) null))
      .addKey(Key.of("one"))
      .addKey(Key.of((String) null))
      .addKey(Key.of(ByteArray.fromBase64("abcd")))
      .addKey(Key.of((ByteArray) null))
      .addKey(Key.of(Timestamp.now()))
      .addKey(Key.of((Timestamp) null))
      .addKey(Key.of(Date.fromYearMonthDay(2012, 1, 1)))
      .addKey(Key.of((Date) null))
      .build();

  encodeAndVerify(g(Mutation.delete("test", allTypes)));

  encodeAndVerify(
      g(Mutation
          .delete("test", KeySet.range(KeyRange.closedClosed(Key.of(1L), Key.of(2L))))));
}
 
开发者ID:apache,项目名称:beam,代码行数:27,代码来源:MutationGroupEncoderTest.java

示例3: sizeOf

import com.google.cloud.spanner.KeyRange; //导入依赖的package包/类
private static long sizeOf(KeySet keySet) {
  long result = 0;
  for (Key k : keySet.getKeys()) {
    result += sizeOf(k);
  }
  for (KeyRange kr : keySet.getRanges()) {
    result += sizeOf(kr);
  }
  return result;
}
 
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:MutationSizeEstimator.java

示例4: testAllTypesMultipleMutations

import com.google.cloud.spanner.KeyRange; //导入依赖的package包/类
@Test
public void testAllTypesMultipleMutations() throws Exception {
  encodeAndVerify(g(
      appendAllTypes(Mutation.newInsertOrUpdateBuilder("test")).build(),
      appendAllTypes(Mutation.newInsertBuilder("test")).build(),
      appendAllTypes(Mutation.newUpdateBuilder("test")).build(),
      appendAllTypes(Mutation.newReplaceBuilder("test")).build(),
      Mutation
          .delete("test", KeySet.range(KeyRange.closedClosed(Key.of(1L), Key.of(2L))))));
}
 
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:MutationGroupEncoderTest.java

示例5: noBatchingRangeDelete

import com.google.cloud.spanner.KeyRange; //导入依赖的package包/类
@Test
@Category(NeedsRunner.class)
public void noBatchingRangeDelete() throws Exception {
  Mutation all = Mutation.delete("test", KeySet.all());
  Mutation prefix = Mutation.delete("test", KeySet.prefixRange(Key.of(1L)));
  Mutation range = Mutation.delete("test", KeySet.range(KeyRange.openOpen(Key.of(1L), Key
      .newBuilder().build())));

  PCollection<MutationGroup> mutations = pipeline.apply(Create
      .of(
          g(m(1L)),
          g(m(2L)),
          g(del(5L, 6L)),
          g(delRange(50L, 55L)),
          g(delRange(11L, 20L)),
          g(all),
          g(prefix), g(range)
      )
  );
  mutations.apply(SpannerIO.write()
      .withProjectId("test-project")
      .withInstanceId("test-instance")
      .withDatabaseId("test-database")
      .withServiceFactory(serviceFactory)
      .withBatchSizeBytes(1000000000)
      .withSampler(fakeSampler(m(1000L)))
      .grouped());
  pipeline.run();

  verifyBatches(
      batch(m(1L), m(2L)),
      batch(del(5L, 6L)),
      batch(delRange(11L, 20L)),
      batch(delRange(50L, 55L)),
      batch(all),
      batch(prefix),
      batch(range)
  );
}
 
开发者ID:apache,项目名称:beam,代码行数:40,代码来源:SpannerIOWriteTest.java

示例6: delRange

import com.google.cloud.spanner.KeyRange; //导入依赖的package包/类
private static Mutation delRange(Long start, Long end) {
  return Mutation.delete("test", KeySet.range(KeyRange.closedClosed(Key.of(start), Key.of(end))));
}
 
开发者ID:apache,项目名称:beam,代码行数:4,代码来源:SpannerIOWriteTest.java


注:本文中的com.google.cloud.spanner.KeyRange类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。