Class OptionalArray<T>
java.lang.Object
org.apache.sysds.runtime.frame.data.columns.Array<T>
org.apache.sysds.runtime.frame.data.columns.OptionalArray<T>
- All Implemented Interfaces:
org.apache.hadoop.io.Writable
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sysds.runtime.frame.data.columns.Array
Array.ArrayIterator -
Field Summary
Fields inherited from class org.apache.sysds.runtime.frame.data.columns.Array
ROW_PARALLELIZATION_THRESHOLD -
Constructor Summary
ConstructorsConstructorDescriptionOptionalArray(Array<T> a, boolean empty) OptionalArray(Array<T> a, ABooleanArray n) OptionalArray(T[] a) OptionalArray(T[] a, Types.ValueType vt) -
Method Summary
Modifier and TypeMethodDescriptionanalyzeValueType(int maxCells) Analyze the column to figure out if the value type can be refined to a better type.voidAppend a string value to the current Array, this should in general be avoided, and appending larger blocks at a time should be preferred.Append other array, if the other array is fitting in current allocated size use that allocated size, otherwise allocate new array to combine the other with this.voidAppend a value of the same type of the Array.static <T> OptionalArray<T>appendOther(OptionalArray<T> that, Array<T> appended) Array<?>Change the allocated array to a different type.clone()Overwrite of the java internal clone function for arrays, return a clone of underlying data that is mutable, (not immutable data.) Immutable data is dependent on the individual allocated arraysbooleananalyze if the array contains null values.booleanEquals operation on arrays.voidfill the entire array with specific value.voidfill the entire array with specific value.get()Get the underlying array out of the column Group, it is the responsibility of the caller to know what type it is.get(int index) Get the value at a given index.byte[]Return the current allocated Array as a byte[], this is used to serialize the allocated Arrays out to the PythonAPI.doublegetAsDouble(int i) Get the index's value.doublegetAsNaNDouble(int i) Get the index's value.longGet the exact serialized size on disk of this array.Get the internal FrameArrayType, to specify the encoding of the Types, note there are more Frame Array Types than there is ValueTypes.longGet in memory size, not counting reference to this object.getInternal(int index) Get the internal value at a given index.getNulls()Get the current value type of this array.doublehashDouble(int idx) Hash the given index of the array.booleanisEmpty()Get if this array is empty, aka filled with empty values.final booleanisNotEmpty(int i) booleananalyze if this array can be shallow serialized.booleanvoidreadFields(DataInput in) voidreset(int size) Reset the Array and set to a different size.select(boolean[] select, int nTrue) Slice out the true indices in the select input and return the sub array.select(int[] indices) Slice out the specified indices and return the sub array.voidset(int index, double value) Set index to given double value (cast to the correct type of this array)voidSet range to given arrays value with an offset into other arrayvoidSet index to the given value of the string parsed.voidSet index to the given value of same typevoidsetFromOtherType(int rl, int ru, Array<?> value) Set range to given arrays valuevoidsetFromOtherTypeNz(int rl, int ru, Array<?> value) Set non default values in the range from the value array givenvoidsetM(HashMapToInt<T> map, int si, AMapToData m, int i) Set the index i in the map given based on the mapping provided.voidsetM(HashMapToInt<T> map, AMapToData m, int i) Set the index i in the map given based on the mapping provided.voidSet non default values in the range from the value array givenslice(int rl, int ru) Slice out the sub range and return new array with the specified type.toString()voidwrite(DataOutput out) Methods inherited from class org.apache.sysds.runtime.frame.data.columns.Array
analyzeValueType, baseMemoryCost, changeType, changeType, changeType, changeTypeWithNulls, changeTypeWithNulls, changeTypeWithNulls, equals, extractDouble, findEmpty, findEmptyInverse, getCache, getIterator, getMinMaxLength, getRecodeMap, getRecodeMap, getRecodeMap, minMax, minMax, set, setCache, setFromOtherTypeNz, setNz, size, statistics
-
Constructor Details
-
OptionalArray
-
OptionalArray
-
OptionalArray
-
OptionalArray
-
-
Method Details
-
write
- Throws:
IOException
-
getExactSerializedSize
public long getExactSerializedSize()Description copied from class:ArrayGet the exact serialized size on disk of this array.- Specified by:
getExactSerializedSizein classArray<T>- Returns:
- The exact size on disk
-
getInMemorySize
public long getInMemorySize()Description copied from class:ArrayGet in memory size, not counting reference to this object.- Overrides:
getInMemorySizein classArray<T>- Returns:
- the size in memory of this object.
-
readFields
- Throws:
IOException
-
get
Description copied from class:ArrayGet the value at a given index. This method returns objects that have a high overhead in allocation. Therefore it is not as efficient as using the vectorized operations specified in the object. -
getInternal
Description copied from class:ArrayGet the internal value at a given index. For instance HashIntegerArray would return the underlying long not a string.- Overrides:
getInternalin classArray<T>- Parameters:
index- the index to get- Returns:
- The value to get
-
get
Description copied from class:ArrayGet the underlying array out of the column Group, it is the responsibility of the caller to know what type it is. Also it is not guaranteed that the underlying data structure does not allocate an appropriate response to the caller. This in practice means that if called there is a possibility that the entire array is allocated again. So the method should only be used for debugging purposes not for performance. -
getAsDouble
public double getAsDouble(int i) Description copied from class:ArrayGet the index's value. returns 0 in case of Null.- Specified by:
getAsDoublein classArray<T>- Parameters:
i- index to get value from- Returns:
- the value
-
getAsNaNDouble
public double getAsNaNDouble(int i) Description copied from class:ArrayGet the index's value. returns Double.NaN in case of Null.- Overrides:
getAsNaNDoublein classArray<T>- Parameters:
i- index to get value from- Returns:
- the value
-
set
Description copied from class:ArraySet index to the given value of same type -
set
public void set(int index, double value) Description copied from class:ArraySet index to given double value (cast to the correct type of this array) -
set
Description copied from class:ArraySet index to the given value of the string parsed. -
setFromOtherType
Description copied from class:ArraySet range to given arrays value- Specified by:
setFromOtherTypein classArray<T>- Parameters:
rl- row lowerru- row upper (inclusive)value- value array to take values from (other type)
-
set
Description copied from class:ArraySet range to given arrays value with an offset into other array -
setNz
Description copied from class:ArraySet non default values in the range from the value array given -
setFromOtherTypeNz
Description copied from class:ArraySet non default values in the range from the value array given- Specified by:
setFromOtherTypeNzin classArray<T>- Parameters:
rl- row startru- row end inclusivevalue- value array of different type
-
append
Description copied from class:ArrayAppend a string value to the current Array, this should in general be avoided, and appending larger blocks at a time should be preferred. -
append
Description copied from class:ArrayAppend a value of the same type of the Array. This should in general be avoided, and appending larger blocks at a time should be preferred. -
append
Description copied from class:ArrayAppend other array, if the other array is fitting in current allocated size use that allocated size, otherwise allocate new array to combine the other with this. This method should use the set range function, and should be preferred over the append single values. -
appendOther
-
slice
Description copied from class:ArraySlice out the sub range and return new array with the specified type. If the conversion fails fallback to normal slice. -
reset
public void reset(int size) Description copied from class:ArrayReset the Array and set to a different size. This method is used to reuse an already allocated Array, without extra allocation. It should only be done in cases where the Array is no longer in use in any FrameBlocks. -
getAsByteArray
public byte[] getAsByteArray()Description copied from class:ArrayReturn the current allocated Array as a byte[], this is used to serialize the allocated Arrays out to the PythonAPI.- Specified by:
getAsByteArrayin classArray<T>- Returns:
- The array as bytes
-
getValueType
Description copied from class:ArrayGet the current value type of this array.- Specified by:
getValueTypein classArray<T>- Returns:
- The current value type.
-
changeType
Description copied from class:ArrayChange the allocated array to a different type. If the type is the same a deep copy is returned for safety.- Overrides:
changeTypein classArray<T>- Parameters:
t- The type to change to- Returns:
- A new column array.
-
analyzeValueType
Description copied from class:ArrayAnalyze the column to figure out if the value type can be refined to a better type. The return is in two parts, first the type it can be, second if it contains nulls.- Specified by:
analyzeValueTypein classArray<T>- Parameters:
maxCells- maximum number of cells to analyze- Returns:
- A better or equivalent value type to represent the column, including null information.
-
getFrameArrayType
Description copied from class:ArrayGet the internal FrameArrayType, to specify the encoding of the Types, note there are more Frame Array Types than there is ValueTypes.- Specified by:
getFrameArrayTypein classArray<T>- Returns:
- The FrameArrayType
-
fill
Description copied from class:Arrayfill the entire array with specific value. -
fill
Description copied from class:Arrayfill the entire array with specific value. -
isShallowSerialize
public boolean isShallowSerialize()Description copied from class:Arrayanalyze if this array can be shallow serialized. to allow caching without modification.- Specified by:
isShallowSerializein classArray<T>- Returns:
- boolean saying true if shallow serialization is available
-
getNulls
-
clone
Description copied from class:ArrayOverwrite of the java internal clone function for arrays, return a clone of underlying data that is mutable, (not immutable data.) Immutable data is dependent on the individual allocated arrays -
isEmpty
public boolean isEmpty()Description copied from class:ArrayGet if this array is empty, aka filled with empty values. -
select
Description copied from class:ArraySlice out the specified indices and return the sub array. -
select
Description copied from class:ArraySlice out the true indices in the select input and return the sub array. -
isNotEmpty
public final boolean isNotEmpty(int i) - Specified by:
isNotEmptyin classArray<T>
-
containsNull
public boolean containsNull()Description copied from class:Arrayanalyze if the array contains null values.- Overrides:
containsNullin classArray<T>- Returns:
- If the array contains null.
-
hashDouble
public double hashDouble(int idx) Description copied from class:ArrayHash the given index of the array. It is allowed to return NaN on null elements.- Specified by:
hashDoublein classArray<T>- Parameters:
idx- The index to hash- Returns:
- The hash value of that index.
-
equals
Description copied from class:ArrayEquals operation on arrays. -
possiblyContainsNaN
public boolean possiblyContainsNaN()- Specified by:
possiblyContainsNaNin classArray<T>
-
setM
Description copied from class:ArraySet the index i in the map given based on the mapping provided. The map should be guaranteed to contain all unique values. -
setM
Description copied from class:ArraySet the index i in the map given based on the mapping provided. The map should be guaranteed to contain all unique values except null. Therefore in case of null we set the provided si value. -
toString
-