Question: I've been reading up on SimpleDB and one downfall (for me) is the 1kb max per attribute limit. I do a lot of RSS feed processing and I was hoping to store feed data in SimpleDB (articles) and from what I've read the best way to do this is to shard the article across several attributes. The typical article is < 30kb of plain text.

I'm currently storing article data in DynamoDB (gzip compressed) without any issues, but the cost is fairly high. Was hoping to migrate to SimpleDB for cheaper storage with still fast retrievals. I do archive a json copy of all rss articles on S3 as well (many years of mysql headaches make me wary of db's).

Does anyone know to shard a string into < 1kb pieces? I'm assuming an identifier would need to be appended to each chunk for order of reassembly.

Any thoughts would be much appreciated!

Answer: 
Your code doesn't do what you think it does.

```
 ArrayList[][] gridList = new ArrayList[300][150];

```

This first line allocates an `array` of `array` of `ArrayList`. 

```
 ArrayList al = this.gridList[a][b];

```

This second line retrieves the `ArrayList` at offset `b` in the `array` at offset `a` in the `array` gridList. *You should be aware that your code doesn't initialize either arrays*.

The equivalent type in C++ could be:

```
#include <vector>
#include <array>

std::array< std::array< std::vector<T>, 150>, 300> gridList;

```

where `T` is the type of the element stored in the vectors. Note that Java prior to generics only allowed to define ArrayList without specifying the element type, which is pretty much what your code does. In C++, this parameter is mandatory. The above variable definition will instantiate it for the current scope. you will need to use a `new` statement for a dynamic value (as in Java), and probably wrap it with a smart pointer.

To access an element of the grid, you can use the `[]` operator:

```
 vector v = gridList[a][b];

```

Beware that this will trigger a full copy of the `vector` content in the grid at position < a,b > into `v`. As suggested, a more efficient way would be to write:

```
auto const &al = gridList[a][b];

```

Again, the memory model used by Java is very dynamic, so if you want code closer in behaviour to the Java version, you would probably have something like:

```
 #include<memory>

 typedef std::vector<int> i_vector;
 typedef std::shared_ptr<i_vector> i_vector_ptr;
 typedef std::array< std::array< i_vector_ptr>, 150>, 300> vector_grid;

 typedef std::shared_ptr<vector_grid> vector_grid_ptr;

 vector_grid_ptr gridList;

 i_vector_ptr al = (*gridList)[a][b];

```

with type `T` being `int`, and each component of the grid type clearly defined. You still have to allocate the grid and each element (ie. `i_vector` here).
If your ArrayList is holding something of type 'Foo', then:

```
std::vector<Foo*> gridList[300][150];
std::vector al = this->gridList[a][b];

```