return new StorageDescriptorKey(tablePath, input.getSd()); return new StorageDescriptorKey(input.getSd()); }); boolean isUnsetKey = key.equals(StorageDescriptorKey.UNSET_KEY);
.addValue("val1") .build(null); assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", p1.getSd()), IsNot.not(new MetaStoreServerUtils.StorageDescriptorKey("a", p2.getSd()))); assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", p1.getSd()), is(new MetaStoreServerUtils.StorageDescriptorKey("a", p3.getSd())));
.setInputFormat("foo") .build(null); assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", p1.getSd()), IsNot.not(new MetaStoreServerUtils.StorageDescriptorKey("a", p2.getSd()))); assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", p1.getSd()), is(new MetaStoreServerUtils.StorageDescriptorKey("a", p3.getSd())));
.addValue("val1") .build(null); assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", p1.getSd()), IsNot.not(new MetaStoreServerUtils.StorageDescriptorKey("a", p2.getSd()))); assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", p1.getSd()), is(new MetaStoreServerUtils.StorageDescriptorKey("a", p3.getSd())));
/** * Two StorageDescriptorKey objects with the same base location but different * SD location should be equal */ @Test public void testCompareWithSdSamePrefixDifferentLocation() throws MetaException { Partition p1 = new PartitionBuilder() .setDbName("DB_NAME") .setTableName(TABLE_NAME) .setLocation("l1") .addCol("a", "int") .addValue("val1") .build(null); Partition p2 = new PartitionBuilder() .setDbName("DB_NAME") .setTableName(TABLE_NAME) .setLocation("l2") .addCol("a", "int") .addValue("val1") .build(null); assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", p1.getSd()), is(new MetaStoreServerUtils.StorageDescriptorKey("a", p2.getSd()))); }
/** * Convert list of partitions to a PartitionSpec object. */ private static PartitionSpec getSharedSDPartSpec(Table table, StorageDescriptorKey sdKey, List<PartitionWithoutSD> partitions) { StorageDescriptor sd; if (sdKey.getSd() == null) { //sd is not requested set it empty StorageDescriptor in the PartitionSpec sd = new StorageDescriptor(); } else { sd = new StorageDescriptor(sdKey.getSd()); sd.setLocation(sdKey.baseLocation); // Use table-dir as root-dir. } PartitionSpecWithSharedSD sharedSDPartSpec = new PartitionSpecWithSharedSD(); sharedSDPartSpec.setPartitions(partitions); sharedSDPartSpec.setSd(sd); PartitionSpec ret = new PartitionSpec(); ret.setRootPath(sd.getLocation()); ret.setSharedSDPartitionSpec(sharedSDPartSpec); ret.setDbName(table.getDbName()); ret.setTableName(table.getTableName()); return ret; }
/** * Two empty StorageDescriptorKey should be equal. */ @Test public void testCompareNullSdKey() { assertThat(MetaStoreServerUtils.StorageDescriptorKey.UNSET_KEY, is(new MetaStoreServerUtils.StorageDescriptorKey())); }
/** * Two StorageDescriptorKey objects with null storage descriptors should be * equal iff the base location is equal. */ @Test public void testCompareNullSd() { assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", null), is(new MetaStoreServerUtils.StorageDescriptorKey("a", null))); // Different locations produce different objects assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", null), IsNot.not(equalTo(new MetaStoreServerUtils.StorageDescriptorKey("b", null)))); }