@Test @SuppressWarnings("unchecked") public void toDirNameIdentityWithNonString() { PartitionStrategy strategy = new PartitionStrategy.Builder() .identity("id") .build(); StorageKey expected = new StorageKey(strategy); expected.replace(0, 0L); Assert.assertEquals("Should convert to schema type", expected, convert.toKey(new Path("id=0"), new StorageKey(strategy))); }
public StorageKey toKey(Path fromPath, StorageKey storage) { final List<FieldPartitioner> partitioners = Accessor.getDefault().getFieldPartitioners(storage.getPartitionStrategy()); final List<Object> values = Lists.newArrayList( new Object[partitioners.size()]); Path currentPath = fromPath; int index = partitioners.size() - 1; while (currentPath != null && index >= 0) { values.set(index, valueForDirname( (FieldPartitioner<?, ?>) partitioners.get(index), currentPath.getName())); currentPath = currentPath.getParent(); index -= 1; } storage.replaceValues(values); return storage; }
PathConversion { public StorageKey toKey(Path fromPath, StorageKey storage) { final List<FieldPartitioner> partitioners = Accessor.getDefault().getFieldPartitioners(storage.getPartitionStrategy()); final List<Object> values = Lists.newArrayList( new Object[partitioners.size()]); Path currentPath = fromPath; int index = partitioners.size() - 1; while (currentPath != null && index >= 0) { values.set(index, valueForDirname( (FieldPartitioner<?, ?>) partitioners.get(index), currentPath.getName())); currentPath = currentPath.getParent(); index -= 1; } storage.replaceValues(values); return storage; } }
PathConversion { public StorageKey toKey(Path fromPath, StorageKey storage) { final List<FieldPartitioner> partitioners = Accessor.getDefault().getFieldPartitioners(storage.getPartitionStrategy()); final List<Object> values = Lists.newArrayList( new Object[partitioners.size()]); Path currentPath = fromPath; int index = partitioners.size() - 1; while (currentPath != null && index >= 0) { values.set(index, valueForDirname( (FieldPartitioner<?, ?>) partitioners.get(index), currentPath.getName())); currentPath = currentPath.getParent(); index -= 1; } storage.replaceValues(values); return storage; } PathConversion(Schema schema); }
PathConversion { public StorageKey toKey(Path fromPath, StorageKey storage) { final List<FieldPartitioner> partitioners = Accessor.getDefault().getFieldPartitioners(storage.getPartitionStrategy()); final List<Object> values = Lists.newArrayList( new Object[partitioners.size()]); Path currentPath = fromPath; int index = partitioners.size() - 1; while (currentPath != null && index >= 0) { values.set(index, valueForDirname( (FieldPartitioner<?, ?>) partitioners.get(index), currentPath.getName())); currentPath = currentPath.getParent(); index -= 1; } storage.replaceValues(values); return storage; } 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 StorageKey toKey(Path fromPath, StorageKey storage) { final List<FieldPartitioner> partitioners = Accessor.getDefault().getFieldPartitioners(storage.getPartitionStrategy()); final List<Object> values = Lists.newArrayList( new Object[partitioners.size()]); Path currentPath = fromPath; int index = partitioners.size() - 1; while (currentPath != null && index >= 0) { values.set(index, valueForDirname( (FieldPartitioner<?, ?>) partitioners.get(index), currentPath.getName())); currentPath = currentPath.getParent(); index -= 1; } storage.replaceValues(values); return storage; } 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);  }