{"id":4855,"date":"2014-03-30T16:07:51","date_gmt":"2014-03-30T16:07:51","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-would-you-serialize-a-large-array-with-109-values-collection-of-common-programming-errors\/"},"modified":"2014-03-30T16:07:51","modified_gmt":"2014-03-30T16:07:51","slug":"how-would-you-serialize-a-large-array-with-109-values-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-would-you-serialize-a-large-array-with-109-values-collection-of-common-programming-errors\/","title":{"rendered":"How would you serialize a large array with 10^9 values?-Collection of common programming errors"},"content":{"rendered":"<p>Your example simply stores the index + 1 in each array element; you can get this via a calculation at runtime, there is no need to store or serialize anything.<\/p>\n<p>Even if your example is made-up and you are actually trying to store 10^9 arbitrary integers, you are probably going to going to have many duplicates. In this case you should be using a sparse data structure, not an array.<\/p>\n<p>Addendum: If the values are primary keys and must be unique, you may be better off storing the numbers that are <b>not<\/b> used rather than the ones which are.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Your example simply stores the index + 1 in each array element; you can get this via a calculation at runtime, there is no need to store or serialize anything. Even if your example is made-up and you are actually trying to store 10^9 arbitrary integers, you are probably going to going to have many [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4855","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4855"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4855\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}