예제 #1
0
 public CFRowAdder resetCollection(String cql3ColumnName) {
   ColumnDefinition def = getDefinition(cql3ColumnName);
   assert def.type.isCollection() && def.type.isMultiCell();
   Composite name = cf.getComparator().create(prefix, def);
   cf.addAtom(new RangeTombstone(name.start(), name.end(), timestamp - 1, ldt));
   return this;
 }
예제 #2
0
  public CFRowAdder(ColumnFamily cf, Composite prefix, long timestamp) {
    this.cf = cf;
    this.prefix = prefix;
    this.timestamp = timestamp;
    this.ldt = (int) (System.currentTimeMillis() / 1000);

    // If a CQL3 table, add the row marker
    if (cf.metadata().isCQL3Table() && !prefix.isStatic())
      cf.addColumn(
          new BufferCell(
              cf.getComparator().rowMarker(prefix), ByteBufferUtil.EMPTY_BYTE_BUFFER, timestamp));
  }
예제 #3
0
  public SliceQueryFilter withUpdatedStart(Composite newStart, CFMetaData cfm) {
    Comparator<Composite> cmp = reversed ? cfm.comparator.reverseComparator() : cfm.comparator;

    // Check our slices to see if any fall before the new start (in which case they can be removed)
    // or
    // if they contain the new start (in which case they should start from the page start).
    // However, if the
    // slices would include static columns, we need to ensure they are also fetched, and so a
    // separate
    // slice for the static columns may be required.
    // Note that if the query is reversed, we can't handle statics by simply adding a separate slice
    // here, so
    // the reversed case is handled by SliceFromReadCommand instead. See CASSANDRA-8502 for more
    // details.
    List<ColumnSlice> newSlices = new ArrayList<>();
    boolean pastNewStart = false;
    for (ColumnSlice slice : slices) {
      if (pastNewStart) {
        newSlices.add(slice);
        continue;
      }

      if (slice.isBefore(cmp, newStart)) {
        if (!reversed && sliceIncludesStatics(slice, cfm))
          newSlices.add(new ColumnSlice(Composites.EMPTY, cfm.comparator.staticPrefix().end()));

        continue;
      } else if (slice.includes(cmp, newStart)) {
        if (!reversed && sliceIncludesStatics(slice, cfm) && !newStart.isEmpty())
          newSlices.add(new ColumnSlice(Composites.EMPTY, cfm.comparator.staticPrefix().end()));

        newSlices.add(new ColumnSlice(newStart, slice.finish));
      } else {
        newSlices.add(slice);
      }

      pastNewStart = true;
    }
    return withUpdatedSlices(newSlices.toArray(new ColumnSlice[newSlices.size()]));
  }
 public boolean maySelectPrefix(CType type, Composite prefix) {
   for (CellName column : columns) {
     if (prefix.isPrefixOf(type, column)) return true;
   }
   return false;
 }