Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solved #4519 Need a reference page for .internal.selfref #6695

Closed
wants to merge 1 commit into from

Conversation

spiddy1204
Copy link

@spiddy1204 spiddy1204 commented Dec 26, 2024

closes #4519
i added a seperate file internal.selfref.rd
containing its

  1. Purpose and Functionality
  2. Behavior and Use
  3. User Interaction
  4. Examples
  5. Reference to Related Functions

@MichaelChirico can you please review it.

Copy link
Contributor

@aitap aitap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: in order to make the new help page more discoverable, find a few other appropriate help pages and link to internal.selfref from there. Either add it to the \seealso{...} section as \code{\link{internal.selfref}}, or add it directly to the main text as \link{internal.selfref} (optionally wrapped into \code{...}).

Are you the same person as @venom1204?
Edit: If yes, let's choose one out of the two pull requests for further review and close the other one. Avoiding unnecessary duplication of maintainers' work is the considerate thing to do.

\alias{.internal.selfref}
\title{Internal Self-Reference Attribute in data.table}
\description{
The `.internal.selfref` attribute is an internal mechanism used by \code{data.table} to optimize memory management and performance. This attribute ensures that \code{data.table} objects can be modified by reference without unnecessary copying, enabling efficient data manipulation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use the ` backtick syntax ` in Rd files. The Rd syntax has \code for anything that can be parsed as valid R and \samp or \verb for other cases.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yha @venom1204 is my account i am closing this pull request as @venom1204 will be my main account .
i will introduce all the necesarry changes and push them through @venom1204 account. @aitap

Comment on lines +11 to +20
The `.internal.selfref` attribute is a pointer that allows \code{data.table} objects to reference their own memory location. This avoids redundant memory allocation when performing in-place modifications such as adding or updating columns, filtering rows, or performing joins.

If the `.internal.selfref` attribute is lost or corrupted (e.g., due to operations that inadvertently break reference semantics), \code{data.table} falls back to standard \code{data.frame}-like behavior, which can lead to reduced performance due to copying.

Users generally do not need to interact directly with `.internal.selfref`, but understanding its purpose can help debug issues related to memory usage or unexpected copying in \code{data.table} operations.

Note that `.internal.selfref` is automatically managed by \code{data.table} and is not intended to be modified by users.
}
\value{
The `.internal.selfref` attribute is an internal implementation detail and does not produce a value that users would typically interact with. It is invisible during regular \code{data.table} operations.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing about the backtick syntax here.

dt[, C := A * 2]

# Verify .internal.selfref is maintained
attr(dt, ".internal.selfref")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not very informative because the pointer fields always contains the address of R's NULL value.

Copy link

codecov bot commented Dec 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.61%. Comparing base (3b2812b) to head (ca6c32a).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6695   +/-   ##
=======================================
  Coverage   98.61%   98.61%           
=======================================
  Files          79       79           
  Lines       14559    14559           
=======================================
  Hits        14358    14358           
  Misses        201      201           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@spiddy1204 spiddy1204 closed this Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need a reference page for .internal.selfref
2 participants