@Test @SuppressWarnings("unchecked") public void toDirNameIdentityWithSlashes() { PartitionStrategy strategy = new PartitionStrategy.Builder() .identity("name") .identity("address") .build(); StorageKey key = new StorageKey(strategy); key.replaceValues((List) Lists.newArrayList("John Doe", "NY/USA")); Assert.assertEquals( new Path("name_copy=John+Doe/address_copy=NY%2FUSA"), convert.fromKey(key)); }
public Path fromKey(StorageKey key) { final StringBuilder pathBuilder = new StringBuilder(); final List<FieldPartitioner> partitioners = Accessor.getDefault().getFieldPartitioners(key.getPartitionStrategy()); for (int i = 0; i < partitioners.size(); i++) { final FieldPartitioner fp = partitioners.get(i); if (i != 0) { pathBuilder.append(Path.SEPARATOR_CHAR); } @SuppressWarnings("unchecked") String dirname = dirnameForValue(fp, key.get(i)); pathBuilder.append(dirname); } return new Path(pathBuilder.toString()); }
PathConversion { public Path fromKey(StorageKey key) { final StringBuilder pathBuilder = new StringBuilder(); final List<FieldPartitioner> partitioners = Accessor.getDefault().getFieldPartitioners(key.getPartitionStrategy()); for (int i = 0; i < partitioners.size(); i++) { final FieldPartitioner fp = partitioners.get(i); if (i != 0) { pathBuilder.append(Path.SEPARATOR_CHAR); } @SuppressWarnings("unchecked") String dirname = dirnameForValue(fp, key.get(i)); pathBuilder.append(dirname); } return new Path(pathBuilder.toString()); } }
PathConversion { public Path fromKey(StorageKey key) { final StringBuilder pathBuilder = new StringBuilder(); final List<FieldPartitioner> partitioners = Accessor.getDefault().getFieldPartitioners(key.getPartitionStrategy()); for (int i = 0; i < partitioners.size(); i++) { final FieldPartitioner fp = partitioners.get(i); if (i != 0) { pathBuilder.append(Path.SEPARATOR_CHAR); } @SuppressWarnings("unchecked") String dirname = dirnameForValue(fp, key.get(i)); pathBuilder.append(dirname); } return new Path(pathBuilder.toString()); } PathConversion(Schema schema); }
PathConversion { public Path fromKey(StorageKey key) { final StringBuilder pathBuilder = new StringBuilder(); final List<FieldPartitioner> partitioners = Accessor.getDefault().getFieldPartitioners(key.getPartitionStrategy()); for (int i = 0; i < partitioners.size(); i++) { final FieldPartitioner fp = partitioners.get(i); if (i != 0) { pathBuilder.append(Path.SEPARATOR_CHAR); } @SuppressWarnings("unchecked") String dirname = dirnameForValue(fp, key.get(i)); pathBuilder.append(dirname); } return new Path(pathBuilder.toString()); } PathConversion(Schema schema); StorageKey toKey(Path fromPath, StorageKey storage); Path fromKey(StorageKey key); T valueForDirname(FieldPartitioner<?, T> field, String name); static String dirnameForValue(FieldPartitioner<?, T> field, T value); static String valueToString(FieldPartitioner<?, T> field, T value); static T valueForDirname(FieldPartitioner<?, T> field, Schema schema, String name); static String dirnameToValueString(String name); }
PathConversion { public Path fromKey(StorageKey key) { final StringBuilder pathBuilder = new StringBuilder(); final List<FieldPartitioner> partitioners = Accessor.getDefault().getFieldPartitioners(key.getPartitionStrategy()); for (int i = 0; i < partitioners.size(); i++) { final FieldPartitioner fp = partitioners.get(i); if (i != 0) { pathBuilder.append(Path.SEPARATOR_CHAR); } @SuppressWarnings("unchecked") String dirname = dirnameForValue(fp, key.get(i)); pathBuilder.append(dirname); } return new Path(pathBuilder.toString()); } PathConversion(Schema schema); StorageKey toKey(Path fromPath, StorageKey storage); Path fromKey(StorageKey key); T valueForDirname(FieldPartitioner<?, T> field, String name); static String dirnameForValue(FieldPartitioner<?, T> field, T value); static String valueToString(FieldPartitioner<?, T> field, T value); static T valueForDirname(FieldPartitioner<?, T> field, Schema schema, String name); static String dirnameToValueString(String name);  }