% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/altrep.R
\name{shared_vector}
\alias{shared_vector}
\title{Create a shared vector from a segment}
\usage{
shared_vector(
  segment,
  type = c("double", "integer", "logical", "raw"),
  offset = 0,
  length = NULL,
  readonly = TRUE,
  cow = NULL
)
}
\arguments{
\item{segment}{A shard_segment object}

\item{type}{Vector type: "integer", "double"/"numeric", "logical", or "raw"}

\item{offset}{Byte offset into segment (default: 0)}

\item{length}{Number of elements. If NULL, calculated from segment size.}

\item{readonly}{If TRUE, prevent write access via DATAPTR (default: TRUE)}

\item{cow}{Copy-on-write policy for mutation attempts. One of
\code{"deny"}, \code{"audit"}, or \code{"allow"}. If NULL, defaults to \code{"deny"} when
\code{readonly=TRUE} and \code{"allow"} otherwise.}
}
\value{
An ALTREP vector backed by shared memory
}
\description{
Create a shared vector from a segment
}
\examples{
\donttest{
seg <- segment_create(400)
segment_write(seg, 1:100, offset = 0)

x <- shared_vector(seg, "integer", length = 100)
x[1:10]

shared_diagnostics(x)
}
}
