Internal CREATE INDEX query that will create the index only if the relation does not exists already
@param self
@param ObjType
@param type
@param field
@param typefield
@param is_unique
@return {Promise.<TResult>}
486157
function pg_declare_index(self, ObjType, type, field, typefield, is_unique) {
	var colname = _parse_predicate_key(ObjType, {'epoch':false}, field);
	var datakey = colname.getMeta('datakey');
	var field_name = (datakey ? datakey + '.' : '' ) + colname.getMeta('key');
	var name = pg_create_index_name(self, ObjType, type, field, typefield, is_unique);
	return pg_relation_exists(self, name).then(function(exists) {
		if(!exists) {
			return pg_create_index(self, ObjType, type, field, typefield, is_unique);
		}

		return pg_get_indexdef(self, name).then(function(old_indexdef) {
			var new_indexdef_v1 = pg_create_index_query_v1(self, ObjType, type, field, typefield, is_unique);
			var new_indexdef_v2 = pg_create_index_query_v2(self, ObjType, type, field, typefield, is_unique);

			if (new_indexdef_v1 === old_indexdef) return self;
			if (new_indexdef_v2 === old_indexdef) return self;

			if (NoPg.debug) {
				debug.info('Rebuilding index...');
				debug.log('old index is: ', old_indexdef);
				debug.log('new index is: ', new_indexdef_v1);
			}

			return pg_drop_index(self, ObjType, type, field, typefield).then(function() {
				return pg_create_index(self, ObjType, type, field, typefield, is_unique);
			});
		});
	});
}
568545
private JsonObject newIndex(JsonSimple response, String oid) {
		JsonObject order = createNewOrder(response,
				TransactionManagerQueueConsumer.OrderType.INDEXER.toString());
		order.put("oid", oid);
		return order;
	}
1350786
def _set_index(self, schema, name, fields, **index_options):
        
        query_str = "CREATE {}INDEX IF NOT EXISTS '{}_{}' ON {} ({})".format(
            'UNIQUE ' if index_options.get('unique', False) else '',
            schema,
            name,
            self._normalize_table_name(schema),
            ', '.join((self._normalize_name(f) for f in fields))
        )

        return self._query(query_str, ignore_result=True, **index_options)
30626
public synchronized static Index createIndex(Class<?> type) {
        Index index = indices.get(type);
        if (index == null) {
            try {
                Indexer indexer = new Indexer();
                Class<?> currentType = type;
                while ( currentType != null ) {
                    String className = currentType.getName().replace(".", "/") + ".class";
                    InputStream stream = type.getClassLoader()
                            .getResourceAsStream(className);
                    indexer.index(stream);
                    currentType = currentType.getSuperclass();
                }
                index = indexer.complete();
                indices.put(type, index);
            } catch (IOException e) {
                throw new RuntimeException("Failed to initialize Indexer", e);
            }
        }
        return index;
    }
235835
@GET
    @Path("/uniqueAttribute/type/{typeName}")
    @Consumes(Servlets.JSON_MEDIA_TYPE)
    @Produces(Servlets.JSON_MEDIA_TYPE)
    public AtlasEntityWithExtInfo getByUniqueAttributes(@PathParam("typeName") String typeName,
                                                        @Context HttpServletRequest servletRequest) throws AtlasBaseException {
        AtlasPerfTracer perf = null;

        try {
            Map<String, Object> attributes = getAttributes(servletRequest);

            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getByUniqueAttributes(" + typeName + "," + attributes + ")");
            }

            AtlasEntityType entityType = ensureEntityType(typeName);

            validateUniqueAttribute(entityType, attributes);

            return entitiesStore.getByUniqueAttributes(entityType, attributes);
        } finally {
            AtlasPerfTracer.log(perf);
        }
    }
16655
public StorableIndex<S> unique(boolean unique) {
        if (unique == mUnique) {
            return this;
        }
        return new StorableIndex<S>(mProperties, mDirections, unique, mClustered, false);
    }
