code: public synchronized Future<?> addIndexedColumn(ColumnDefinition cdef)
      {
          if (indexesByColumn.containsKey(cdef.name.bytes))
              return null;
  
          assert cdef.getIndexType() != null;
  
          SecondaryIndex index;
          try
          {
              index = SecondaryIndex.createInstance(baseCfs, cdef);
          }
          catch (ConfigurationException e)
          {
              throw new RuntimeException(e);
          }
  
          // Keep a single instance of the index per-cf for row level indexes
          // since we want all columns to be under the index
          if (index instanceof PerRowSecondaryIndex)
          {
              SecondaryIndex currentIndex = rowLevelIndexMap.get(index.getClass());
  
              if (currentIndex == null)
              {
                  rowLevelIndexMap.put(index.getClass(), index);
                  index.init();
              }
              else
              {
                  index = currentIndex;
                  index.addColumnDef(cdef);
                  logger.info("Creating new index : {}",cdef);
              }
          }
          else
          {
              // TODO: We sould do better than throw a RuntimeException
              if (cdef.getIndexType() == IndexType.CUSTOM && index instanceof AbstractSimplePerColumnSecondaryIndex)
                  throw new RuntimeException("Cannot use a subclass of AbstractSimplePerColumnSecondaryIndex as a CUSTOM index, as they assume they are CFS backed");
              index.init();
          }
  
          // link in indexedColumns. this means that writes will add new data to
          // the index immediately,
          // so we don't have to lock everything while we do the build. it's up to
          // the operator to wait
          // until the index is actually built before using in queries.
          indexesByColumn.put(cdef.name.bytes, index);
  
          // Add to all indexes set:
          allIndexes.add(index);
  
          // if we're just linking in the index to indexedColumns on an
          // already-built index post-restart, we're done
          if (index.isIndexBuilt(cdef.name.bytes))
              return null;
  
          return index.buildIndexAsync();
      }
docs: Adds and builds a index for a column
  @param cdef the column definition holding the index data
  @return a future which the caller can optionally block on signaling the index is built