Swarm-NG  1.1
swarmng.logdb.IndexedLogDB Class Reference

Interface to BDB log files. More...

Public Member Functions

def __init__
 Opens a BDB file that contains the primary database and secondary indices. More...
 
def getMetadata
 Get meta data from the database for the provided name string. More...
 
def all_records
 Return an iterable for all of the records, the records are sorted by time, then event id then system id. More...
 
def time_sequence
 Returns a iterable of times for a time range, it is used for making range queries. More...
 
def system_range_records
 Query for all the records that have system id in the system range. More...
 
def time_range_records
 Query for all the records that have time in the time range. More...
 
def system_at_time
 Query for all the records for a system in a given time range. More...
 
def initial_conditions
 Return initial coniditions for the system range. More...
 
def final_conditions
 Return the final conditions for a range of systems that is the largest time for which the system has a valid entry. More...
 
def query
 Query the database for with a time range ,system range and event id range. More...
 

Static Public Attributes

string fileFormatVersion = "1"
 Supported version of BDB log files.
 

Detailed Description

Interface to BDB log files.

open a log file like:

1 >>> db = IndexedLogDB('mydatabase.db')
2 >>> records = db.all_records()
3 >>> print(next(records))
4 >>> print(next(records))

Note that most of the methods below return key-value pairs. The key-value pair is a Python tuple where the first element is of type PKey and has time, system_id, event_id properties. the second element is a LogRecord object and contains all the information about the planetary system and its attributes.

Definition at line 180 of file logdb.py.

Constructor & Destructor Documentation

Member Function Documentation

def swarmng.logdb.IndexedLogDB.all_records (   self)

Return an iterable for all of the records, the records are sorted by time, then event id then system id.

The elements of the returend iterable or key-value pairs.

Definition at line 255 of file logdb.py.

def swarmng.logdb.IndexedLogDB.final_conditions (   self,
  system_range 
)

Return the final conditions for a range of systems that is the largest time for which the system has a valid entry.

Return an iterable of a tuple of system id and LogRecord.

Usage:

1 for system_id, lr in d.final_conditions(Range.interval(10,20)):
2  print(system_id) # prints integers
3  print(lr.time) # lr is a LogRecord object and has a time property

Definition at line 369 of file logdb.py.

def swarmng.logdb.IndexedLogDB.getMetadata (   self,
  name 
)

Get meta data from the database for the provided name string.

There are two metadata that are always available: fileFormatVersion and swarmngVersion

Meta data for the log file is a mapping of string -> string.

  • name : string :name of the property we are looking for. returns : string value for the provided property, None if the property is not found.

Definition at line 241 of file logdb.py.

References swarmng.logdb.IndexedLogDB.fileFormatVersion, and swarmng.logdb.IndexedLogDB.getMetadata().

Referenced by swarmng.logdb.IndexedLogDB.getMetadata().

def swarmng.logdb.IndexedLogDB.initial_conditions (   self,
  system_range 
)

Return initial coniditions for the system range.

Return an iterable of a tuple of system id and LogRecord.

Usage:

1 for system_id, lr in d.initial_conditions(Range.interval(10,20)):
2  print(system_id) # prints integers
3  print(lr.time) # lr is a LogRecord object and has a time property

Definition at line 336 of file logdb.py.

def swarmng.logdb.IndexedLogDB.query (   d,
  tr,
  sr,
  er 
)

Query the database for with a time range ,system range and event id range.

Return an iterable of key-value pairs.

Definition at line 419 of file logdb.py.

def swarmng.logdb.IndexedLogDB.system_at_time (   self,
  sysid,
  time_range 
)

Query for all the records for a system in a given time range.

Return an iterable of key-value pairs.

Definition at line 311 of file logdb.py.

def swarmng.logdb.IndexedLogDB.system_range_records (   self,
  sys_range 
)

Query for all the records that have system id in the system range.

Return an iterable of key-value pairs.

Definition at line 280 of file logdb.py.

def swarmng.logdb.IndexedLogDB.time_range_records (   self,
  time_range 
)

Query for all the records that have time in the time range.

Return an iterable of key-value pairs.

Definition at line 295 of file logdb.py.

def swarmng.logdb.IndexedLogDB.time_sequence (   self,
  time_range 
)

Returns a iterable of times for a time range, it is used for making range queries.

The elements of the returned iterable are floating point values.

Definition at line 264 of file logdb.py.


The documentation for this class was generated from the following file: