Documentation
¶
Overview ¶
Key schema struct, constructors that are part of the OrientDB schema or support representing the schema.
Index ¶
- Constants
- func ODataTypeNameFor(dt ODataType) string
- type OClass
- type ODataType
- type ODocument
- func (doc *ODocument) AddField(name string, field *OField) *ODocument
- func (doc *ODocument) ConvertValue(v interface{}) (driver.Value, error)
- func (doc *ODocument) Field(name string, val interface{}) *ODocument
- func (doc *ODocument) FieldNames() []string
- func (doc *ODocument) FieldWithType(name string, val interface{}, fieldType ODataType) *ODocument
- func (doc *ODocument) GetField(fname string) *OField
- func (doc *ODocument) GetFieldById(id int32) *OField
- func (doc *ODocument) GetFields() []*OField
- func (doc *ODocument) Scan(src interface{}) error
- func (doc *ODocument) String() string
- func (doc *ODocument) StringNoFields() string
- func (doc *ODocument) ToJSON() ([]byte, error)
- func (doc *ODocument) Value() (driver.Value, error)
- type OEmbeddedArrayMap
- func (em *OEmbeddedArrayMap) All() (keys []string, vals []interface{}, types []ODataType)
- func (em *OEmbeddedArrayMap) Get(key string) (interface{}, ODataType)
- func (em *OEmbeddedArrayMap) Keys() []string
- func (em *OEmbeddedArrayMap) Len() int
- func (em *OEmbeddedArrayMap) Put(key string, val interface{}, typ ODataType)
- func (em OEmbeddedArrayMap) String() string
- func (em *OEmbeddedArrayMap) Types() []ODataType
- func (em *OEmbeddedArrayMap) Value(key string) interface{}
- func (em *OEmbeddedArrayMap) Values() []interface{}
- type OEmbeddedList
- type OEmbeddedMap
- type OEmbeddedSlice
- type OEmbeddedStringList
- type OField
- type OGlobalProperty
- type OLink
- type OLinkBag
- type OProperty
- type ORID
- type ORemoteLinkBag
Constants ¶
const ( // // Default ClusterID that maps to the "invalid" value on the OrientDB server // ClusterIDInvalid = -1 // // Default ClusterPos that maps to the "invalid" value on the OrientDB server // ClusterPosInvalid = -1 )
Variables ¶
This section is empty.
Functions ¶
func ODataTypeNameFor ¶
Types ¶
type OClass ¶
type OClass struct { Name string ShortName string Properties map[string]*OProperty // key=Property.Name DefaultClusterID int32 // TODO: why is this int32 ?? shouldn't it be int16? ClusterIDs []int32 // TODO: why is this int32 ?? shouldn't it be int16? SuperClass string OverSize float32 StrictMode bool AbstractClass bool ClusterSelection string // OClusterSelectionStrategy in Java code - needed? CustomFields map[string]string }
func NewOClassFromDocument ¶
Should be passed an ODocument that comes from a load schema request to the database.
type ODataType ¶
type ODataType byte
ODataType is an enum for the various datatypes supported by OrientDB.
const ( BOOLEAN ODataType = 0 INTEGER ODataType = 1 SHORT ODataType = 2 LONG ODataType = 3 FLOAT ODataType = 4 DOUBLE ODataType = 5 DATETIME ODataType = 6 STRING ODataType = 7 BINARY ODataType = 8 // means []byte EMBEDDED ODataType = 9 // was: EMBEDDEDRECORD EMBEDDEDLIST ODataType = 10 EMBEDDEDSET ODataType = 11 EMBEDDEDMAP ODataType = 12 LINK ODataType = 13 LINKLIST ODataType = 14 LINKSET ODataType = 15 LINKMAP ODataType = 16 BYTE ODataType = 17 TRANSIENT ODataType = 18 DATE ODataType = 19 CUSTOM ODataType = 20 DECIMAL ODataType = 21 LINKBAG ODataType = 22 ANY ODataType = 23 // BTW: ANY == UNKNOWN/UNSPECIFIED UNKNOWN ODataType = 255 // ogonori addition )
in alignment with: https://github.com/orientechnologies/orientdb/wiki/Types
type ODocument ¶
type ODocument struct { RID ORID Version int32 Fields map[string]*OField // key: property-name // TODO: may want a mapping of ids => OField Classname string // TODO: probably needs to change *OClass (once that is built) // contains filtered or unexported fields }
func NewDocument ¶
NewDocument should be called to create new ODocument objects, since some internal data structures need to be initialized before the ODocument is ready to use.
func NewEmptyDocument ¶
func NewEmptyDocument() *ODocument
TODO: have this replace NewDocument and change NewDocument to take RID and Version (???)
func (*ODocument) AddField ¶
AddField adds a fully created field directly rather than by some of its attributes, as the other "Field" methods do. The same *ODocument is returned to allow call chaining.
func (*ODocument) ConvertValue ¶
Implements database/sql/driver.ValueConverter interface TODO: haven't detected when this is called yet
func (*ODocument) Field ¶
Field is used to add a new field to a document. This will usually be done just before calling Save and sending it to the database. The field type will be inferred via type switch analysis on `val`. Use FieldWithType to specify the type directly. The same *ODocument is returned to allow call chaining.
func (*ODocument) FieldNames ¶
FieldNames returns the names of all the fields currently in this ODocument in "entry order". These fields may not have already been committed to the database.
func (*ODocument) FieldWithType ¶
FieldWithType is used to add a new field to a document. This will usually be done just before calling Save and sending it to the database. The `fieldType` must correspond one of the OrientDB type in the schema pkg constants. It will follow the same list as: https://github.com/orientechnologies/orientdb/wiki/Types The same *ODocument is returned to allow call chaining.
func (*ODocument) GetField ¶
GetFieldByName looks up the OField in this document with the specified field. If no field is found with that name, nil is returned.
func (*ODocument) GetFieldById ¶
GetFieldById looks up the OField in this document with the specified field id (aka property-id). If no field is found with that id, nil is returned.
func (*ODocument) GetFields ¶
GetFields return the OField objects in the Document in "entry order". There is some overhead to getting them in entry order, so if you don't care about that order, just access the Fields field of the ODocument struct directly.
func (*ODocument) StringNoFields ¶
StringNoFields is a String() method that elides the fields. This is useful when the fields include links and there are circular links.
type OEmbeddedArrayMap ¶
type OEmbeddedArrayMap struct {
// contains filtered or unexported fields
}
OEmbeddedArrayMap is optimized for small data sets, since it requires linear searches over the key slice to do lookups. For maps with a small number of entries (< 10 ?) this is typically faster than true hash lookups or tree walks
IMPORTANT NOTE: OEmbeddedArrayMap does not properly handle value changes (keys mapping to new values). They will be appended to the end and the old values will not be removed. TODO: This behavior will be reviewed later.
func (*OEmbeddedArrayMap) All ¶
func (em *OEmbeddedArrayMap) All() (keys []string, vals []interface{}, types []ODataType)
func (*OEmbeddedArrayMap) Get ¶
func (em *OEmbeddedArrayMap) Get(key string) (interface{}, ODataType)
func (*OEmbeddedArrayMap) Keys ¶
func (em *OEmbeddedArrayMap) Keys() []string
func (*OEmbeddedArrayMap) Len ¶
func (em *OEmbeddedArrayMap) Len() int
func (*OEmbeddedArrayMap) Put ¶
func (em *OEmbeddedArrayMap) Put(key string, val interface{}, typ ODataType)
func (OEmbeddedArrayMap) String ¶
func (em OEmbeddedArrayMap) String() string
func (*OEmbeddedArrayMap) Types ¶
func (em *OEmbeddedArrayMap) Types() []ODataType
func (*OEmbeddedArrayMap) Value ¶
func (em *OEmbeddedArrayMap) Value(key string) interface{}
func (*OEmbeddedArrayMap) Values ¶
func (em *OEmbeddedArrayMap) Values() []interface{}
type OEmbeddedList ¶
type OEmbeddedList interface { Len() int Get(idx int) interface{} Add(val interface{}) // Add(val interface{}, typ ODataType) // TODO: we could allow for mixed type lists -> useful? Type() ODataType Values() []interface{} }
OEmbeddedList is a interface wrapper for go slices that should be used when serializing Go ODocuments to the OrientDB database.
func NewEmbeddedSlice ¶
func NewEmbeddedSlice(v []interface{}, typ ODataType) OEmbeddedList
type OEmbeddedMap ¶
type OEmbeddedMap interface { Len() int Get(key string) (val interface{}, typ ODataType) Put(key string, val interface{}, typ ODataType) Value(key string) interface{} Keys() []string Values() []interface{} Types() []ODataType All() (keys []string, vals []interface{}, types []ODataType) }
OEmbeddedMap acts like a map[string]interface{} but: * it preserves insertion order * it can optionally retain the data type of the value
Right now there is only an OEmbeddedArrayMap implementation optimized for small maps. If larger maps are needed, an OEmbeddedTreeMap should be implemented.
Note that there is no Delete functionality (will be reviewed for that later)
func NewEmbeddedMap ¶
func NewEmbeddedMap() OEmbeddedMap
Creates an empty EmbeddedMap with default capacity (currently=8)
func NewEmbeddedMapWithCapacity ¶
func NewEmbeddedMapWithCapacity(cap int) OEmbeddedMap
Creates an empty EmbeddedMap with specified capacity
type OEmbeddedSlice ¶
type OEmbeddedSlice struct {
// contains filtered or unexported fields
}
func (*OEmbeddedSlice) Add ¶
func (es *OEmbeddedSlice) Add(val interface{})
func (*OEmbeddedSlice) Get ¶
func (es *OEmbeddedSlice) Get(idx int) interface{}
func (*OEmbeddedSlice) Len ¶
func (es *OEmbeddedSlice) Len() int
func (*OEmbeddedSlice) Type ¶
func (es *OEmbeddedSlice) Type() ODataType
func (*OEmbeddedSlice) Values ¶
func (es *OEmbeddedSlice) Values() []interface{}
type OEmbeddedStringList ¶
type OEmbeddedStringList struct {
// contains filtered or unexported fields
}
type OField ¶
type OField struct { ID int32 // TODO: is the size specified in OrientDB docs? Name string Type ODataType Value interface{} }
OField is a generic data holder that goes in ODocuments.
type OGlobalProperty ¶
OGlobalProperty is used by OrientDB to efficiently store "property" (field) types and names (but not values) across all clusters in a database These are stored in record #0:1 of a database and loaded when the DBClient starts up. (TODO: it will also need to be updated when new fields are added at runtime)
func NewGlobalPropertyFromDocument ¶
func NewGlobalPropertyFromDocument(doc *ODocument) OGlobalProperty
based on how the Java client does it ; TODO: document usage
type OLink ¶
OLink represents a LINK in the OrientDB system. It holds a RID and optionally a Record pointer to the ODocument that the RID points to.
type OLinkBag ¶
type OLinkBag struct { Links []*OLink ORemoteLinkBag }
OLinkBag can have a tree-based or an embedded representation.
Embedded stores its content directly to the document that owns it. It is used when only small numbers of links are stored in the bag.
The tree-based implementation stores its content in a separate data structure called on OSBTreeBonsai on the server. It fits great for cases when you have a large number of links. This is used to efficiently manage relationships (particularly in graph databases).
The OLinkBag struct corresponds to ORidBag in Java client codebase.
func NewOLinkBag ¶
NewOLinkBag constructor is called with all the OLink objects precreated. Usually appropriate when dealing with an embedded LinkBag.
func NewTreeOLinkBag ¶
NewTreeOLinkBag constructor is called for remote tree-based LinkBags. This is called by the Deserializer when all it knows is the pointer reference to the LinkBag on the remote server.
The OLinkBag returned does not yet know the size of the LinkBag nor know what the OLinks are.
type OProperty ¶
type OProperty struct { ID int32 // TODO: is the size specified in OrientDB docs? Name string Fullname string // Classname.propertyName Type byte // corresponds to one of the type constants above NotNull bool Collate string // is OCollate in Java client Mandatory bool Min string Max string Regexp string CustomFields map[string]string Readonly bool }
OProperty roughly corresponds to OProperty in the Java client. It represents a property of a class in OrientDB. A property represents the metadata of a field. A field (OField) is the actual data of a field in an ODocument.
func NewOPropertyFromDocument ¶
NewOPropertyFromDocument creates a new OProperty from an ODocument that was created after a load schema call to the OrientDB server.
type ORID ¶
ORID encapsulates the two aspects of an OrientDB RecordID - ClusterID:ClusterPos
func NewORID ¶
func NewORID() ORID
Returns an ORID with the default "invalid" settings. Invalid settings indicate that the Document has not yet been saved to the DB (which assigns it a valid RID) or it indicates that it is not a true Document with a Class (e.g., it is a result of a Property query)
func NewORIDFromString ¶
NewORIDFromString converts a string of form #N:M or N:M to an ORID struct. Make sure to get the string format correctly, as this function panics if any error occurs.
type ORemoteLinkBag ¶
type ORemoteLinkBag struct { CollectionPointer *treeCollectionPointer // contains filtered or unexported fields }
func (*ORemoteLinkBag) GetFileID ¶
func (lb *ORemoteLinkBag) GetFileID() int64
GetFileID returns the fileID of the server collection pointer if the OLinkBag is an instance of ORemoteLinkBag. If the OLinkBAg is not an instance of ORemoteLinkBag, than the return value is meaningless, but no error is returned/thrown in such a case.
func (*ORemoteLinkBag) GetPageIndex ¶
func (lb *ORemoteLinkBag) GetPageIndex() int64
func (*ORemoteLinkBag) GetPageOffset ¶
func (lb *ORemoteLinkBag) GetPageOffset() int32
func (*ORemoteLinkBag) GetRemoteSize ¶
func (lb *ORemoteLinkBag) GetRemoteSize() int
func (*ORemoteLinkBag) SetRemoteSize ¶
func (lb *ORemoteLinkBag) SetRemoteSize(sz int32)