1249523
function pg_create_index_query_v2 (self, ObjType, type, field, typefield, is_unique) {
	var colname = _parse_predicate_key(ObjType, {'epoch':false}, field);
	var query = pg_create_index_query_internal_v2(self, ObjType, type, field, typefield, is_unique);
	var params = colname.getParams();
	if(params.length !== 0) {
		throw new TypeError("pg_create_index_query_v2() does not support params!");
	}
	return query;
}
372145
public boolean createOrUpdateData(String indexName, String type, String id, Object obj) {
        IndexResponse response = getClient().prepareIndex(indexName, type).setId(id).setSource(Lang.obj2map(obj)).execute().actionGet();
        return response.getResult() == DocWriteResponse.Result.CREATED || response.getResult() == DocWriteResponse.Result.UPDATED;
    }
597338
StatementSchema compileCreateIndex(boolean unique, boolean assumeUnique, boolean migrating) {
    /* disable 1 line ...
    StatementSchema compileCreateIndex(boolean unique) {
    ... disabled 1 line */
    // End of VoltDB extension

        Table    table;
        HsqlName indexHsqlName;

        read();

        indexHsqlName = readNewSchemaObjectName(SchemaObject.INDEX);

        readThis(Tokens.ON);

        table = readTableName();

        HsqlName tableSchema = table.getSchemaName();

        indexHsqlName.setSchemaIfNull(tableSchema);

        indexHsqlName.parent = table.getName();

        if (indexHsqlName.schema != tableSchema) {
            throw Error.error(ErrorCode.X_42505);
        }

        indexHsqlName.schema = table.getSchemaName();

        // 
        java.util.List<Boolean> ascDesc = new java.util.ArrayList<Boolean>();
        // A VoltDB extension to "readColumnList(table, true)" to support indexed expressions.
        java.util.List<Expression> indexExprs = XreadExpressions(ascDesc, migrating);
        OrderedHashSet set = getSimpleColumnNames(indexExprs);
        int[] indexColumns = null;
        if (set == null) {
            // A VoltDB extension to support indexed expressions.
            // Not just indexing columns.
            // The meaning of set and indexColumns shifts here to be
            // the set of unique base columns for the indexed expressions.
            set = getBaseColumnNames(indexExprs);
        } else {
            // Just indexing columns -- by-pass extended support for generalized index expressions.
            indexExprs = null;
        }

        // A VoltDB extension to support partial index
        Expression predicate = null;
        if (readIfThis(Tokens.WHERE)) {
            predicate = XreadBooleanValueExpression();
        }

        indexColumns = getColumnList(set, table);
        String   sql          = getLastPart();
        Object[] args         = new Object[] {
            table, indexColumns, indexHsqlName, unique, migrating, indexExprs, assumeUnique, predicate
        /* disable 4 lines ...
        int[]    indexColumns = readColumnList(table, true);
        String   sql          = getLastPart();
        Object[] args         = new Object[] {
            table, indexColumns, indexHsqlName, Boolean.valueOf(unique)
        ... disabled 4 lines */
        // End of VoltDB extension
        };

        return new StatementSchema(sql, StatementTypes.CREATE_INDEX, args,
                                   null, table.getName());
    }
1369514
private Mapper createMapper(Field field, boolean indexed) {
    lock.lock();
    try {
      Mapper mapper;
      Class<?> fieldType = field.getType();
      Type genericType = field.getGenericType();
      String cacheKey = computeCacheKey(genericType, indexed);
      mapper = cache.get(cacheKey);
      if (mapper != null) {
        return mapper;
      }
      if (List.class.isAssignableFrom(fieldType)) {
        mapper = new ListMapper(genericType, indexed);
      } else if (Set.class.isAssignableFrom(fieldType)) {
        mapper = new SetMapper(genericType, indexed);
      } else {
        // we shouldn't be getting here
        throw new IllegalArgumentException(
            String.format("Field type must be List or Set, found %s", fieldType));
      }
      cache.put(cacheKey, mapper);
      return mapper;
    } finally {
      lock.unlock();
    }
  }
