builder.setRangePartitionColumns(new ArrayList<String>()); List<String> hashPartitionColumns = new ArrayList<>(); hashPartitionColumns.add(KEY);
private CreateTableOptions buildCreateTableOptions(Schema schema, Map<String, Object> properties) { CreateTableOptions options = new CreateTableOptions(); RangePartitionDefinition rangePartitionDefinition = null; PartitionDesign partitionDesign = KuduTableProperties.getPartitionDesign(properties); if (partitionDesign.getHash() != null) { for (HashPartitionDefinition partition : partitionDesign.getHash()) { options.addHashPartitions(partition.getColumns(), partition.getBuckets()); } } if (partitionDesign.getRange() != null) { rangePartitionDefinition = partitionDesign.getRange(); options.setRangePartitionColumns(rangePartitionDefinition.getColumns()); } List<RangePartition> rangePartitions = KuduTableProperties.getRangePartitions(properties); if (rangePartitionDefinition != null && !rangePartitions.isEmpty()) { for (RangePartition rangePartition : rangePartitions) { PartialRow lower = KuduTableProperties.toRangeBoundToPartialRow(schema, rangePartitionDefinition, rangePartition.getLower()); PartialRow upper = KuduTableProperties.toRangeBoundToPartialRow(schema, rangePartitionDefinition, rangePartition.getUpper()); options.addRangePartition(lower, upper); } } Optional<Integer> numReplicas = KuduTableProperties.getNumReplicas(properties); numReplicas.ifPresent(options::setNumReplicas); return options; }
builder.setRangePartitionColumns(Arrays.asList("key")); for (int i = 1; i < tablets; i++) { PartialRow splitRow = schema.newPartialRow();
builder.setRangePartitionColumns(rangeKeys); client.createTable(tableInfo.getTableName(), schema, builder); logger.debug("Table: " + tableInfo.getTableName() + " created successfully");
private static CreateTableOptions createTableOptions() { return new CreateTableOptions().setRangePartitionColumns(ImmutableList.of("key")); }
public static CreateTableOptions getAllTypesCreateTableOptions() { return new CreateTableOptions().setRangePartitionColumns(ImmutableList.of("int8")); }
public static CreateTableOptions getBasicCreateTableOptions() { return new CreateTableOptions().setRangePartitionColumns(ImmutableList.of("key")); }
@Test(timeout = 100000) public void testUnpartitionedTable() throws Exception { CreateTableOptions tableBuilder = new CreateTableOptions().setRangePartitionColumns(ImmutableList.<String>of()); testPartitionSchema(tableBuilder); }
/** * Builds the default CreateTableOptions for a schema. * * @param schema the schema * @return a default CreateTableOptions */ private CreateTableOptions defaultCreateTableOptions(Schema schema) { List<String> columnNames = new ArrayList<>(); for (ColumnSchema columnSchema : schema.getPrimaryKeyColumns()) { columnNames.add(columnSchema.getName()); } return new CreateTableOptions() .setRangePartitionColumns(columnNames); }
@Test(timeout = 100000) public void testHashBucketedTable() throws Exception { CreateTableOptions tableBuilder = new CreateTableOptions(); tableBuilder.addHashPartitions(ImmutableList.of("a"), 3); tableBuilder.addHashPartitions(ImmutableList.of("b", "c"), 3, 42); tableBuilder.setRangePartitionColumns(ImmutableList.<String>of()); testPartitionSchema(tableBuilder); }
@Before public void setUp() throws Exception { harness.getClient().createTable(TABLE_NAME, schema, new CreateTableOptions().setRangePartitionColumns(ImmutableList.of("key"))); }
@Before public void setUp() throws Exception { harness.getClient().createTable(TABLE_NAME, schema, new CreateTableOptions().setRangePartitionColumns(ImmutableList.of("key"))); }
@Before public void setUp() throws Exception { client = harness.getClient(); // Using multiple tablets doesn't work with the current way this test works since we could // jump from one TS to another which changes the logical clock. CreateTableOptions builder = new CreateTableOptions().setRangePartitionColumns(ImmutableList.of("key")); table = client.createTable(TABLE_NAME, schema, builder); }
@Before public void setUp() throws Exception { harness.getClient().createTable(TABLE_NAME, schema, new CreateTableOptions().setRangePartitionColumns(ImmutableList.of("key"))); }
@Before public void setUp() throws Exception { String runtimeProp = System.getProperty(RUNTIME_PROPERTY_NAME); runtimeInSeconds = runtimeProp == null ? DEFAULT_RUNTIME_SECONDS : Long.parseLong(runtimeProp); if (runtimeInSeconds < TEST_MIN_RUNTIME_SECONDS || runtimeInSeconds > TEST_TIMEOUT_SECONDS) { Assert.fail("This test needs to run more than " + TEST_MIN_RUNTIME_SECONDS + " seconds" + " and less than " + TEST_TIMEOUT_SECONDS + " seconds"); } LOG.info ("Test running for {} seconds", runtimeInSeconds); // Client we're using has low tolerance for read timeouts but a // higher overall operation timeout. localAsyncClient = new AsyncKuduClient.AsyncKuduClientBuilder(harness.getMasterAddressesAsString()) .defaultSocketReadTimeoutMs(500) .build(); localClient = new KuduClient(localAsyncClient); CreateTableOptions builder = new CreateTableOptions().setNumReplicas(3); builder.setRangePartitionColumns(ImmutableList.of("key")); table = localClient.createTable(TABLE_NAME, getBasicSchema(), builder); }
@Test(timeout = 100000) public void testHashBucketedAndRangePartitionedTable() throws Exception { Schema schema = createSchema(); CreateTableOptions tableBuilder = new CreateTableOptions(); tableBuilder.addHashPartitions(ImmutableList.of("a"), 3); tableBuilder.addHashPartitions(ImmutableList.of("b", "c"), 3, 42); tableBuilder.setRangePartitionColumns(ImmutableList.of("c", "b")); PartialRow split = schema.newPartialRow(); split.addString("c", "3"); tableBuilder.addSplitRow(split); split = schema.newPartialRow(); split.addString("c", "3"); split.addString("b", "3"); tableBuilder.addSplitRow(split); testPartitionSchema(tableBuilder); }
@Test(timeout = 100000) public void testNonDefaultRangePartitionedTable() throws Exception { Schema schema = createSchema(); CreateTableOptions tableBuilder = new CreateTableOptions(); tableBuilder.setRangePartitionColumns(ImmutableList.of("c", "b")); PartialRow split = schema.newPartialRow(); split.addString("c", "3"); tableBuilder.addSplitRow(split); split = schema.newPartialRow(); split.addString("c", "3"); split.addString("b", "3"); tableBuilder.addSplitRow(split); testPartitionSchema(tableBuilder); }
@Test(timeout = 100000) public void testSimplePartitionedTable() throws Exception { Schema schema = createSchema(); CreateTableOptions tableBuilder = new CreateTableOptions().setRangePartitionColumns(ImmutableList.of("a", "b", "c")); PartialRow split = schema.newPartialRow(); split.addString("c", "3"); tableBuilder.addSplitRow(split); split = schema.newPartialRow(); split.addString("c", "3"); split.addString("b", "3"); tableBuilder.addSplitRow(split); testPartitionSchema(tableBuilder); }
@Test public void testShortPredicates() throws Exception { Schema schema = createTableSchema(Type.INT16); client.createTable("short-table", schema, new CreateTableOptions().setRangePartitionColumns( ImmutableList.<String>of())); KuduTable table = client.openTable("short-table"); NavigableSet<Long> values = createIntegerValues(Type.INT16); KuduSession session = client.newSession(); session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH); long i = 0; for (long value : values) { Insert insert = table.newInsert(); insert.getRow().addLong("key", i++); insert.getRow().addShort("value", (short) value); session.apply(insert); } Insert nullInsert = table.newInsert(); nullInsert.getRow().addLong("key", i++); nullInsert.getRow().setNull("value"); session.apply(nullInsert); session.flush(); checkIntPredicates(table, values, createIntegerTestValues(Type.INT16)); }
@Test public void testLongPredicates() throws Exception { Schema schema = createTableSchema(Type.INT64); client.createTable("long-table", schema, new CreateTableOptions().setRangePartitionColumns( ImmutableList.<String>of())); KuduTable table = client.openTable("long-table"); NavigableSet<Long> values = createIntegerValues(Type.INT64); KuduSession session = client.newSession(); session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH); long i = 0; for (long value : values) { Insert insert = table.newInsert(); insert.getRow().addLong("key", i++); insert.getRow().addLong("value", value); session.apply(insert); } Insert nullInsert = table.newInsert(); nullInsert.getRow().addLong("key", i++); nullInsert.getRow().setNull("value"); session.apply(nullInsert); session.flush(); checkIntPredicates(table, values, createIntegerTestValues(Type.INT64)); }