here's what i ended up, this seems to work for me.

    @Test
    public void readAndWriteSettingTTL() throws Exception {
        int ttl = 2;
        String columnFamily = "Quote";
        Set<String> symbols = new HashSet<String>(){{
                                                add("appl");
                                                add("goog");
                                                add("ibm");
                                                add("csco");
                                            }};

        UUID timeUUID = TimeUUIDUtils.getUniqueTimeUUIDinMillis();

Mutator<String> mutator = HFactory.createMutator(_keyspace, _stringSerializer); for(String symbol : symbols) addInsertionToMutator(columnFamily, timeUUID, mutator, symbol, ttl);
        mutator.execute();

RangeSlicesQuery<String, UUID, String> rangeSlicesQuery = HFactory.createRangeSlicesQuery(_keyspace, _stringSerializer, _uuidSerializer, _stringSerializer);
        rangeSlicesQuery.setColumnFamily(columnFamily);
        rangeSlicesQuery.setKeys("", "");
        rangeSlicesQuery.setRange(null, null, false, 1);
QueryResult<OrderedRows<String, UUID, String>> result = rangeSlicesQuery.execute();

UUID uuid = result.get().getList().get(0).getColumnSlice().getColumns().get(0).getName();

        Assert.assertEquals("UUID should be the same", timeUUID, uuid);
Assert.assertEquals("We should have 4 records", 4, result.get().getList().size());

Thread.sleep(5000); // wait till TTL hits to make sure keys are getting flushed.

QueryResult<OrderedRows<String, UUID, String>> result2 = rangeSlicesQuery.execute();
        for(Row<String, UUID, String> row : result2.get().getList()) {
Assert.assertEquals("We should have no records", 0, row.getColumnSlice().getColumns().size());
        }

    }

private void addInsertionToMutator(String columnFamily, UUID columnName, Mutator<String> mutator, String symbol, int ttl) { mutator.addInsertion(symbol, columnFamily, HFactory.createColumn(columnName, "", ttl, _uuidSerializer, _stringSerializer));
    }


On 11/30/2011 1:56 PM, David McNelis wrote:
You wouldn't query for all the keys that have a column name x exactly. Instead what you would do is for sector x grab your list of symbols S. Then you would get the last column for each of those symbols (which you do in different ways depending on the API), and then test if that date is within your threshold. If not, it goes into your list of symbols to fetch.

Alternatively, you could iterate over the symbols grabbing data where the date is between range A and B, if you get an empty set / no columns returned, then you need to re-pull for that symbol. Does that make sense?

Either way you end up hitting on each of the individual symbols. Maybe someone else has a better idea of how to structure the data for that particular use case.

On Wed, Nov 30, 2011 at 3:45 PM, Deno Vichas <d...@syncopated.net <mailto:d...@syncopated.net>> wrote:

    with the quote CF below how would one query for all keys that have
    a column name value that have a timeuuid of later than x minutes?
     i need to be able to find all symbols that have not been fetch in
    x minutes by sector.  i know i get list of symbol by sector from
    my sector CF.

    thanks,
    deno


    On 11/30/2011 1:07 PM, David McNelis wrote:


        Then I would have a column family for quotes where I have the
        key as the symbol, the column name as the timestamp, the value
        as the quote:

        quote : {
           key: symbol
           column names:  timeuuid
           column values:  quote at that time for that symbol
        }






--
*David McNelis*
Lead Software Engineer
Agentis Energy
www.agentisenergy.com <http://www.agentisenergy.com>
c: 219.384.5143

/A Smart Grid technology company focused on helping consumers of energy control an often under-managed resource./



Reply via email to