@Test(groups = {"unit"}) public void shouldWriteToPath() throws Exception { TestPojo testObject = new TestPojo("v1", 42L, true, Arrays.asList("e1", "e2")); dao.writeToPath(rowKey, path, testObject); Map<String,Object> stringObjectMap = getExpectedMap(true); verify(operations).writeColumns(rowKey, stringObjectMap); }
@Override public void writeToPath(K rowKey, Path path, Object value, @Nullable BatchContext batchContext) { validateArgs(rowKey, path); Object structure = writeMapper.convertValue(value, Object.class); Map<Path,Object> pathMap = Collections.singletonMap(path, structure); Map<Path,Object> objectMap = Decomposer.get().decompose(pathMap); Map<String,Object> stringMap = new HashMap<String,Object>(); for (Map.Entry<Path,Object> entry : objectMap.entrySet()) { stringMap.put(entry.getKey().toString(), entry.getValue()); } if (batchContext == null) { operations.writeColumns(rowKey, stringMap); } else { operations.writeColumns(rowKey, stringMap, batchContext); } }
ThriftStructuredDataSupport extends AbstractThriftStructuredDataSupport<K> { @Override public void writeToPath(K rowKey, Path path, Object value, @Nullable BatchContext batchContext) { validateArgs(rowKey, path); Object structure = writeMapper.convertValue(value, Object.class); Map<Path,Object> pathMap = Collections.singletonMap(path, structure); Map<Path,Object> objectMap = Decomposer.get().decompose(pathMap); Map<String,Object> stringMap = new HashMap<String,Object>(); for (Map.Entry<Path,Object> entry : objectMap.entrySet()) { stringMap.put(entry.getKey().toString(), entry.getValue()); } if (batchContext == null) { operations.writeColumns(rowKey, stringMap); } else { operations.writeColumns(rowKey, stringMap, batchContext); } } }
ThriftStructuredDataSupport extends AbstractThriftStructuredDataSupport<K> { @Override public void writeToPath(K rowKey, Path path, Object value, @Nullable BatchContext batchContext) { validateArgs(rowKey, path); Object structure = writeMapper.convertValue(value, Object.class); Map<Path,Object> pathMap = Collections.singletonMap(path, structure); Map<Path,Object> objectMap = Decomposer.get().decompose(pathMap); Map<String,Object> stringMap = new HashMap<String,Object>(); for (Map.Entry<Path,Object> entry : objectMap.entrySet()) { stringMap.put(entry.getKey().toString(), entry.getValue()); } if (batchContext == null) { operations.writeColumns(rowKey, stringMap); } else { operations.writeColumns(rowKey, stringMap, batchContext); } } ThriftStructuredDataSupport(ColumnFamilyOperations<K,String,Object> operations); }
ThriftStructuredDataSupport extends AbstractThriftStructuredDataSupport<K> { @Override public void writeToPath(K rowKey, Path path, Object value, @Nullable BatchContext batchContext) { validateArgs(rowKey, path); Object structure = writeMapper.convertValue(value, Object.class); Map<Path,Object> pathMap = Collections.singletonMap(path, structure); Map<Path,Object> objectMap = Decomposer.get().decompose(pathMap); Map<String,Object> stringMap = new HashMap<String,Object>(); for (Map.Entry<Path,Object> entry : objectMap.entrySet()) { stringMap.put(entry.getKey().toString(), entry.getValue()); } if (batchContext == null) { operations.writeColumns(rowKey, stringMap); } else { operations.writeColumns(rowKey, stringMap, batchContext); } } ThriftStructuredDataSupport(ColumnFamilyOperations<K,String,Object> operations); @Override BatchContext beginBatch(); @Override void applyBatch(BatchContext batchContext); @Override T readFromPath(K rowKey, Path path, TypeReference<T> type); @Override void writeToPath(K rowKey,
                            Path path,
                            Object value,
                            @Nullable BatchContext batchContext); @Override void deletePath(K rowKey, Path path, @Nullable BatchContext batchContext); }
ThriftStructuredDataSupport extends AbstractThriftStructuredDataSupport<K> { @Override public void writeToPath(K rowKey, Path path, Object value, @Nullable BatchContext batchContext) { validateArgs(rowKey, path); Object structure = writeMapper.convertValue(value, Object.class); Map<Path,Object> pathMap = Collections.singletonMap(path, structure); Map<Path,Object> objectMap = Decomposer.get().decompose(pathMap); Map<String,Object> stringMap = new HashMap<String,Object>(); for (Map.Entry<Path,Object> entry : objectMap.entrySet()) { stringMap.put(entry.getKey().toString(), entry.getValue()); } if (batchContext == null) { operations.writeColumns(rowKey, stringMap); } else { operations.writeColumns(rowKey, stringMap, batchContext); } } ThriftStructuredDataSupport(ColumnFamilyOperations<K,String,Object> operations); @Override BatchContext beginBatch(); @Override void applyBatch(BatchContext batchContext); @Override T readFromPath(K rowKey, Path path, TypeReference<T> type); @Override void writeToPath(K rowKey,
                            Path path,
                            Object value,
                            @Nullable BatchContext batchContext); @Override void deletePath(K rowKey, Path path, @Nullable BatchContext batchContext);  }