Add a named index on given columns to improve performance.
352222
def sql_index(self,index_name,column_names,unique=True):
        """"""
        if type(column_names) == str:
            column_names = [column_names]
        try:
            if len(column_names) == 0:
                raise TypeError
        except TypeError:
            raise ValueError("Provide a list of column names for an index.")
        if unique:
            UNIQUE = "UNIQUE"
        else:
            UNIQUE = ""
        table_name = self.name
        columns = ",".join(column_names)
        SQL = """CREATE %(UNIQUE)s INDEX %(index_name)s ON %(table_name)s """\
            """(%(columns)s)""" % locals()
        self.sql(SQL)
401961
def has_index(self, columns):
        """"""
        if not self.exists:
            return False
        columns = set([normalize_column_name(c) for c in columns])
        if columns in self._indexes:
            return True
        for column in columns:
            if not self.has_column(column):
                return False
        indexes = self.db.inspect.get_indexes(self.name, schema=self.db.schema)
        for index in indexes:
            if columns == set(index.get('column_names', [])):
                self._indexes.append(columns)
                return True
        return False
972864
protected function addIndex($name, $type, $column)
    {
        if (isset($this->indexes[$name])) {
            $this->indexes[$name]['columns'][] = $column;
        }
        else {
            $this->indexes[$name] = [
                'name' => $name,
                'type' => $type,
                'columns' => [
                    $column
                ]
            ];
        }
    }
1113284
function columnIndexing(selector, colNames, dtypes) {
  if (isUndefined(selector) || selector === null) {
    return null;
  }

  // Handle boolean case if applicable
  var maxLen = colNames.size();
  var boolIdxResult = attemptBoolIndexing(selector, maxLen);
  if (!isUndefined(boolIdxResult)) {
    return boolIdxResult;
  }

  // Handle integer index / col name lookup hybrid
  var opts = resolverOpts(RESOLVE_MODE.COL, maxLen,
    colNames._getIndex(), dtypes);
  return resolveSelector(selector, opts);
}
810529
def add_index_operation(self, name, operations):
        
        if name not in self._index_operations:
            self._add_io(name, operations)
        else:
            raise AttributeError("An index operation with the name {} was already taken".format(name))
790394
def set_row(self, index, values):
        
        if self._sort:
            exists, i = sorted_exists(self._index, index)
            if not exists:
                self._insert_row(i, index)
        else:
            try:
                i = self._index.index(index)
            except ValueError:  # new row
                i = len(self._index)
                self._add_row(index)
        if isinstance(values, dict):
            if not (set(values.keys()).issubset(self._columns)):
                raise ValueError('keys of values are not all in existing columns')
            for c, column in enumerate(self._columns):
                self._data[c][i] = values.get(column, self._data[c][i])
        else:
            raise TypeError('cannot handle values of this type.')
509355
def _make_index(df, cols=META_IDX):
    """"""
    return pd.MultiIndex.from_tuples(
        pd.unique(list(zip(*[df[col] for col in cols]))), names=tuple(cols))
1371761
def build_index(self, idx_name, _type='default'):
        ""
        indexes = {}
        has_non_string_values = False
        for key, item in self.data.items():
            if idx_name in item:
                value = item[idx_name]
                # A non-string index value switches it into a lazy one.
                if not isinstance(value, six.string_types):
                    has_non_string_values = True
                if value not in indexes:
                    indexes[value] = set([])
                indexes[value].add(key)
        self.indexes[idx_name] = indexes
        if self._meta.lazy_indexes or has_non_string_values:
            # Every index is lazy
            _type = 'lazy'
        self.index_defs[idx_name] = {'type': _type}
1326668
def insert(self, index, p_object):
        
        key = self._get_object_key(p_object)
        if key in self._col_dict:
            raise KeyError()
        self._col_list.insert(index, p_object)
        self._col_dict[key] = p_object
415252
def create_column_index(annotations):
    
    _column_index = OrderedDict({'Column Name' : annotations['Column Name']})
    categorical_rows = annotation_rows('C:', annotations)
    _column_index.update(categorical_rows)
    numerical_rows = {name: [float(x) if x != '' else float('NaN') for x in values]
            for name, values in annotation_rows('N:', annotations).items()} # to floats
    _column_index.update(numerical_rows)
    column_index = pd.MultiIndex.from_tuples(list(zip(*_column_index.values())), names=list(_column_index.keys()))
    if len(column_index.names) == 1:
        # flatten single-level index
        name = column_index.names[0]
        column_index = column_index.get_level_values(name)
    return column_index
479108
def _add_column(self, column):
        
        self._columns.append(column)
        if self._blist:
            self._data.append(blist([None] * len(self._index)))
        else:
            self._data.append([None] * len(self._index))
1062709
def add (self, defn):
        """"""
        self[defn.name]          = defn
        self.colnames[defn.name] = defn
189735
public void addToIndexedColumnList(IndexInfo indexInfo)
    {
        ColumnInfo columnInfo = new ColumnInfo();
        columnInfo.setColumnName(indexInfo.getColumnName());
        if (getEmbeddedColumnMetadatas().isEmpty()
                || !getEmbeddedColumnMetadatas().get(0).getColumns().contains(columnInfo))
        {
            if (!columnToBeIndexed.contains(indexInfo))
            {
                columnToBeIndexed.add(indexInfo);
            }
        }
    }
172170
private void indexSparse(DBIDRef ref, SparseNumberVector obj) {
    double len = 0.;
    for(int iter = obj.iter(); obj.iterValid(iter); iter = obj.iterAdvance(iter)) {
      final int dim = obj.iterDim(iter);
      final double val = obj.iterDoubleValue(iter);
      if(val == 0. || val != val) {
        continue;
      }
      len += val * val;
      getOrCreateColumn(dim).add(val, ref);
    }
    length.put(ref, len);
  }
1355325
public void addRow(int rowIndex, Table sourceTable) {
        for (int i = 0; i < columnCount(); i++) {
            column(i).appendObj(sourceTable.column(i).get(rowIndex));
        }
    }
684203
def set_primary_key(self, columns, index_name=False):
        
        self._add_index(
            self._create_index(columns, index_name or "primary", True, True)
        )

        for column_name in columns:
            column = self.get_column(column_name)
            column.set_notnull(True)

        return self
1222544
def index_name(table, columns):
    """"""
    sig = '||'.join(columns)
    key = sha1(sig.encode('utf-8')).hexdigest()[:16]
    return 'ix_%s_%s' % (table, key)