Package me.prettyprint.hector.api.beans

Examples of me.prettyprint.hector.api.beans.DynamicComposite


  public ResultStatus execute() {
Mutator<String> mutator = HFactory.createMutator(keyspace, stringSerializer);
   
    HColumnImpl<DynamicComposite, String> column = new HColumnImpl<DynamicComposite, String>(dcs, stringSerializer);
    column.setClock(keyspace.createClock());       
    DynamicComposite dc = new DynamicComposite();
    dc.add(0, "Austin");
    dc.add(1, 7516L);
    dc.add(2, 225L);
    column.setName(dc);      
    column.setValue("TIME WARNER COMMUNICATIONS AXS OF AUSTIN, TX");
    mutator.addInsertion("TX:512", "StateNpaIndexDynamic", column);
   
    column = new HColumnImpl<DynamicComposite, String>(dcs, stringSerializer);
    column.setClock(keyspace.createClock());
    dc = new DynamicComposite();
    dc.add(0, "225");
    //dc.add(1, 7516L);   
    column.setName(dc);      
    column.setValue("TIME WARNER COMMUNICATIONS AXS OF AUSTIN, TX");
    mutator.addInsertion("TX:512", "StateNpaIndexDynamic", column);
   
    column = new HColumnImpl<DynamicComposite, String>(dcs, stringSerializer);
    column.setClock(keyspace.createClock());
    dc = new DynamicComposite();
    dc.add(0, "Austin");
    dc.add(1, 7516L);
    dc.add(2, 334L);
    column.setName(dc);      
    column.setValue("TIME WARNER COMMUNICATIONS AXS OF AUSTIN, TX");
    mutator.addInsertion("TX:512", "StateNpaIndexDynamic", column);
   
    column = new HColumnImpl<DynamicComposite, String>(dcs, stringSerializer);
    column.setClock(keyspace.createClock());
    dc = new DynamicComposite();
    dc.add(0, "334");
    dc.add(1, 7516L);
    column.setName(dc);      
    column.setValue("TIME WARNER COMMUNICATIONS AXS OF AUSTIN, TX");
    mutator.addInsertion("TX:512", "StateNpaIndexDynamic", column);
  
    column = new HColumnImpl<DynamicComposite, String>(dcs, stringSerializer);
    column.setClock(keyspace.createClock());
    dc = new DynamicComposite();  
    dc.add(0, "Austin");
    dc.add(1, 7516L);
    dc.add(2, 439L);
    column.setName(dc);      
    column.setValue("TIME WARNER COMMUNICATIONS AXS OF AUSTIN, TX");
    mutator.addInsertion("TX:512", "StateNpaIndexDynamic", column);
  
    column = new HColumnImpl<DynamicComposite, String>(dcs, stringSerializer);
    column.setClock(keyspace.createClock());
  
    dc = new DynamicComposite();
    dc.add(0, "Austin");
    dc.add(1, 5830L);
    dc.add(2, 215L);
    column.setName(dc);      
    column.setValue("TIME WARNER COMMUNICATIONS AXS OF AUSTIN, TX");
    mutator.addInsertion("TX:512", "StateNpaIndexDynamic", column);
   
    column = new HColumnImpl<DynamicComposite, String>(dcs, stringSerializer);
    column.setClock(keyspace.createClock());
    dc = new DynamicComposite();   
    dc.add(0, "Lockhart");
    dc.add(1, 9533L);
    dc.add(2, 227L);
    column.setName(dc);      
    column.setValue("SOUTHWESTERN BELL");
    mutator.addInsertion("TX:512", "StateNpaIndexDynamic", column);
       
    mutator.execute();
   
    SliceQuery<String, DynamicComposite, String> sliceQuery =
      HFactory.createSliceQuery(keyspace, stringSerializer, dcs, stringSerializer);
    sliceQuery.setColumnFamily("StateNpaIndexDynamic");
    sliceQuery.setKey("TX:512");

    DynamicComposite startRange = new DynamicComposite();
    //startRange.add(0, "225");
    startRange.add(0, "Austin");
    //startRange.addComponent(new Long(5830), LongSerializer.get(), "LongType", AbstractComposite.ComponentEquality.LESS_THAN_EQUAL);
    //startRange.add(1, 5830L);
   
   
    DynamicComposite endRange = new DynamicComposite();   
    //endRange.add(0, "225" + Character.MAX_VALUE);
    endRange.add(0, "Austin");
    endRange.addComponent(new Long(5830), LongSerializer.get(), "LongType", AbstractComposite.ComponentEquality.GREATER_THAN_EQUAL);
   
    sliceQuery.setRange(startRange, endRange, false, 10);

    QueryResult<ColumnSlice<DynamicComposite, String>> result = sliceQuery.execute();
    return result;
View Full Code Here


        assemblyStack.push(value);
    }

    @Override
    public void initializeFromColumn(byte[] columnValue, ClassResolver classResolver) {
        DynamicComposite dynamicComposite = DynamicCompositeSerializer.get().fromBytes(columnValue);
        this.value = dynamicComposite.get(0);
    }
