private RIntVector createResult(RAbstractVector x, int[] data, boolean useNames) { RIntVector result = RDataFactory.createIntVector(data, RDataFactory.COMPLETE_VECTOR); if (useNames) { result.copyNamesFrom(attrProfiles, x); } return result; }
public final RIntVector materialize() { int length = getLength(); int[] result = new int[length]; for (int i = 0; i < length; i++) { int data = getDataAt(i); result[i] = data; } return RDataFactory.createIntVector(result, vector.isComplete()); }
@Specialization( guards = { "!copyAllAttributes || target != source", "containsMetadata(source, attrSourceProfiles)" }) public RAbstractVector copySameLength( RAbstractVector target, RAbstractVector source, // @Cached("create()") CopyOfRegAttributesNode copyOfReg, // @Cached("createDim()") RemoveAttributeNode removeDim, // @Cached("createDimNames()") RemoveAttributeNode removeDimNames, // @Cached("create()") InitAttributesNode initAttributes, // @Cached("createNames()") PutAttributeNode putNames, // @Cached("createDim()") PutAttributeNode putDim, // @Cached("createBinaryProfile()") ConditionProfile noDimensions, // @Cached("createBinaryProfile()") ConditionProfile hasNamesSource, // @Cached("createBinaryProfile()") ConditionProfile hasDimNames) { RVector result = target.materialize(); if (copyAllAttributes) { copyOfReg.execute(source, result); } int[] newDimensions = source.getDimensions(); if (noDimensions.profile(newDimensions == null)) { RAttributes attributes = result.getAttributes(); if (attributes != null) { removeDim.execute(attributes); removeDimNames.execute(attributes); result.setInternalDimNames(null); } result.setInternalDimensions(null); RStringVector vecNames = source.getNames(attrSourceProfiles); if (hasNamesSource.profile(vecNames != null)) { putNames.execute(initAttributes.execute(result), vecNames); result.setInternalNames(vecNames); return result; } return result; } putDim.execute( initAttributes.execute(result), RDataFactory.createIntVector(newDimensions, RDataFactory.COMPLETE_VECTOR)); result.setInternalDimensions(newDimensions); RList newDimNames = source.getDimNames(attrSourceProfiles); if (hasDimNames.profile(newDimNames != null)) { result.getAttributes().put(RRuntime.DIMNAMES_ATTR_KEY, newDimNames); newDimNames.elementNamePrefix = RRuntime.DIMNAMES_LIST_ELEMENT_NAME_PREFIX; result.setInternalDimNames(newDimNames); return result; } return result; }
@Specialization(guards = {"!copyAllAttributes || target != source", "containsMetadata(source)"}) protected RAbstractVector copySameLength( RAbstractVector target, RAbstractVector source, // @Cached("create()") CopyOfRegAttributesNode copyOfReg, // @Cached("createDim()") RemoveFixedAttributeNode removeDim, // @Cached("createDimNames()") RemoveFixedAttributeNode removeDimNames, // @Cached("create()") InitAttributesNode initAttributes, // @Cached("createNames()") SetFixedAttributeNode putNames, // @Cached("createDim()") SetFixedAttributeNode putDim, // @Cached("createDimNames()") SetFixedAttributeNode putDimNames, // @Cached("createBinaryProfile()") ConditionProfile noDimensions, // @Cached("createBinaryProfile()") ConditionProfile hasNamesSource, // @Cached("createBinaryProfile()") ConditionProfile hasDimNames, @Cached("create()") GetDimAttributeNode getDimsNode) { RVector<?> result = target.materialize(); if (copyAllAttributes) { copyOfReg.execute(source, result); } int[] newDimensions = getDimsNode.getDimensions(source); if (noDimensions.profile(newDimensions == null)) { DynamicObject attributes = result.getAttributes(); if (attributes != null) { removeDim.execute(attributes); removeDimNames.execute(attributes); } RStringVector vecNames = getNamesNode.getNames(source); if (hasNamesSource.profile(vecNames != null)) { putNames.execute(initAttributes.execute(result), vecNames); return result; } return result; } putDim.execute( initAttributes.execute(result), RDataFactory.createIntVector(newDimensions, RDataFactory.COMPLETE_VECTOR)); RList newDimNames = getDimNamesNode.getDimNames(source); if (hasDimNames.profile(newDimNames != null)) { putDimNames.execute(result.getAttributes(), newDimNames); newDimNames.elementNamePrefix = RRuntime.DIMNAMES_LIST_ELEMENT_NAME_PREFIX; return result; } return result; }
public final RVector createEmptySameType(int newLength, boolean newIsComplete) { return RDataFactory.createIntVector(new int[newLength], newIsComplete); }