C ++找到ofstream的大小(C++ find size of ofstream)
我有代码,目前有如下所示:
ofstream fout; fout.open("file.txt"); fout<<"blah blah "<<100<<","<<3.14; //get ofstream length here fout<<"write more stuff"<<endl;
有没有一种方便的方法来找出在上面指定的阶段写的那条线的长度? (在现实生活中,int 100和float 3.14不是恒定的,可以改变)。 有没有一种方法可以做我想做的事?
编辑:通过长度,我的意思是可以使用fseek,例如
fseek(pFile, -linelength, SEEK_END);
I have code that currently does something like the following:
ofstream fout; fout.open("file.txt"); fout<<"blah blah "<<100<<","<<3.14; //get ofstream length here fout<<"write more stuff"<<endl;
Is there a convenient way to find out the length of that line that is written at the stage I specified above? (in real life, the int 100 and float 3.14 are not constant and can change). Is there a good way to do what I want?
EDIT: by length, I mean something that can be used using fseek, e.g.
fseek(pFile, -linelength, SEEK_END);
原文:https://stackoverflow.com/questions/16825055
最满意答案
GCS的回应:
我们的产品团队能够找到索引无法创建的原因。 看起来,在数据中,您有两个不唯一的条目,因此会创建唯一性违规[1]并阻止创建索引。 在索引尝试之前抛出此错误,这就是为什么索引创建失败,甚至未尝试索引。
您可以使用查询来查找重复条目:
SELECT column, count(column) FROM table GROUP BY column HAVING COUNT(column) > 1
您可以修改此查询以同时搜索所有密钥或在每次搜索后对其进行修改。 一旦完成了重复项目,您应该能够管理这些项目并再次运行索引创建。
我希望Spanner团队能够修复这个错误,并在未来的版本中返回正确的错误。
Response from GCS:
Our product team was able to find the reason the indexes are not able to be created. As it appears, within the data, you have two entries that are not unique and thus creates a uniqueness violation[1] and prevent the index from being created. This error is thrown prior to the index attempt and that is why the index creation fails before it is even attempted.
You can use a query to find the duplicate entries:
SELECT column, count(column) FROM table GROUP BY column HAVING COUNT(column) > 1
You can modify this query to search all keys at the same time or modify it after each search. Once the duplicates have been taken care of, you should be able to manage these entries and run the index creation again.
I hope the Spanner team can fix this bug and return the correct error in a future release.
相关问答
更多-
“Spanner操作失败”创建NULL_FILTERED索引(“Spanner operation failed” creating NULL_FILTERED indexes)[2024-01-09]
GCS的回应: 我们的产品团队能够找到索引无法创建的原因。 看起来,在数据中,您有两个不唯一的条目,因此会创建唯一性违规[1]并阻止创建索引。 在索引尝试之前抛出此错误,这就是为什么索引创建失败,甚至未尝试索引。 您可以使用查询来查找重复条目: SELECT column, count(column) FROM table GROUP BY column HAVING COUNT(column) > 1 您可以修改此查询以同时搜索所有密钥或在每次搜索后对其进行修改。 一旦完成了重复项目,您应该能够管理这 ... -
是的,你不能用架构来做。 您需要先创建模型,然后才能执行以下操作: Order.collection.getIndexes({full: true}).then(indexes => { console.log("indexes:", indexes); // ... }).catch(console.error); Yeah, you can't do it with a schema. You will need to create the model first, and then ...
-
你得到以下错误。 Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax/persistence/Table.indexes()ÝLjavax/persistence/Index; 此错误表示特定类中没有所需的方法。 “index()”方法可以在JPA 2.1 jar(hibernate-jpa-2.1-api)的“javax.persistence.Table”类中找到。 一些如何在 ...
-
哪些索引是必要的?(Which indexes are necessary?)[2021-07-22]
两个查询都可以使用table_a(COL2, COL1)上的常规B树索引。 单独使用COL2上的索引可能更有效地仅使用此列上的过滤器来检索行,但附加索引将使用空间并且会减慢插入速度(如果更新此列,则会更新)。 这是一种权衡。 A regular B-tree index on table_a(COL2, COL1) could be used by both queries. Having an index on COL2 alone might be more efficient to retrieve ... -
touch():Utime失败:操作不允许filesystem.inc:262(touch(): Utime failed: Operation not permitted filesystem.inc:262)[2022-04-09]
我正在努力解决同样的问题。 我发现不使用NFS作为sync_type解决了我的问题。 I was struggling with the same issue. I have found that NOT using NFS as the sync_type solved my problem. -
它是您的索引中的WHERE子句。 我的一百万行表的真实生活计划: 我需要一个表中的列索引,但90%的值是NULL。 我需要非空的10%的索引,但索引是臃肿与90%NULL。 所以我添加过滤器并节省空间。 我想独一无二的同一列(eq唯一的非空值)。 在SQL Server 2008之前,我必须使用索引视图或代码。 现在,“WHERE”允许我通过索引执行唯一的操作 It's WHERE clause on your index. My real life plans for a million row tabl ...
-
您不能通过直接引用getdate()来完成此操作。 您需要动态SQL。 CREATE INDEX语法只允许与常量进行比较。 CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name ON
-
1 and tbl0.Type = 'Alert' 2 AND (tbl0.AccessRights like '%'+TblCUG0.userGroup+'%' 3 or tbl0.AccessRights like 'All' ) 4 AND (tbl0.ExpiryDate > CONVERT(varchar(8), GETDATE(), 1) 5 or tbl0.ExpiryDate is null) 最有可能的是,您将无法使用带有WHER ...
-
一块一块地移动记录结果非常长,有或没有索引,所以这个选项被抛弃了。 此外,当我们尝试它时,我们的事务日志的磁盘空间变得庞大,并使大多数查询失败。 我们最终做的是使用建议的SQL批量传输工具,新表没有索引。 对于十亿+行,这花了大约一个小时。 然后重新创建索引每个只需几分钟。 Moving the records piece by piece turned out to take incredibly long, with or without indexes, so this option was thro ...
-
您无法使用Array作为键创建索引: 不允许的类型 这些不能是ARRAY类型: 表的关键列。 索引的关键列。 您可以通过STORING关键字在索引中包含Array,以返回数组而不加入主表,但是您无法扫描我 You can't create an index using an Array as a key: Disallowed types These cannot be of type ARRAY: A table's key columns. An index's key columns. You can ...