public Map<String, String> getInputArguments(Map<String, String> otherProperties) throws IOException, InterruptedException { Location lock = lock(); try { PartitionDetail partition = getLatestPartition(); if (partition == null) { throw new IllegalArgumentException("Snapshot fileset does not have a latest snapshot, so cannot be read."); } Map<String, String> args = new HashMap<>(); args.putAll(otherProperties); PartitionedFileSetArguments.addInputPartition(args, partition); return args; } finally { lock.delete(); } }
@Test public void testGetInputPartitionKeys() throws Exception { Map<String, String> arguments = new HashMap<>(); Assert.assertEquals(0, PartitionedFileSetArguments.getInputPartitionKeys(arguments).size()); List<? extends Partition> partitions = Lists.newArrayList(new BasicPartition(null, "path/doesn't/matter/1", generateUniqueKey()), new BasicPartition(null, "path/doesn't/matter/2", generateUniqueKey()), new BasicPartition(null, "path/doesn't/matter/3", generateUniqueKey())); for (Partition partition : partitions) { PartitionedFileSetArguments.addInputPartition(arguments, partition); } List<PartitionKey> inputPartitionKeys = Lists.transform(partitions, new Function<Partition, PartitionKey>() { @Nullable @Override public PartitionKey apply(Partition input) { return input.getPartitionKey(); } }); Assert.assertEquals(inputPartitionKeys, PartitionedFileSetArguments.getInputPartitionKeys(arguments)); arguments.clear(); PartitionedFileSetArguments.addInputPartitions(arguments, partitions.iterator()); Assert.assertEquals(inputPartitionKeys, PartitionedFileSetArguments.getInputPartitionKeys(arguments)); }