Class Relation
- All Implemented Interfaces:
Proxy
GRelation
is a table of data which can be indexed on any number
of fields, rather like simple database tables. A GRelation
contains
a number of records, called tuples. Each record contains a number of
fields. Records are not ordered, so it is not possible to find the
record at a particular index.
Note that GRelation
tables are currently limited to 2 fields.
To create a GRelation
, use new_(int)
.
To specify which fields should be indexed, use index(int, org.gnome.glib.HashFunc, org.gnome.glib.EqualFunc)
.
Note that this must be called before any tuples are added to the
GRelation
.
To add records to a GRelation
use insert(java.lang.Object...)
.
To determine if a given record appears in a GRelation
, use
exists(java.lang.Object...)
. Note that fields are compared directly, so
pointers must point to the exact same position (i.e. different
copies of the same string will not match.)
To count the number of records which have a particular value in a
given field, use count(java.lang.foreign.MemorySegment, int)
.
To get all the records which have a particular value in a given
field, use select(java.lang.foreign.MemorySegment, int)
. To access fields of the resulting
records, use Tuples.index(int, int)
. To free the resulting records use
Tuples.destroy()
.
To delete all records which have a particular value in a given
field, use delete(java.lang.foreign.MemorySegment, int)
.
To destroy the GRelation
, use destroy()
.
To help debug GRelation
objects, use print()
.
GRelation
has been marked as deprecated, since this API has never
been fully implemented, is not very actively maintained and rarely
used.
-
Constructor Summary
ConstructorDescriptionRelation
(MemorySegment address) Deprecated.Create a Relation proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionint
count
(@Nullable MemorySegment key, int field) Deprecated.Rarely used APIint
delete
(@Nullable MemorySegment key, int field) Deprecated.Rarely used APIvoid
destroy()
Deprecated.Rarely used APIboolean
Deprecated.Rarely used APIvoid
Deprecated.Rarely used APIvoid
Deprecated.Rarely used APIstatic Relation
new_
(int fields) Deprecated.Rarely used APIvoid
print()
Deprecated.Rarely used APIselect
(@Nullable MemorySegment key, int field) Deprecated.Rarely used APIMethods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Relation
Deprecated.Create a Relation proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
new_
Deprecated.Rarely used APICreates a newGRelation
with the given number of fields. Note that currently the number of fields must be 2.- Parameters:
fields
- the number of fields.- Returns:
- a new
GRelation
.
-
count
Deprecated.Rarely used APIReturns the number of tuples in aGRelation
that have the given value in the given field.- Parameters:
key
- the value to compare with.field
- the field of each record to match.- Returns:
- the number of matches.
-
delete
Deprecated.Rarely used APIDeletes any records from aGRelation
that have the given key value in the given field.- Parameters:
key
- the value to compare with.field
- the field of each record to match.- Returns:
- the number of records deleted.
-
destroy
Deprecated.Rarely used APIDestroys theGRelation
, freeing all memory allocated. However, it does not free memory allocated for the tuple data, so you should free that first if appropriate. -
exists
Deprecated.Rarely used APIReturnstrue
if a record with the given values exists in aGRelation
. Note that the values are compared directly, so that, for example, two copies of the same string will not match.- Parameters:
varargs
- the fields of the record to compare. The number must match the number of fields in theGRelation
.- Returns:
true
if a record matches.
-
index
Deprecated.Rarely used APICreates an index on the given field. Note that this must be called before any records are added to theGRelation
.- Parameters:
field
- the field to index, counting from 0.hashFunc
- a function to produce a hash value from the field data.keyEqualFunc
- a function to compare two values of the given field.
-
insert
Deprecated.Rarely used APIInserts a record into aGRelation
.- Parameters:
varargs
- the fields of the record to add. These must match the number of fields in theGRelation
, and of typegpointer
orgconstpointer
.
-
print
Deprecated.Rarely used APIOutputs information about all records in aGRelation
, as well as the indexes. It is for debugging. -
select
Deprecated.Rarely used APIReturns all of the tuples which have the given key in the given field. Use g_tuples_index() to access the returned records. The returned records should be freed with g_tuples_destroy().- Parameters:
key
- the value to compare with.field
- the field of each record to match.- Returns:
- the records (tuples) that matched.
-