下面有一个函数,递归地将一个大数组分解成两个子数组,并收集它们供以后处理。我的问题是,在拆分过程中是否有一种方法可以生成子数组以减少内存占用,例如,拆分调用的数组很大,~50G。
def split(array, subarrays):
n = len(array)
if n == 1:
return
else:
i = n / 2
subarray1 = array[:i]
subarrays.append(subarray1)
subarray2 = array[i:]
假设我们有一个有1亿行和80 GB大小的表。
每一行都有文本列和多个整数列。
我们将Innodb_buffer_pool_size设置为40G
我执行这个查询:
select text,id,like_count from example where time > 'xxx-xx-xx' and time < 'xxx-xx-xx'
因此,如果这个查询需要读取50G数据文件(因为有查询)并移动到缓冲池。我想知道缓冲池如何处理这些数据。
因为我们将缓冲池设置为40G,但是查询需要50G来处理它。
我读过这个问题:
根据答案:
int main()
{
int a = 7; // 7 rvalue is stored in the program binary and assigned to "a"
int b = 7 * rand(); // 7 is pulled from the program binary, multiplied by result of rand and assigned to "b"
// But...
const int& c = 3; // 3 is an rvalue?
我知道c++编译器在某些情况下通常不会为const int分配存储空间,而是求助于const折叠。我尝试了一个简单的程序来测试这个:
int main()
{
const int num = 5;
int a[num];
}
我使用-g标志进行编译,并在gdb中运行它。当尝试访问这里的变量num的地址时,它显示了一些有效地址。我没想到会这样。这里有什么见解吗?