1087585
function _createIndex(indexName, indexData, value, ex, cb) {
    var callback = cb;
    var expiry = ex;
    if(!callback) {
      expiry = null;
      callback = ex;
    }

    // generate the index value
    var index = indexName + '-' +
      crypto.createHash('sha256').update(indexData).digest('hex');

    client.set(index, value, function(err, reply) {
      if(err) {
        return callback(err);
      }
      if(expiry) {
        return client.expire(index, expiry, function(err) {
          callback(err, reply);
        });
      }
      callback(err, reply);
    });
  }
390821
public Object getRepeatedField(final FieldDescriptorType descriptor,
                                 final int index) {
    if (!descriptor.isRepeated()) {
      throw new IllegalArgumentException(
        "getRepeatedField() can only be called on repeated fields.");
    }

    final Object value = getField(descriptor);

    if (value == null) {
      throw new IndexOutOfBoundsException();
    } else {
      return ((List<?>) value).get(index);
    }
  }
892793
public ActionFuture<IndexResponse> sendDataAsyncWithObjectMapper(
            Object sourceObject, String index, String type, String id) {
        return indexQueryAsync(buildIndexRequest(
                JMElasticsearchUtil.buildSourceByJsonMapper(sourceObject),
                index, type, id));
    }
614212
public Index mapper(String field, Mapper mapper) {
        schema.mapper(field, mapper);
        return this;
    }
84059
public final Index createIndex(PersistentStore store, HsqlName name,
                                   int[] columns, boolean[] descending,
                                   boolean[] nullsLast, boolean unique, boolean migrating,
                                   boolean constraint, boolean forward) {

        Index newIndex = createAndAddIndexStructure(name, columns, descending,
            nullsLast, unique, migrating, constraint, forward);

        return newIndex;
    }
1026149
private static IndexOptions prepareOptions(MongoDBIndexType indexType, Document options, String indexName, boolean unique) {
		IndexOptions indexOptions = new IndexOptions();
		indexOptions.name( indexName ).unique( unique ).background( options.getBoolean( "background" , false ) );

		if ( unique ) {
			// MongoDB only allows one null value per unique index which is not in line with what we usually consider
			// as the definition of a unique constraint. Thus, we mark the index as sparse to only index values
			// defined and avoid this issue. We do this only if a partialFilterExpression has not been defined
			// as partialFilterExpression and sparse are exclusive.
			indexOptions.sparse( !options.containsKey( "partialFilterExpression" ) );
		}
		else if ( options.containsKey( "partialFilterExpression" ) ) {
			indexOptions.partialFilterExpression( (Bson) options.get( "partialFilterExpression" ) );
		}
		if ( options.containsKey( "expireAfterSeconds" ) ) {
			//@todo is it correct?
			indexOptions.expireAfter( options.getInteger( "expireAfterSeconds" ).longValue() , TimeUnit.SECONDS );

		}

		if ( MongoDBIndexType.TEXT.equals( indexType ) ) {
			// text is an option we take into account to mark an index as a full text index as we cannot put "text" as
			// the order like MongoDB as ORM explicitly checks that the order is either asc or desc.
			// we remove the option from the Document so that we don't pass it to MongoDB
			if ( options.containsKey( "default_language" ) ) {
				indexOptions.defaultLanguage( options.getString( "default_language" ) );
			}
			if ( options.containsKey( "weights" ) ) {
				indexOptions.weights( (Bson) options.get( "weights" ) );
			}

			options.remove( "text" );
		}
		return indexOptions;
	}
23225
@Override
    public <T> Query<T> createQuery(Class<T> entityType, Object queryObject) {
        Assert.notNull(entityType, "entityType must not null");
        Assert.notNull(queryObject, "queryObject must not null");
        return query(entityType, queryObject);
    }