View Full Code Here

        this.value = dynamicComposite.get(0);
    }

    @Override
    public ColumnValueDefinition<?> toColumnDefinition() {
        final DynamicComposite dynamicComposite = new DynamicComposite();
        dynamicComposite.addComponent(value, CassidyUtils.inferSerializer(value));
        return new ColumnValueDefinition<DynamicComposite>(dynamicComposite, DynamicCompositeSerializer.get());
    }
View Full Code Here

        final HColumn<DynamicComposite, K> indexColumn = HFactory.createColumn(indexColumnName, itemKey, DYNAMIC_COMPOSITE_SERIALIZER, keySerializer);
        indexMutator.addInsertion(indexName, indexColumnFamily, indexColumn);
    }

    private void insertEntryColumn(K itemKey, long timestamp, List<IndexValue<?>> indexValues, Mutator<DynamicComposite> entryMutator) {
        DynamicComposite entryValue = new DynamicComposite();
        IndexValue.addAll(indexValues, entryValue);
        final HColumn<Long, DynamicComposite> entryColumn = HFactory.createColumn(timestamp, entryValue, LONG_SERIALIZER, DYNAMIC_COMPOSITE_SERIALIZER);
        entryMutator.addInsertion(entryKey(itemKey), entryColumnFamily, entryColumn);
    }
View Full Code Here

// Other Methods
//----------------------------------------------------------------------------------------------------------------------

    @Override
    public List<K> find(Object... values) {
        DynamicComposite start = new DynamicComposite();
        DynamicComposite end = new DynamicComposite();
        for (int i = 0; i < values.length; i++) {
            Object value = values[i];
            start.addComponent(i, value, AbstractComposite.ComponentEquality.EQUAL);
            end.addComponent(i, value, i == values.length - 1 ? AbstractComposite.ComponentEquality.GREATER_THAN_EQUAL : AbstractComposite.ComponentEquality.EQUAL);
        }
        final SliceQuery<String, DynamicComposite, K> query = HFactory.createSliceQuery(keyspace, StringSerializer.get(), DynamicCompositeSerializer.get(), keySerializer);
        query.setKey(indexName);
        query.setColumnFamily(indexColumnFamily);
        query.setRange(start, end, false, Integer.MAX_VALUE);
View Full Code Here

        indexMutator.execute();
        entryMutator.execute();
    }

    private void performCleanup(K key, Mutator<String> indexMutator, Mutator<DynamicComposite> entryMutator) {
        final DynamicComposite entryKey = entryKey(key);
        final List<HColumn<Long, DynamicComposite>> entries = getEntries(entryKey);
        for (HColumn<Long, DynamicComposite> entry : entries) {
            final Long entryTimestamp = entry.getName();

            DynamicComposite indexColumnName = new DynamicComposite();
            appendComponents(entry.getValue(), indexColumnName);
            indexColumnName.addComponent(key, keySerializer);
            indexColumnName.addComponent(entryTimestamp, LONG_SERIALIZER);

            indexMutator.addDeletion(indexName, indexColumnFamily, indexColumnName, DYNAMIC_COMPOSITE_SERIALIZER);
            entryMutator.addDeletion(entryKey, entryColumnFamily, entryTimestamp, LONG_SERIALIZER);
        }
    }
