Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-10092

Generalize PerRowSecondaryIndex validation

    XMLWordPrintableJSON

Details

    Description

      Index validation is currently done in a per-cell basis. However, per-row secondary index developers can be interested in validating all the written columns at once, because some implementations need to check the validity of a row write by comparing some column values against others. For example, a per row 2i implementation indexing time ranges (composed by a start date column and an end date column) should check that the start date is before the stop date.

      I'm attaching a patch adding a new method to PerRowSecondaryIndex:

      public void validate(ByteBuffer key, ColumnFamily cf) throws InvalidRequestException {}
      

      and a new method to SecondaryIndexManager:

      public void validateRowLevelIndexes(ByteBuffer key, ColumnFamily cf) throws InvalidRequestException
        {
            for (SecondaryIndex index : rowLevelIndexMap.values())
            {
                ((PerRowSecondaryIndex) index).validate(key, cf);
            }
        }
      

      This method is invoked in CQL UpdateStatement#validateIndexedColumns. This way, PerRowSecondaryIndex could perform complex write validation.

      I have tried to do the patch in the least invasive way possible. Maybe the current method SecondaryIndex#validate(ByteBuffer, Cell) should be moved to PerColumnSecondaryIndex, and the InvalidRequestException that informs about the particular 64k limitation should be thrown by AbstractSimplePerColumnSecondaryIndex. However, given the incoming CASSANDRA-9459, I think that the proposed patch is more than enough to provide rich validation features to 2i implementations based on 2.1.x and 2.2.x.

      Attachments

        1. CASSANDRA-10092_v2.patch
          9 kB
          Andres de la Peña
        2. CASSANDRA-10092_v3.patch
          14 kB
          Andres de la Peña
        3. improve_2i_validation.patch
          2 kB
          Andres de la Peña

        Activity

          People

            adelapena Andres de la Peña
            adelapena Andres de la Peña
            Andres de la Peña
            Sam Tunnicliffe
            Votes:
            9 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: