@Override // Since Options mandates checking hasXX() before XX() is called, the equals & hashCode look more // complicated than usual. public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Options that = (Options) o; return (!hasLimit() && !that.hasLimit() || hasLimit() && that.hasLimit() && Objects.equals(limit(), that.limit())) && (!hasPrefetchChunks() && !that.hasPrefetchChunks() || hasPrefetchChunks() && that.hasPrefetchChunks() && Objects.equals(prefetchChunks(), that.prefetchChunks())) && (!hasPageSize() && !that.hasPageSize() || hasPageSize() && that.hasPageSize() && Objects.equals(pageSize(), that.pageSize())) && Objects.equals(pageToken(), that.pageToken()) && Objects.equals(filter(), that.filter()); }
@Test public void allOptionsPresent() { Options options = Options.fromReadOptions(Options.limit(10), Options.prefetchChunks(1)); assertThat(options.hasLimit()).isTrue(); assertThat(options.limit()).isEqualTo(10); assertThat(options.hasPrefetchChunks()).isTrue(); assertThat(options.prefetchChunks()).isEqualTo(1); }
@Test public void allOptionsAbsent() { Options options = Options.fromReadOptions(); assertThat(options.hasLimit()).isFalse(); assertThat(options.hasPrefetchChunks()).isFalse(); assertThat(options.hasFilter()).isFalse(); assertThat(options.hasPageToken()).isFalse(); assertThat(options.toString()).isEqualTo(""); assertThat(options.equals(options)).isTrue(); assertThat(options.equals(null)).isFalse(); assertThat(options.equals(this)).isFalse(); assertThat(options.hashCode()).isEqualTo(31); }
Options readOptions = Options.fromReadOptions(option); Preconditions.checkArgument( !readOptions.hasLimit(), "Limit option not supported by partitionRead|partitionReadUsingIndex"); final PartitionReadRequest.Builder builder =
.setTable(checkNotNull(table)) .addAllColumns(columns); if (readOptions.hasLimit()) { builder.setLimit(readOptions.limit());
@Test public void readUsingIndexInstance() { Partition p = Partition.createReadPartition( partitionToken, partitionOptions, table, index, keys, columns, readOptions); assertThat(p.getPartitionToken()).isEqualTo(partitionToken); assertThat(p.getTable()).isEqualTo(table); assertThat(p.getIndex()).isEqualTo(index); assertThat(p.getKeys()).isEqualTo(keys); assertThat(p.getColumns()).isEqualTo(columns); assertTrue(p.getReadOptions().hasLimit()); assertThat(p.getReadOptions().limit()).isEqualTo(10); assertNull(p.getStatement()); assertNull(p.getQueryOptions()); // Test serialization. reserializeAndAssert(p); }
@Test public void readInstance() { Partition p = Partition.createReadPartition( partitionToken, partitionOptions, table, null /*index*/, keys, columns, readOptions); assertThat(p.getPartitionToken()).isEqualTo(partitionToken); assertThat(p.getTable()).isEqualTo(table); assertThat(p.getKeys()).isEqualTo(keys); assertThat(p.getColumns()).isEqualTo(columns); assertTrue(p.getReadOptions().hasLimit()); assertThat(p.getReadOptions().limit()).isEqualTo(10); assertNull(p.getIndex()); assertNull(p.getStatement()); assertNull(p.getQueryOptions()); // Test serialization. reserializeAndAssert(p); }
@Override // Since Options mandates checking hasXX() before XX() is called, the equals & hashCode look more // complicated than usual. public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Options that = (Options) o; return (!hasLimit() && !that.hasLimit() || hasLimit() && that.hasLimit() && Objects.equals(limit(), that.limit())) && (!hasPrefetchChunks() && !that.hasPrefetchChunks() || hasPrefetchChunks() && that.hasPrefetchChunks() && Objects.equals(prefetchChunks(), that.prefetchChunks())) && (!hasPageSize() && !that.hasPageSize() || hasPageSize() && that.hasPageSize() && Objects.equals(pageSize(), that.pageSize())) && Objects.equals(pageToken(), that.pageToken()) && Objects.equals(filter(), that.filter()); }
Options readOptions = Options.fromReadOptions(option); Preconditions.checkArgument( !readOptions.hasLimit(), "Limit option not supported by partitionRead|partitionReadUsingIndex"); final PartitionReadRequest.Builder builder =
.setTable(checkNotNull(table)) .addAllColumns(columns); if (readOptions.hasLimit()) { builder.setLimit(readOptions.limit());