Пример #1
0
  public QueueIndexUpdate batchUpdateQueueIndex(
      QueueIndexUpdate indexUpdate, UUID subcriptionQueueId) throws Exception {

    logger.info("batchUpdateQueueIndex");

    Mutator<ByteBuffer> batch = indexUpdate.getBatch();

    // queue_id,prop_name
    Object index_key = key(subcriptionQueueId, indexUpdate.getEntryName());

    // subscription_queue_id,subscriber_queue_id,prop_name

    for (QueueIndexEntry entry : indexUpdate.getPrevEntries()) {

      if (entry.getValue() != null) {

        index_key = key(subcriptionQueueId, entry.getPath());

        batch.addDeletion(
            bytebuffer(index_key),
            PROPERTY_INDEX.getColumnFamily(),
            entry.getIndexComposite(),
            dce,
            indexUpdate.getTimestamp());
      } else {
        logger.error("Unexpected condition - deserialized property value is null");
      }
    }

    if (indexUpdate.getNewEntries().size() > 0) {

      for (QueueIndexEntry indexEntry : indexUpdate.getNewEntries()) {

        index_key = key(subcriptionQueueId, indexEntry.getPath());

        batch.addInsertion(
            bytebuffer(index_key),
            PROPERTY_INDEX.getColumnFamily(),
            createColumn(
                indexEntry.getIndexComposite(),
                ByteBuffer.allocate(0),
                indexUpdate.getTimestamp(),
                dce,
                be));
      }
    }

    for (String index : indexUpdate.getIndexesSet()) {
      batch.addInsertion(
          bytebuffer(key(subcriptionQueueId, DICTIONARY_SUBSCRIBER_INDEXES)),
          QUEUE_DICTIONARIES.getColumnFamily(),
          createColumn(index, ByteBuffer.allocate(0), indexUpdate.getTimestamp(), se, be));
    }

    return indexUpdate;
  }
Пример #2
0
  public QueueSet searchQueueIndex(UUID publisherQueueId, QuerySlice slice, int count)
      throws Exception {

    ByteBuffer start = null;
    if (slice.getCursor() != null) {
      start = slice.getCursor();
    } else if (slice.getStart() != null) {
      DynamicComposite s =
          new DynamicComposite(slice.getStart().getCode(), slice.getStart().getValue());
      if (!slice.getStart().isInclusive()) {
        setEqualityFlag(s, ComponentEquality.GREATER_THAN_EQUAL);
      }
      start = s.serialize();
    }

    ByteBuffer finish = null;
    if (slice.getFinish() != null) {
      DynamicComposite f =
          new DynamicComposite(slice.getFinish().getCode(), slice.getFinish().getValue());
      if (slice.getFinish().isInclusive()) {
        setEqualityFlag(f, ComponentEquality.GREATER_THAN_EQUAL);
      }
      finish = f.serialize();
    }

    if (slice.isReversed() && (start != null) && (finish != null)) {
      ByteBuffer temp = start;
      start = finish;
      finish = temp;
    }

    List<HColumn<ByteBuffer, ByteBuffer>> results =
        createSliceQuery(cass.getApplicationKeyspace(applicationId), be, be, be)
            .setColumnFamily(PROPERTY_INDEX.getColumnFamily())
            .setKey(bytebuffer(key(publisherQueueId, slice.getPropertyName())))
            .setRange(start, finish, slice.isReversed(), count)
            .execute()
            .get()
            .getColumns();

    QueueSet queues = new QueueSet();
    for (HColumn<ByteBuffer, ByteBuffer> column : results) {
      DynamicComposite c = DynamicComposite.fromByteBuffer(column.getName());
      queues.addQueue(c.get(3, se), c.get(2, ue));
    }
    return queues;
  }