View Full Code Here

            entryMutator.addDeletion(entryKey, entryColumnFamily, entryTimestamp, LONG_SERIALIZER);
        }
    }

    private DynamicComposite entryKey(K itemKey) {
        DynamicComposite entryKey = new DynamicComposite();
        entryKey.addComponent(itemKey, keySerializer);
        entryKey.addComponent(indexName, STRING_SERIALIZER);
        return entryKey;
    }
View Full Code Here

    private <T> void appendComponent(DynamicComposite composite, AbstractComposite.Component<T> component) {
        composite.addComponent(component.getValue(), component.getSerializer());
    }

    private void insertIndexColumn(K itemKey, long timestamp, List<IndexValue<?>> indexValues, Mutator<String> indexMutator) {
        DynamicComposite indexColumnName = new DynamicComposite();
        IndexValue.addAll(indexValues, indexColumnName);
        indexColumnName.addComponent(itemKey, keySerializer);
        indexColumnName.addComponent(timestamp, LONG_SERIALIZER);
        final HColumn<DynamicComposite, K> indexColumn = HFactory.createColumn(indexColumnName, itemKey, DYNAMIC_COMPOSITE_SERIALIZER, keySerializer);
        indexMutator.addInsertion(indexName, indexColumnFamily, indexColumn);
    }
View Full Code Here

    }

    @Override
    @SuppressWarnings("unchecked")
    public List<K> find(Object... values) {
        DynamicComposite start = new DynamicComposite();
        DynamicComposite end = new DynamicComposite();
        for (int i = 0; i < values.length; i++) {
            Object value = values[i];
            Serializer<Object> serializer;
            if (value == null) {
                value = NULL_VALUE;
                serializer = (Serializer<Object>) NULL_VALUE_SERIALIZER;
            } else {
                serializer = (Serializer<Object>) context.serializerRegistry().getSerializer(value.getClass());
            }
            final String comparator = serializer.getComparatorType().getTypeName();
            start.addComponent(value, serializer, comparator, AbstractComposite.ComponentEquality.EQUAL);
            end.addComponent(value, serializer, comparator, i == values.length - 1 ? AbstractComposite.ComponentEquality.GREATER_THAN_EQUAL : AbstractComposite.ComponentEquality.EQUAL);
        }
        LOGGER.debug("Searching for '{}' index columns with names between {} and {}...", indexName, start, end);
        final SliceQuery<String, DynamicComposite, K> query = HFactory.createSliceQuery(context.keyspaceHelper().keyspace(), StringSerializer.get(), DynamicCompositeSerializer.get(), keySerializer);
        query.setKey(indexName);
        query.setColumnFamily(indexColumnFamily);
View Full Code Here

        final HColumn<Long, DynamicComposite> entryColumn = HFactory.createColumn(timestamp, CassidyUtils.toComposite(context.serializerRegistry(), indexValues), LONG_SERIALIZER, DYNAMIC_COMPOSITE_SERIALIZER);
        entryMutator.addInsertion(entryKey(itemKey), entryColumnFamily, entryColumn);
    }

    private DynamicComposite entryKey(K itemKey) {
        DynamicComposite entryKey = new DynamicComposite();
        entryKey.addComponent(itemKey, keySerializer);
        entryKey.addComponent(indexName, STRING_SERIALIZER);
        return entryKey;
    }
View Full Code Here

TOP

Related Classes of me.prettyprint.hector.api.beans.DynamicComposite

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.