Field#
- class Field#
This class may be used as an input to FHE SQL queries implemented by Table class. To this end, a Field object may be created using Table::createCompareValue() function. Then, the created Field object may be used as an input to FHE SQL queries, such as Table::countQuery().
- load_from_buffer(self: pyhelayers.Field, buf: bytes) None #
Loads this Field from a buffer.
- Parameters:
buf – a memory buffer to load the object from.
- load_from_file(self: pyhelayers.Field, file_name: str) int #
Loads this Field from a file saved by save_to_file().
- Parameters:
file_name (string) – File to load from.
- save_to_buffer(self: pyhelayers.Field) bytes #
Saves this Field into a buffer.
- Returns:
a memory buffer containing the saved object.
- save_to_file(self: pyhelayers.Field, file_name: str) int #
Saves this Field to a file in binary form.
- Parameters:
file_name (string) – File to write to.
-
class Field#
This class holds one or more encrypted values.
It may be used as an input to FHE SQL queries implemented by Table class. To this end, a Field object can be created using Table::createCompareValue() function. Then, the created Field object can be used as an input to FHE SQL queries, such as Table::countQuery(). The Field class also has some internal usages. For example, it is used by the Table class to hold a single column value of slotCount database records. If a Table contains 2*SlotCount records and one column, it will hold two Field objects. While If a Table contains 2*slotCount records and two columns, it will hold four Field objects.
Public Functions
-
inline Field(const HeContext &he)#
Constructs an empty object.
- Parameters:
HeContext – The heContext.
A constructor for a hybrid bitwise Field.
A Constructor for a numerical Field.
- Parameters:
_he –
_singleValue – The values of the entires represented by this field (a single value for each entry).
_mask – A (possibly nullptr) mask to zero some of the entries of the queries on this Field. See also Field::mask.
ft – The type of the data represented by this field.
-
inline bool isBitWise() const#
Returns true if this field holds a hybrid biwise ciphertext and false otherwise.
-
inline bool isIndicators() const#
returns true if this Field is composed from indicators and false otherwise.
Updates the mask held in this field.
If the mask is set to be a non-nullptr value it can be multiplied with the result of queries made on this Field to zero some of the resulting query entries.
-
Field createIndicator(const Field &fieldToCompare, bool useInverse, ComparisonType ct, bool multByMask = false) const#
Creates an indicator Field, holding 1 for each slot for which the given comparison condition holds and 0 for all other slots.
- Parameters:
filedToCompare – The other field we should compare this Field with.
ct – The comparison query type.
multByMask – Whether the query result should be multiplied by the stored mask before it is returned.
-
void sumWithOtherField(const Field &fieldToSum)#
Sums the values in this Field with the given other Field.
This Field and fieldToSum mustn’t be of the hybrid bitwise type.
- Parameters:
fieldToSum – Other field to sum.
- Throws:
runtime_error – If either this Field or fieldToSum is of the hubrid bitwise type.
-
void multWithOtherField(const Field &fieldToMult)#
Multiply the values in this Field with the given other Field.
This field and the given fieldToMult mustn’t be of the hybrid bitwise type.
- Parameters:
fieldToSum – Other field to multiply.
-
void multWithOtherCipher(const CTile &cipherToMult)#
Multiply the values in this Field with the values in the given CTile.
This field mustn’t be of the hybrid bitwise type.
- Parameters:
cipherToMult – CTile to multiply with.
-
Field multByIndicatorsAndMutate(const Field &indicators) const#
Returns the result of multiplying this Field by the given indicators Field.
- Parameters:
indicators – To multiply with.
-
void multByIndicator(const Field &indicators)#
Multiplies this Field by the given indicators Field.
- Parameters:
indicators – To multiply with.
-
void multByScalar(double scalar)#
Multipltes this Field by the given scalar.
- Parameters:
scalar – The scalar to multiply by.
-
void innerSum()#
Sums all of the slots of this Field into the first slot.
The type of this field mustn’t be of the hybrid bitwise type.
-
void multWithMaskInplace()#
Multiplies this field by the stored mask, in place.
-
std::streamoff save(std::ostream &stream) const#
Saves this Field to a stream in binary form.
Returns the number of bytes written to the output stream.
- Parameters:
stream – [in] output stream to write to
-
std::streamoff load(std::istream &stream)#
Loads this Field from the given stream.
Returns the number of bytes read from the input stream.
- Parameters:
stream – [in] input stream to read from
-
std::streamoff saveToFile(const std::string &fileName) const#
Saves this Field to a file in binary form.
Returns the number of bytes written to the saved file.
- Parameters:
fileName – [in] name of file to write to
-
std::streamoff loadFromFile(const std::string &fileName)#
Loads this Field from a file saved by saveToFile().
Returns the number of bytes read from the loaded file.
- Parameters:
fileName – [in] name of file to read from
-
inline Field(const HeContext &he)#