Accessing the database
Web.py provides a simple and uniform interface to the database that you want to work with, whether it is PostgreSQL, MySQL, SQLite or any other. It doesn’t try to build layers between you and your database. Rather, it tries to make it easy to perform common tasks, and get out of your way when you need to do more advanced things.
Create database object
The first thing to work with databases from web.py is to create a create a database object with web.database(). It returns database object, which has convenient methods for you to use.
Make sure that you have appropriate database library installed (psycopg2 for PostgreSQL, MySQLdb for MySQL, sqlite3 for SQLite).
db = web.database(dbn='postgres', db='dbname', user='username', pw='password')
dbn for MySQL is mysql and sqlite for SQLite. SQLite doesn’t take user pw parameters.
Multiple databases
Working with more databases is not at all difficult with web.py. Here’s what you do.
db1 = web.database(dbn='postgres', db='dbname1', user='username1', pw='password2')
db2 = web.database(dbn='postgres', db='dbname2', user='username2', pw='password2')
And use db1, db2 to access those databases respectively.
Operations
web.database() returns an object which provide you all the functionality to insert, select, update and delete data from your database. For each of the methods on db below, you can pass _test=True to see the SQL statement rather than executing it.
Inserting
# Insert an entry into table 'user'
userid = db.insert('user', firstname="Bob", lastname="Smith", joindate=web.SQLLiteral("NOW()"))
The first argument is the table name and the rest of them are set of named arguments which represent the fields in the table. If values are not given, the database may create default values or issue a warning.
For bulk insertion rather than inserting record by record, use Multiple Inserts rather.
Selecting
The select method is used for selecting rows from the database. It returns a web.iterbetter object, which can be looped through.
To select all the rows from the user table, you would simply do
users = db.select('user')
For the real world use cases, select method takes vars, what, where, order, group, limit, offset, and _test optional parameters.
users = db.select('users', where="id>100")
To prevent SQL injection attacks, you can use $key in where clause and pass the vars which has { ‘key’: value }.
vars = dict(name="Bob")
results = db.select('users', where="name = $name", vars=vars, _test=True)
>>> results
<sql: "SELECT * FROM users WHERE name = 'Bob'">
Updating
The update method accepts same kind of arguments as Select. It returns the number of rows updated.
num_updated = db.update('users', where="id = 10", firstname = "Foo")
Deleting
The delete method returns the number of rows deleted. It also accepts “using” and “vars” parameters. See Selecting
for more details on vars.
num_deleted = db.delete('users', where="id=10")
Multiple Inserts
The multiple_insert method on the db object allows you to do that. All that’s needed is to prepare a list of dictionaries, one for each row to be inserted, each with the same set of keys and pass it to multiple_insert along with the table name. It returns the list of ids of the inserted rows.
The value of db.supports_multiple_insert tells you if your database supports multiple inserts.
values = [{"name": "foo", "email"<EMAIL_ADDRESS>{"name": "bar", "email"<EMAIL_ADDRESS>db.multiple_insert('person', values=values)
Advanced querying
Many a times, there is more to do with the database, rather than the simple operations which can be done by insert, select, delete and update - Things like your favorite (or scary) joins, counts etc. All these are possible with query method, which also takes vars.
results = db.query("SELECT COUNT(*) AS total_users FROM users")
print results[0].total_users # prints number of entries in 'users' table
Joining tables
results = db.query("SELECT * FROM entries JOIN users WHERE entries.author_id = users.id")
Transactions
The database object has a method transaction which starts a new transaction and returns the transaction object. The transaction object can be used to commit or rollback that transaction. It is also possible to have nested transactions.
From Python 2.5 onwards, which support with statements, you would do
with db.transaction():
userid = db.insert('users', name='foo')
authorid = db.insert('authors', userid=userid)
For earlier versions of Python, you can do
t = db.transaction()
try:
userid = db.insert('users', name='foo')
authorid = db.insert('authors', userid=userid)
except:
t.rollback()
raise
else:
t.commit()


I am experienced in Node.js, JavaScript, and frontend.
In lectures I cover HTML, CSS, JavaScript, Node, D3, Web Sockets,
and Service Workers.
In open source I work with natural language and syntax trees.
I’ve written frontend applications with virtual DOM libraries and
Angular.
I often use Bash, Git, SASS, and LaTeX.
I’ve used Python, CoffeeScript, PHP, MySQL, and Cordova, and dabbled in
Rust and C.
Most importantly, I’ll learn anything I need to get something done.


Attention
Banh mi four dollar toast sriracha post-ironic, paleo meggings plaid yuccie PBR&B normcore lomo. Bitters umami shabby chic, kogi poutine kickstarter iPhone. Cornhole squid kickstarter godard, sustainable schlitz narwhal tacos aesthetic irony yr selfies +1 iPhone. Cred four loko literally listicle. Vice shoreditch chambray, +1 schlitz truffaut deep v drinking vinegar. Scenester trust fund shabby chic hella chambray, pour-over vinyl brunch microdosing meditation disrupt craft beer. Roof party PBR&B tilde pour-over kitsch tote bag godard, post-ironic kale chips salvia cornhole pinterest. Distillery narwhal street art, roof party master cleanse fashion axe intelligentsia listicle PBR&B gastropub lumbersexual hoodie kale chips craft beer. Scenester pickled yuccie, mustache readymade pitchfork normcore pour-over everyday carry cold-pressed farm-to-table. Narwhal pinterest post-ironic, tumblr ennui pabst beard whatever leggings godard vegan slow-carb next level pug. Taxidermy disrupt etsy tacos, kitsch chia kickstarter small batch pitchfork mustache art party yr ethical kombucha. Squid deep v etsy bushwick tousled celiac. Butcher trust fund mumblecore, williamsburg neutra ethical echo park slow-carb disrupt kinfolk brooklyn fanny pack leggings 8-bit. Sartorial portland authentic, direct trade wolf 3 wolf moon twee literally.


SUBJECT VIEW PAGE
Welcome
Questions
{{#questions}}
{{Question}}
{{/questions}}
Batches
{{#batches}}
Batch {{BatchId}} -- [{{Teachername}}]
{{/batches}}


EARTH SCIENCE IN THE SCIENTIFIC REVOLUTION 1600-1728
by
Yushi IT0, BSc(Tohoku), BA, MA, PhD coursework (Hiroshima) Department of History & Philosophy of Science
University of Melbourne
Submitted in accordance with the requirement for the degree of Doctor of Philosophy in the
University of Melbourne
February 1985
Reproduced with permission of the copyright owner. Further reproduction prohibited without permission.


Thank you for reporting an inappropriate group
We will take a look at the report you have submitted in line with our Terms and Conditions and reply to you within 10 working days.
SENDER: {{ name }}
EMAIL: {{ email }}
SUBJECT: {{ subject }}
MESSAGE: {{ message }}
FROM PAGE: https://www.stockport.gov.uk/groups/{{ slug }}


The first product lines to be renovated by Steve Jobs were the pro products, Power Mac and PowerBook, which he unveiled in November 1997, only eleven months after he came back. They were the first Macs to run the new Power PC G3 family of processors, from Motorola. They were relatively fast machines designed for creative professionals, which outperformed their Pentium-based competitors in many respects.


Timestamp Microservice
(Uses UTC instead of GMT)
https://timestamp-microservice-wcs.herokuapp.com/December%2015,%202015
https://timestamp-microservice-wcs.herokuapp.com/1450166400000
{
"unix":<PHONE_NUMBER>000,
"natural": "December 15, 2015"
}


Afterglow (1997, USA)
Written and directed by Alan Rudolph, produced by Robert Altman ,music by Mark Isham with Nick Nolte, Julie Christie, Lara Flynn Boyle and Johnny Lee Miller 110 minutes, 1:1.85
seen on the 9/18/1997 at the Astor, Berlin
Afterglow is Alan Rudolph's first film since the ambitious Mrs Parker and the Vicious Circle unfairly flopped in 1994. The American writer and director moves back to small-sized character-study, the genre he best knows and which brought him wide recognition with Choose Me (1984) and Trouble in Mind (1985).
Marianne (Flynn Boyle), the estranged wife of Montreal yuppie Jeffey Byron (Lee Miller), hires Lucky Fix-it Mann (Nolte) to make a baby's room - symbol! - in their modern but awful vast appartment. "Why a baby's room? We don't need a baby" says the selfish Jeffrey. "I'm having one, with or without you" argues Marianne. Oddly enough, this is where Lucky appears, and he offers pretty much everything she needs. Lucky's wife, Phyllis (Christie), is an aging former Hollywoodian actress, who keeps herself busy watching her own B-movies on TV, with her glasses on and a glass at reach, blaming herself for the departure of their twenty year old daughter. Guess what happens? While Lucky and Marianne are having good time, Jeffrey finds in Phyllis the motherly presence he ever waited for - the two of them meet at the Ritz hotel, which may or may not be owned by Mohammad Al-Fayed. They safely drive a Cadillac coupe, though I didn't see anyone wearing seatbelts.
It's such an inane script that even the great Max Ophuls wouldn't have saved it. A great disappointment, though Rudolph's style is still there and recognizable. Actors get the attention they deserve, but their parts are so thin that such first-class competitors can't produce sparkles.  I'm bully for Christie, but her return to the screen in her second major performance this year since her portrayal of Gertrude in Hamlet (1996) has this natural born actress in a freewheeling overdrive a la Dunaway. As for Nolte, his physical appearance reminded me of the late Lee Marvin - for the nose - and of Kriss Kritofferson, who was so impressing in Trouble in Mind. Nolte did not have the carreer we thought he might have deserved after seeing him in Who'll Stop the Rain (1974) and Underfire (1983). Fifty years ago he would have matched with Howard Hawks' characters. Now he's just wandering through Walter Hill's actioners and Barbra Streisand's disastrous directorial efforts. Too bad. Jeffrey is played by the talented British actor Johnny Lee Miller, and I'm sure all Trainspotting fans will witness that gaving up dying his hair in blond is not a great idea.
I'll give Rudolph another chance, but since Altman's own films are now taken away from him, I'm afraid he'll have to direct more Demi Moore vehicles.
(C) Vincent Merlaud 1997
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


Spark Configuration
Spark provides three main locations to configure the system:
- Java system properties, which control internal configuration parameters and can be set
either programmatically (by calling
System.setProperty
before creating aSparkContext
) or through JVM arguments. - Environment variables for configuring per-machine settings such as the IP address,
which can be set in the
conf/spark-env.sh
script. - Logging configuration, which is done through
log4j.properties
.
System Properties
To set a system property for configuring Spark, you need to either pass it with a -D flag to the JVM (for example java -Dspark.cores.max=5 MyProgram
) or call System.setProperty
in your code before creating your Spark context, as follows:
System.setProperty("spark.cores.max", "5")
val sc = new SparkContext(...)
Most of the configurable system properties control internal settings that have reasonable default values. However, there are at least five properties that you will commonly want to control:
| Property Name | Default | Meaning |
|---|---|---|
| spark.executor.memory | 512m |
Amount of memory to use per executor process, in the same format as JVM memory strings (e.g. 512m , 2g ).
|
| spark.serializer | org.apache.spark.serializer. JavaSerializer |
Class to use for serializing objects that will be sent over the network or need to be cached
in serialized form. The default of Java serialization works with any Serializable Java object but is
quite slow, so we recommend using org.apache.spark.serializer.KryoSerializer
and configuring Kryo serialization when speed is necessary. Can be any subclass of
org.apache.spark.Serializer .
|
| spark.kryo.registrator | (none) |
If you use Kryo serialization, set this class to register your custom classes with Kryo.
It should be set to a class that extends
KryoRegistrator .
See the tuning guide for more details.
|
| spark.local.dir | /tmp | Directory to use for "scratch" space in Spark, including map output files and RDDs that get stored on disk. This should be on a fast, local disk in your system. It can also be a comma-separated list of multiple directories on different disks. |
| spark.cores.max | (infinite) | When running on a standalone deploy cluster or a Mesos cluster in "coarse-grained" sharing mode, how many CPU cores to request at most. The default will use all available cores offered by the cluster manager. |
Apart from these, the following properties are also available, and may be useful in some situations:
| Property Name | Default | Meaning |
|---|---|---|
| spark.default.parallelism | 8 |
Default number of tasks to use for distributed shuffle operations (groupByKey ,
reduceByKey , etc) when not set by user.
|
| spark.storage.memoryFraction | 0.66 | Fraction of Java heap to use for Spark's memory cache. This should not be larger than the "old" generation of objects in the JVM, which by default is given 2/3 of the heap, but you can increase it if you configure your own old generation size. |
| spark.mesos.coarse | false | If set to "true", runs over Mesos clusters in "coarse-grained" sharing mode, where Spark acquires one long-lived Mesos task on each machine instead of one Mesos task per Spark task. This gives lower-latency scheduling for short queries, but leaves resources in use for the whole duration of the Spark job. |
| spark.ui.port | 4040 | Port for your application's dashboard, which shows memory and workload data |
| spark.ui.retained_stages | 1000 | How many stages the Spark UI remembers before garbage collecting. |
| spark.shuffle.compress | true | Whether to compress map output files. Generally a good idea. |
| spark.broadcast.compress | true | Whether to compress broadcast variables before sending them. Generally a good idea. |
| spark.rdd.compress | false |
Whether to compress serialized RDD partitions (e.g. for StorageLevel.MEMORY_ONLY_SER ).
Can save substantial space at the cost of some extra CPU time.
|
| spark.io.compression.codec | org.apache.spark.io. LZFCompressionCodec |
The compression codec class to use for various compressions. By default, Spark provides two
codecs: org.apache.spark.io.LZFCompressionCodec and org.apache.spark.io.SnappyCompressionCodec .
|
| spark.io.compression.snappy.block.size | 32768 | Block size (in bytes) used in Snappy compression, in the case when Snappy compression codec is used. |
| spark.scheduler.mode | FIFO |
The scheduling mode between
jobs submitted to the same SparkContext. Can be set to FAIR
to use fair sharing instead of queueing jobs one after another. Useful for
multi-user services.
|
| spark.reducer.maxMbInFlight | 48 | Maximum size (in megabytes) of map outputs to fetch simultaneously from each reduce task. Since each output requires us to create a buffer to receive it, this represents a fixed memory overhead per reduce task, so keep it small unless you have a large amount of memory. |
| spark.closure.serializer | org.apache.spark.serializer. JavaSerializer |
Serializer class to use for closures. Generally Java is fine unless your distributed functions (e.g. map functions) reference large objects in the driver program. |
| spark.kryo.referenceTracking | true | Whether to track references to the same object when serializing data with Kryo, which is necessary if your object graphs have loops and useful for efficiency if they contain multiple copies of the same object. Can be disabled to improve performance if you know this is not the case. |
| spark.kryoserializer.buffer.mb | 2 | Maximum object size to allow within Kryo (the library needs to create a buffer at least as large as the largest single object you'll serialize). Increase this if you get a "buffer limit exceeded" exception inside Kryo. Note that there will be one buffer per core on each worker. |
| spark.broadcast.factory | org.apache.spark.broadcast. HttpBroadcastFactory |
Which broadcast implementation to use. |
| spark.locality.wait | 3000 |
Number of milliseconds to wait to launch a data-local task before giving up and launching it
on a less-local node. The same wait will be used to step through multiple locality levels
(process-local, node-local, rack-local and then any). It is also possible to customize the
waiting time for each level by setting spark.locality.wait.node , etc.
You should increase this setting if your tasks are long and see poor locality, but the
default usually works well.
|
| spark.locality.wait.process | spark.locality.wait | Customize the locality wait for process locality. This affects tasks that attempt to access cached data in a particular executor process. |
| spark.locality.wait.node | spark.locality.wait | Customize the locality wait for node locality. For example, you can set this to 0 to skip node locality and search immediately for rack locality (if your cluster has rack information). |
| spark.locality.wait.rack | spark.locality.wait | Customize the locality wait for rack locality. |
| spark.worker.timeout | 60 | Number of seconds after which the standalone deploy master considers a worker lost if it receives no heartbeats. |
| spark.akka.frameSize | 10 |
Maximum message size to allow in "control plane" communication (for serialized tasks and task
results), in MB. Increase this if your tasks need to send back large results to the driver
(e.g. using collect() on a large dataset).
|
| spark.akka.threads | 4 | Number of actor threads to use for communication. Can be useful to increase on large clusters when the driver has a lot of CPU cores. |
| spark.akka.timeout | 20 | Communication timeout between Spark nodes, in seconds. |
| spark.driver.host | (local hostname) | Hostname or IP address for the driver to listen on. |
| spark.driver.port | (random) | Port for the driver to listen on. |
| spark.cleaner.ttl | (infinite) | Duration (seconds) of how long Spark will remember any metadata (stages generated, tasks generated, etc.). Periodic cleanups will ensure that metadata older than this duration will be forgetten. This is useful for running Spark for many hours / days (for example, running 24/7 in case of Spark Streaming applications). Note that any RDD that persists in memory for more than this duration will be cleared as well. |
| spark.streaming.blockInterval | 200 | Duration (milliseconds) of how long to batch new objects coming from network receivers. |
| spark.task.maxFailures | 4 | Number of individual task failures before giving up on the job. Should be greater than or equal to 1. Number of allowed retries = this value - 1. |
Environment Variables
Certain Spark settings can also be configured through environment variables, which are read from the conf/spark-env.sh
script in the directory where Spark is installed (or conf/spark-env.cmd
on Windows). These variables are meant to be for machine-specific settings, such
as library search paths. While Java system properties can also be set here, for application settings, we recommend setting
these properties within the application instead of in spark-env.sh
so that different applications can use different
settings.
Note that conf/spark-env.sh
does not exist by default when Spark is installed. However, you can copy
conf/spark-env.sh.template
to create it. Make sure you make the copy executable.
The following variables can be set in spark-env.sh
:
JAVA_HOME
, the location where Java is installed (if it’s not on your defaultPATH
)PYSPARK_PYTHON
, the Python binary to use for PySparkSPARK_LOCAL_IP
, to configure which IP address of the machine to bind to.SPARK_LIBRARY_PATH
, to add search directories for native libraries.SPARK_CLASSPATH
, to add elements to Spark’s classpath that you want to be present for all applications. Note that applications can also add dependencies for themselves throughSparkContext.addJar
– we recommend doing that when possible.SPARK_JAVA_OPTS
, to add JVM options. This includes Java options like garbage collector settings and any system properties that you’d like to pass with-D
(e.g.,-Dspark.local.dir=/disk1,/disk2
).- Options for the Spark standalone cluster scripts, such as number of cores to use on each machine and maximum memory.
Since spark-env.sh
is a shell script, some of these can be set programmatically – for example, you might
compute SPARK_LOCAL_IP
by looking up the IP of a specific network interface.
Configuring Logging
Spark uses log4j for logging. You can configure it by adding a log4j.properties
file in the conf
directory. One way to start is to copy the existing log4j.properties.template
located there.


Events
Blood, Sweat & Respect. The first two you give, the last one you earn.
WebEra
Command on the Web World, Presented by Department of Master of Computer Application Engineering. Day 2 Technical Event on 19th feb. Participate with Registration Fees 100 per individual & 150 per team. Contact to Umesh Pawar +919503054950.
QUERY MASTER
Just Trigger To Fire It, Presented by Department of Information Technology. Day 2 Technical Event on 19th feb. 2 Person Participation with Registration Fees 120 per team. Contact to Suraj Nanavare +919623299399.
CONCRETECH
Concrete Block Cum Exhibition, Presented by Department of Civil Engineering. Day 2 Technical Event on 19th Feb. 3 Person Participation with Registration Fees 200 per team. Contact to Upendra Kulkarni +918411045024.
EXPISCOR
Paper Presentation, Presented by Deparment of Electrical Engineering. Day 2 Technical Event on 19th Feb. 2 Person Participation with Registration Fees 150 per team. Contact to Mayur +918421820982.
TECHEXPO
Project Exhibition, Presented by Department of Electronics and Telecommunication. Day 2 Technical Event on 19th Feb.
2 Person Participation with Registration Fees 160 per team. Contact to Swapnil Kada +918983009191.
Catia Modelling
Create Wonders, Presented by Department of Mechanical Engineering. Day 1 Technical Event on 18th feb. 3 Person Participation with Registration Fees 150 per team. Contact to Altmash +919096744364.
Canon Shot
Shot for Glory, Presented by Department of Mechanical Engineering. Day 1 Technical Event on 18th feb. 2 Person Participation with Registration Fees 150 per team. Contact to Nagraj +917776070212.
ELECTROVISION
Visualize the world, Presented by Deparment of Electrical Engineering. Day 1 Technical Event on 18th feb. 2 Person Participation with Registration Fees 150 per team. Contact to Nikhil Patil +918421174858.
TRONIC HUNT
Happy Hunting, Presented by Department of Electronics and Telecommunication. Day 1 Technical Event on 18th Feb.
2 Person Participation with Registration Fees 160 per team. Contact to Rohan +917767863614.
Circuit-O-Vert
Circuit building event, Presented by Department of Electronics and Telecommunication. Day 1 Technical Event on 18th Feb.
2 Person Participation with Registration Fees 160 per team. Contact to Amol Kale +919673924975.
CODETRIX
Think Twice Code Once, Presented by Department of Information Technology. Day 1 Technical Event on 18th feb. 2 Person Participation with Registration Fees 120 per team. Contact to Mahesh More +917875151584.
STRUCTWELL
Beam Making, Presented by Department of Civil Engineering. Day 1 Technical Event on 18th Feb. 2 Person Participation with Registration Fees 200 per team. Contact to Shubham Bidkar +918380846321.
CIVIL MANIA
The Great Mingle, Presented by Department of Civil Engineering. Day 1 Technical Event on 18th Feb. 2 Person Participation with Registration Fees 200 per team. Contact to Shailesh Shelar +917757898237.
IntelloStruct
On spot model making, Presented by Department of Civil Engineering. Day 1 Technical Event on 18th Feb. 2 Person Participation with Registration Fees 150 per team. Contact to Aum Sai Krishna Gadi +917350370781.
PINNACLE
The Summit Within, Presented by Department of Information Technology. Day 1 Non-Technical Event on 18th Feb. *Registration Full*. Contact to Lucky Bajaj +919545301187.
QUIZ FEST
General Knowledge Quiz, Presented by Department of Master of Computer Application. Day 1 Non-Technical Event on 18th Feb. 2 Person Participation with Registration Fees 150 per team. Contact to Poonam Ghatge +917972567904
Rohit:<PHONE_NUMBER>.
ENGINEERING STUDENTS' PARLIAMENT
The Unconfined Right of Compelling. Day 1 Non-Technical Event on 18th feb. 2 Person Participation with Registration Fees 150 per team. Contact to Nikhil +919823035613.
MAKE A DIFFERENCE
Be the Change you want to see in the World. Day 2 Non-Technical Event on 19th Feb. 3 Person Participation with Registration Fees 150 per team. Contact to Shrinivas +919766100146.
KALAAVISHKAR
Painting Competition. Day 1 Non-Technical Event on 18th Feb. Single Person Participation with Registration Fees 100. Contact to Akshay +918379820735.
SNAP IT
Let the true colors shine through ur LENSES!! Day 1 Non-Technical Event on 18th Feb. Single Person Participation with Registration Fees 100. Contact to Pradhmesh Deshpande +919404299079.
C-Strike
Two Day gaming Event on 18th & 19th Feb. Max 4 person per team Participation with Registration Fees 200 per team. +919765419086.
Box Cricket
Day 1 Gaming Event on 18th Feb. *Registration Full*.Contact to Suraj Gadhave +917767094490.
About aavishkar
Those who want to achieve something, never point a finger at anybody, take the burden on their shoulder and carry it.
This event is conducted with great compassion and passion by GCEKians it is platform that provide the students a great place to show off their technical and professional knowledge and skills.
Aavishkar 2k17 is a event that put test to the wid, ability and talent of every individual who participate in it. Avishkar 2k17 is not a chance its an opportunity for every aspirer to get exposed to scrupulously conceded ideas loathed with technical knowledge.
Every year every GCEKian spents every last moment of his very life to produce an event which we call with gratitude Aavishkar for every tech lover to be part of an enjoy, which is made with every drop of over seat an every inch of our honour.
-
Organisation
-
Composure under Pressure
-
Ability to Listen
-
Attention to Detail


Super-Resolution can be defined as the area of study within machine learning that aims to enhance the quality of a given digital image by increasing its resolution. This is relevant because display resolution in TVs and phones has been going up, and there’s a lot of old multimedia content produced in lower resolutions.
Traditionally, image rescaling has been done utilising digital FIR filters such as box, triangle, Mitchell Netravali and Lanczos for nearest neighbour, bilinear, bicubic and windowed sinc scaling, respectively.
Convolutional Neural Networks have been eclipsing traditional methodologies in digital image processing, and several models have been proposed for the resolution upscaling problem such as SRCNN, FSRCNN, ESPCN and VSDR.
Traditional scaling filters such as Lanczos can interpolate existing information relatively well but they cannot recreate the lost high frequency components.
The absolute difference between an upscaled image and the ground truth is then defined as the residuals. Deep CNNs such as VDSR are designed to learn how to find residuals so they can be added back to the interpolation image in order to achieve a high-resolution recreation with higher fidelity than it would be otherwise possible. SRCNN, FSRCNN and ESPCN, on another hand, are designed to learn how to go from a low-resolution image to its high-resolution version directly, SRCNN utilises a bicubic interpolated image as its input, FSRCNN and ESPCN both receive the low-resolution image directly.
This study aims to not only review those networks but also propose a shallow CNN capable of achieving similar performance with shorter training time.
The simplest way of increasing the resolution of a digital image is to simply repeat its discrete values N^2 times for scaling factor N. This is called “Nearest Neighbour” and it is the cheapest algorithm you can implement computationally speaking. A single step further than that would be to interpolate existing values and create a straight line between them, do this for both axes and we have what we call “Bilinear” interpolation. If we want to increase the complexity again and draw more accurate curves, we can take more than 2 points into account and fit a polynomial curve into the existing discrete points, the most common techniques that do this are collectively called “Bicubic” interpolation.
Using other FIR filters is possible, the Lanczos filter is a popular approximation of the sinc function, the difference is that Lanczos is a sinc windowed by the first lobe or a larger sinc. The optimal reconstruction filter for band-limited signals is proven to be the sinc filter, but as a filter of infinite duration we can’t use it directly in real discrete systems. For this reason, several approximations have been proposed and the Lanczos kernel is one of them.
Don P. Mitchell and Arun N. Netravali, came out with a paper, Reconstruction Filters in Computer Graphics [1], which formulated two variables known as “B” (as used for 'B-spline' curves) and “C” (as used for the 'Cardinal' curves). The authors then conducted a survey to find the optimal parameters for a bicubic filter, which resulted in the Mitchell Netravali filter with B = C = 1/3. The following image displays the result of the survey.
If we downsample the popular picture of the Swedish model Lena Forsén using the Mitchell Netravali filter and a scaling factor of 0.5x, and then upsample it back up using the same filter (scaling factor 2x), we can see that the resulting image is considerably blurrier than the original.
Alternatively, it’s easier to see the difference if we look at the absolute difference between the images magnified by a factor of 10.
The difference between them, as explained before, is mostly contained in the high frequency components (the edges) that get lost when you downscale an image throwing away information. The act of upscaling can increase the number of pixels but we’re not creating new information, we’re merely interpolating already existing information to find new points in between the existing points in the low-resolution image. This phenomenon can also be observed in the frequency domain directly through the discrete Fourier transform, the following image displays the DFTs of both images side by side.
The human visual system has lower acuity for differences in colour than in luminance, this fact has motivated engineers to manipulate the data accordingly in order to save bandwidth and achieve reasonable quality at a fraction of the bitrate.
Chroma subsampling is the technique currently present in any modern video codec like H.265/HEVC, H.264/AVC, VP9 or AV1. Lossy still image codecs such as JPEG and WebP also implement chroma subsampling. The technique consists of literally having fewer samples for chromatic information, which is usually easier and more straightforward to do in the YCbCr channels.
The YCbCr family of colourspaces split the RGB data into a luminance channel (Y) and 2 chromatic channels (Cb and Cr). Video codecs almost always use the “4:2:0” scheme which simply means the chromatic channels are of a quarter of the full luma resolution.
RGB Lena:
YCbCr Lena:
Understanding that the human visual system is more sensitive to luminance information is important because it allows us to focus solely on the luma plane when spending computational power trying to resample a given image accurately. For this reason, all networks described above only upsample the Luma frame, chromatic information is handled by the conventional FIR filters.
SRCNN [2] stands for Super-Resolution Convolutional Neural Network, and it’s one of the first works in this area. The model receives a bicubic interpolated image as its input, goes through a 9x9 convolutional layer with 64 filters called “feature extraction”, then through a 1x1 convolutional layer called “non-linear mapping” with 32 filters and then it attempts to reconstruct the high-resolution image with a final 5x5 convolution with a single filter.
Since attempting to reconstruct an image is essentially a regression task with multiple outputs, the mean-squared-error loss function was chosen.
The following images showcase the results obtained by the original authors.
SRCNN achieved a PSNR (peak-signal to noise ratio) score of almost 4 dB higher than bicubic interpolation, what the neural network uses as its input, but this came after 12\bullet{10}^8 backpropagations and a training time of weeks to fine tune the layers [2].
FSRCNN [3] stands for Fast Super-Resolution Convolutional Neural Network, and it came as an attempt to make SRCNN faster through modifications to its structure. The major difference between the two is that FSRCNN receives the original low-resolution image as its input, introducing a transposed convolution at the end that increases the scale to the target resolution. The new network also replaces the larger filters by a series of smaller 3x3 convolutional layers that end up with the same receptive field but with fewer trainable weights [4].
The interesting thing about the transposed convolution is that the scale factor simply becomes the stride of last layer, which means it’s possible to reuse the previous layers and only retrain the last one for a different scaling factor.
The new model achieves much better runtime performance when compared to SRCNN, the smaller dimension of the LR images coupled with the smaller 3x3 filters allow FSRCNN to be orders of magnitude faster [3]. When it comes to the output’s fidelity, the new model also achieves comparable or better image quality.
Despite offering better runtime performance, FSRCNN still requires considerable training time to fine-tune the final transposed convolution layer (the authors use a learning rate of 0.0001) [3].
ESPCN [5] stands for Efficient Sub-Pixel Convolutional Neural Network, and it came as a novel alternative to the transposed convolution layer introduced before. The key difference this time is that this network reconstructs the high-resolution image rearranging several channels into a single larger channel in a “depth-to-space” operation.
The advantage when compared to the transposed convolution used in FSRCNN is that the channels are generated separately before they’re reconstructed into a single image, which means the network is capable of learning more quickly since it has better control of the artifacts it’s producing in its output.
Both ESPCN and FSRCNN are orders of magnitude faster than SRCNN since they take low-resolution images as their inputs and employ several layers in series with smaller 3x3 kernels. Unfortunately, the authors also claim their training time took a week on a Nvidia K2 GPU with 91 images as a training set.
VDSR [6] stands for Very Deep Super-Resolution, and despite having “very deep” in its name this fact isn’t necessarily what differentiates it the most compared to the previous models. SRCNN, FSRCNN and ESPCN all get better with more layers, but the prohibitive factor was training time to achieve convergence on a deeper model. VDSR solves this issue by capitalising on the already existing knowledge of image processing, as explained before, the difference between an interpolated low-resolution image and a real high-resolution image is in the high frequency components and we can call it the residuals, so instead of attempting to recreate the high-resolution image entirely the network attempts to recreate said residuals [6].
This simple yet effective fact is what allows VDSR to be trained in a much shorter period of time compared to the previous models. The authors claim training finished after only 4 hours on a Nvidia Titan Z, or 80 epochs (9960 iterations with batch size 64). This number is interesting because it proves brute forcing a problem is not always fruitful, the original SRCNN authors dismissed deeper networks for super-resolution due to the fact that they couldn’t get it to converge on a reasonable amount of time, resulting in weaker models with poor performance [2], [6].
VDSR is also the first network to include SSIM (structural similarity) metrics since the difference in PSNR scores might not give a clear picture on reconstruction quality.
We can see that the lines and edges generated from the deeper VDSR network are of much better perceptual quality with fewer aliasing artifacts.
If we simply take VDSR’s model, reduce the number of filters per layer and make it less deep, we arrive at a model that, theoretically speaking, can be trained relatively quickly due to the intrinsic residual approach.
If we replace the interpolated input with a low-resolution input and introduce the “Sub-Pixel Convolution” layer (the depth-to-space operation from ESPCN [5]) at the end we can make it even faster due to the reduced dimensions throughout the network. ESPCN’s authors remind us through their paper that training time is still long for their network employing the “sub-pixel” convolution. But theirs generate the high-resolution prediction directly, the aim here is to evaluate whether we can make it converge more quickly if we make it generate the residuals instead.
Unlike the original VDSR, this model upsamples the input using the Lanczos filter due to its higher reconstruction fidelity when compared to bicubic filters. The images were previously downsampled using the Catmull-Rom filter, the sharpest key bicubic filter considered to be a good compromise by the Mitchell-Netravali survey. Lanczos was not chosen as the downsampling filter because bicubic interpolation is the “industry standard” when it comes to downsampling and experiments showed the difference was within the margin of error. The following table shows the mean PSNR scores for several FIR filters when upsampling the entire training set by a scaling factor of 2x.
The scaling factor 2x was chosen instead of 3x because the interpolated LR input image is closer in structure to the HR ground-truth, meaning that the residuals the network needs to learn are less complex, making convergence easier to achieve.
A SP-VDSR network with 5 convolutional layers of 8 3x3 filters each and a final “Sub-Pixel Convolutional” layer was then trained with 32 images of line-art drawings extracted from animated content. Line-art was chosen due to the lower high-frequency complexity compared to live-action images.
Training was done with 3600 epochs and batch size of 32. The Adam optimiser’s learning rate is set to drop progressively but the minimum value it can achieve is set to 0.0001. Leaky ReLU was used because residuals can have negative values and the change showed faster convergence. A canonical VDSR with the same depth was also trained for comparison purposes. The networks were trained for roughly an hour to show the advantage of using the depth-to-space operation to reduce the network’s dimensions allowing it to go through more epochs in the same period of time.
The modified network, which is a hybrid between VDSR [6] and ESPCN [5], was named “SP-VDSR” (Sub-Pixel-Very-Deep-Super-Resolution) and its architecture is described in the following image. The variant tested is shallow and only has 5 convolutional layers.
The network matched the Lanczos very quickly, apparently reaching a local minimum that lasted for approximately 200 epochs before it found a way to increase the quality again. The final average PSNR score was 44.86 dB after an hour. The network was also trained with bilinear and bicubic interpolation for comparison purposes, and we can see that despite the initial discrepancies all models converged to similar results. Feeding Lanczos interpolated images to the network resulted in a PSNR that’s 0.364 dB higher than doing the same with bilinear interpolated images.
The quality results can then be shown in the figure below using a line-art test image. It’s easy to see the neural network learnt how to sharpen lines and make them look less blurry, achieving a PSNR score 3.68 dB higher than the Lanczos interpolated image it used as its input. Since the network is designed to only receive the luminance channel, chroma was upsampled by the same Lanczos filter before rearranging the YCbCr image into RGB.
Direct comparisons with the other works are impossible due to hardware limitations. I do not have direct access to an Nvidia GPU to allow a model to be trained for longs periods of time with CUDA acceleration. Support for OpenCL is bad within the big machine learning so the chosen solution was to train the models on the Google Colab platform using their cloud GPUs and attempt to help the network’s performance with clever modifications.
The proposed model, SP-VDSR, displayed faster training epoch time and better quality for the same training time. Reducing the resolution of the convolutional layers to a quarter of their original size (for a 2x scaling factor) resulted in an epoch time of 1 second, going down from 3 seconds for the original VDSR model (which was trained for 1200 epochs to match the other network in training time, achieving 41.50 dB on the same training dataset).
A deep SP-VDSR can be explored so it can be more directly compared to the canonical VDSR in [6]. This study reinforces the idea that residual networks converge more quickly as claimed in [6], even when the depth-to-space “sub-pixel convolution” from [5] is used to upsample the residuals.
The loss function can also be modified, MSE is a good metric to find the absolute difference between the predicted image and the ground truth, but it does not give enough emphasis to the high frequency components the network is supposed to reconstruct [7], [8]. The gradient sensitive loss described in [7] is an interesting choice to be evaluated. This loss function extracts the edges from the images using the Sobel filter and then derives a mask to segment low-frequency and high-frequency information, which are then weighted to make the network give more emphasis to learning how to reconstruct the edges. Other studies, like [8], suggest using structural similarity indexes directly alongside MSE.
Generative adversarial networks, residual networks and attention-based networks aimed at the super-resolution problem have also emerged. RDN [9], ESRGAN [10] and RealSR [11] all achieve higher perceptual quality than conventional feed-forward CNNs, but those networks are deeper and more complex. Future works can explore how to accelerate GANs with the same techniques described in this article. A fast Super-Resolution network could also be implemented in hardware to upsample old multimedia content in real-time.
[1] ‘Reconstruction filters in computer-graphics | ACM SIGGRAPH Computer Graphics’. https://dl.acm.org/doi/10.1145/378456.378514 (accessed Dec. 14, 2020).
[2] C. Dong, C. C. Loy, K. He, and X. Tang, ‘Image Super-Resolution Using Deep Convolutional Networks’, Dec. 2014, Accessed: Dec. 15, 2020. [Online]. Available: https://arxiv.org/abs/1501.00092v3.
[3] C. Dong, C. C. Loy, and X. Tang, ‘Accelerating the Super-Resolution Convolutional Neural Network’, Aug. 2016, Accessed: Dec. 15, 2020. [Online]. Available: https://arxiv.org/abs/1608.00367v1.
[4] K. Simonyan and A. Zisserman, ‘Very Deep Convolutional Networks for Large-Scale Image Recognition’, Sep. 2014, Accessed: Dec. 15, 2020. [Online]. Available: https://arxiv.org/abs/1409.1556v6.
[5] W. Shi et al., ‘Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network’, Sep. 2016, Accessed: Dec. 15, 2020. [Online]. Available: https://arxiv.org/abs/1609.05158v2.
[6] J. Kim, J. K. Lee, and K. M. Lee, ‘Accurate Image Super-Resolution Using Very Deep Convolutional Networks’, Nov. 2015, Accessed: Dec. 15, 2020. [Online]. Available: https://arxiv.org/abs/1511.04587v2.
[7] ‘[1809.07099] Dual Reconstruction Nets for Image Super-Resolution with Gradient Sensitive Loss’. https://arxiv.org/abs/1809.07099 (accessed Dec. 17, 2020).
[8] H. Zhao, O. Gallo, I. Frosio, and J. Kautz, ‘Loss Functions for Image Restoration With Neural Networks’, IEEE Trans. Comput. Imaging, vol. 3, no. 1, pp. 47–57, Mar. 2017, doi: 10.1109/TCI.2016.2644865.
[9] Y. Zhang, Y. Tian, Y. Kong, B. Zhong, and Y. Fu, ‘Residual Dense Network for Image Super-Resolution’, ArXiv180208797 Cs, Mar. 2018, Accessed: Dec. 19, 2020. [Online]. Available: http://arxiv.org/abs/1802.08797.
[10] X. Wang et al., ‘ESRGAN: Enhanced Super-Resolution Generative Adversarial Networks’, ArXiv180900219 Cs, Sep. 2018, Accessed: Dec. 17, 2020. [Online]. Available: http://arxiv.org/abs/1809.00219.
[11] X. Ji, Y. Cao, Y. Tai, C. Wang, J. Li, and F. Huang, ‘Real-World Super-Resolution via Kernel Estimation and Noise Injection’, 2020, pp. 466–467, Accessed: Dec. 16, 2020. [Online]. Available: https://openaccess.thecvf.com/content_CVPRW_2020/html/w31/Ji_Real-World_Super-Resolution_via_Kernel_Estimation_and_Noise_Injection_CVPRW_2020_paper.html.


Compare pollination management scenarios
Learn how to integrate managed and wild pollination on your farm in five simple steps using the Pollination Mapper BETA tool:
- Zoom in to your farm using the map on the left.
- Outline your crop field.
- Update the current crop map.
- Create pollination management scenarios by adjusting honey bee stocking rates and/or the size and location of pollinator plantings on your farm.
- Compare how different scenarios impact your crop’s pollination and yield.
This Help Page will walk you through the process in more detail.


Header one
Header two
Header three
Header four
Header five
Header six
Header one ( no spacing )
Header one ( normal )
Header one ( uppercase )
Header one ( bold )
Header one ( italic )
Header one ( no italic )
Header one ( underline )
Header one ( tiny )
Header one ( color primary )
Header one ( color highlight )
Header one ( color sub )
Header one ( color white )
Super/Duper/Long/NonBreaking/Path/Name/To/A/File/That/Is/Way/Deep/Down/In/Some/Mysterious/Remote/Desolate/Part/Of/The/Operating/System/To/A/File/That/Just/So/Happens/To/Be/Strangely/Named/Supercalifragilisticexpialidocious.txt
Stay hungry. Stay foolish.
Multi line blockquote with a cite reference:
People think focus means saying yes to the thing you’ve got to focus on. But that’s not what it means at all. It means saying no to the hundred other good ideas that there are. You have to pick carefully. I’m actually as proud of the things we haven’t done as the things I have done. Innovation is saying no to 1,000 things. Steve Jobs – Apple Worldwide Developers’ Conference, 1997
Tables
| Employee | Salary | |
|---|---|---|
| John Saddington | $1 | Because that’s all Steve Job’ needed for a salary. |
| Tom McFarlin | $100K | For all the blogging he does. |
| Jared Erickson | $100M | Pictures are worth a thousand words, right? So Tom x 1,000. |
| Chris Ames | $100B | With hair like that?! Enough said… |
- Above the comments
- Below the comments
- Included within the normal flow of comments
- Above the comments
- Below the comments
- Included within the normal flow of comments
- Above the comments
- Below the comments
- Included within the normal flow of comments
- Above the comments
- Below the comments
- Included within the normal flow of comments
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. This is link.
Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Cras mattis consectetur purus sit amet fermentum. Donec id elit non mi porta gravida at eget metus.
Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Aenean lacinia bibendum nulla sed consectetur. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Nullam quis risus eget urna mollis ornare vel eu leo. Integer posuere erat a ante venenatis dapibus posuere velit aliquet.
$: > Booting systems... $: > Total memory found: 256kb $: > Scanning for bootable media ------------ 100% $: > No media found. Booting from network address 3E:40:9C:75 $: > Loading BIOS 2.3 ------------ 100% $: > Reticulating splines ------------ 100% $: > Booting console ------------ 100%
#wrapper {
padding:5%;
margin:0 auto;
}
#wrapper {
padding:5%;
margin:0 auto;
}
Centering Container
Automatically centers the container box by adjusting the left and right margin values equally on each side.
Tiny Container
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.
S Container
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.
M Container
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
L Container
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
Max-width(Default), Max-width(XL), Max-width(XXL) Container
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
100% Width
Using .container-fluid
for width: 100% across all viewport and device sizes.
Column
It can be used for fluid layout for multiple projects and Bootstrap grid system. Its biggest feature is its support for loop lists.
One Fifth
Still keep 5 columns when small screen.
One Fifth
Still keep 5 columns when small screen.
One Fifth
Still keep 5 columns when small screen.
One Fifth
Still keep 5 columns when small screen.
One Fifth
Still keep 5 columns when small screen.
One Fourth (1)
Keep 1 columns when small screen < 768px
.
One Fourth (2)
Keep 1 columns when small screen < 768px
.
One Fourth (3)
Keep 1 columns when small screen < 768px
.
One Fourth (4)
Keep 1 columns when small screen < 768px
.
One Fifth
Keep 1 columns when small screen < 768px
.
Four Fifth
Keep 1 columns when small screen < 768px
.
One Fourth (1)
Keep 2 columns when small screen < 992px
.
One Fourth (2)
Keep 2 columns when small screen < 992px
.
One Fourth (3)
Keep 2 columns when small screen < 992px
.
One Fourth (4)
Keep 2 columns when small screen < 992px
.
One Third
Keep 1 columns when small screen < 768px
.
One Third
Keep 1 columns when small screen < 768px
.
One Third
Keep 1 columns when small screen < 768px
.
One Half
Always keep 2 columns
Just use the class prefix .col-
One Half
Always keep 2 columns
Just use the class prefix .col-
One Half
Keep 1 columns when small screen < 992px
.
One Half
Keep 1 columns when small screen < 992px
.
One Third
Keep 1 columns when small screen < 992px
.
Two Third
Keep 1 columns when small screen < 992px
.
Two Third
Keep 1 columns when small screen < 992px
.
One Third
Keep 1 columns when small screen < 992px
.
One Fourth
Keep 1 columns when small screen < 992px
.
Three Fourth
Keep 1 columns when small screen < 992px
.
Three Fourth
Keep 1 columns when small screen < 992px
.
One Fourth
Keep 1 columns when small screen < 992px
.
One Third (1)
Keep 1 columns when small screen < 992px
.
One Third (1)
Keep 2 columns when small screen < 992px
.
Keep 1 columns when small screen < 576px
.
One Third (1)
Keep 2 columns when small screen < 992px
.
Keep 1 columns when small screen < 576px
.
Column (No line breaks)
Please simulate mobile viewing after zooming out your viewport.
One Fourth (1)
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
One Fourth (2)
Aliquam congue dignissim tellus, vel eleifend urna rutrum nec.
One Fourth (3)
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
One Fourth (4)
Morbi et mauris vitae quam venenatis imperdiet.
One Third
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
One Third
Aliquam congue dignissim tellus, vel eleifend urna rutrum nec.
One Third
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Center Column
The class .align-items-center
or .justify-content-center
used here will be applied .row
One Fourth (1)
Aliquam congue dignissim tellus, vel eleifend urna rutrum nec. Morbi et mauris vitae quam venenatis imperdiet. Proin et rutrum magna. Nulla sed venenatis leo. Suspendisse potenti. Proin faucibus cursus luctus.
One Fourth (2)
Aliquam congue dignissim tellus, vel eleifend urna rutrum nec. Morbi et mauris vitae quam venenatis imperdiet. Proin et rutrum magna. Nulla sed venenatis leo. Suspendisse potenti. Proin faucibus cursus luctus.
One Fourth (1)
Aliquam congue dignissim tellus, vel eleifend urna rutrum nec. Morbi et mauris vitae quam venenatis imperdiet. Proin et rutrum magna. Nulla sed venenatis leo. Suspendisse potenti. Proin faucibus cursus luctus.
One Fourth (2)
Vertical Centering
One Third
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris a mi ac diam varius commodo sit amet a eros. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.


The Akan people of Ghana frequently name their children after the day of the week they were born and the order in which they were born. These "day names" have further meanings concerning the soul and character of the person. Middle names have considerably more variety and can refer to their birth order, twin status, or an ancestor's middle name.
This naming tradition is shared throughout West Africa and the African diaspora. During the 18th–19th centuries, enslaved people in the Caribbean from the region that is modern-day Ghana were referred to as Coromantees. Many of the leaders of enslaved people’s rebellions had "day names" including Cuffy, Cuffee or Kofi, Cudjoe or Kojo, Quao or Quaw, and Quamina or Kwame/Kwamina.
Most people do know when their birthdays are, but some might not know what day of the week they were born. Luckily for us, there are ways to calculate the day of the week from a specific date.
Do you belong to the Akan Community?
Well, this web application will help you know which day you were born.
Go ahead and submit your details below!


| Routine | Description | |
| real | complex | |
| SLAED5 | Used by SSTEDC. Solves the 2-by-2 secular equation. | |
| SLAED6 | Used by SSTEDC. Computes one Newton step in solution of secular equation. | |
| SLAED7 | CLAED7 | Used by SSTEDC. Computes the updated eigensystem of a diagonal matrix after modification by a rank-one symmetric matrix. Used when the original matrix is dense. |
| SLAED8 | CLAED8 | Used by xSTEDC. Merges eigenvalues and deflates secular equation. Used when the original matrix is dense. |
| SLAED9 | Used by SSTEDC. Finds the roots of the secular equation and updates the eigenvectors. Used when the original matrix is dense. | |
| SLAEDA | Used by SSTEDC. Computes the Z vector determining the rank-one modification of the diagonal matrix. Used when the original matrix is dense. | |
| SLAEIN | CLAEIN | Computes a specified right or left eigenvector of an upper Hessenberg matrix by inverse iteration. |
| SLAEV2 | CLAEV2 | Computes the eigenvalues and eigenvectors of a 2-by-2 symmetric/Hermitian matrix. |
| SLAEXC | Swaps adjacent diagonal blocks of a real upper quasi-triangular matrix in Schur canonical form, by an orthogonal similarity transformation. | |
| SLAG2 | Computes the eigenvalues of a 2-by-2 generalized eigenvalue problem , with scaling as necessary to avoid over-/underflow. | |
| SLAGS2 | Computes 2-by-2 orthogonal matrices U, V, and Q, and applies them to matrices A and B such that the rows of the transformed A and B are parallel. | |
| SLAGTF | Computes an LU factorization of a matrix , where T is a general tridiagonal matrix, and a scalar, using partial pivoting with row interchanges. | |
| SLAGTM | CLAGTM | Performs a matrix-matrix product of the form , where A is a tridiagonal matrix, B and C are rectangular matrices, and and are scalars, which may be 0, 1, or -1. |
| SLAGTS | Solves the system of equations or , where T is a general tridiagonal matrix and a scalar, using the LU factorization computed by SLAGTF. | |
| SLAGV2 | Computes the Generalized Schur factorization of a real 2-by-2 matrix pencil (A,B) where B is upper triangular. | |
| SLAHQR | CLAHQR | Computes the eigenvalues and Schur factorization of an upper Hessenberg matrix, using the double-shift/single-shift QR algorithm. |
| SLAHRD | CLAHRD | Reduces the first nb columns of a general rectangular matrix A so that elements below the kth subdiagonal are zero, by an orthogonal/unitary transformation, and returns auxiliary matrices which are needed to apply the transformation to the unreduced part of A. |
| SLAIC1 | CLAIC1 | Applies one step of incremental condition estimation. |
| Routine | Description | |
| real | complex | |
| SLARFX | CLARFX | Applies an elementary reflector to a general rectangular matrix, with loop unrolling when the reflector has order . |
| SLARGV | CLARGV | Generates a vector of plane rotations with real cosines and real/complex sines. |
| SLARNV | CLARNV | Returns a vector of random numbers from a uniform or normal distribution. |
| SLARRB | Given the relatively robust representation(RRR) L D LT, SLARRB does ``limited'' bisection to locate the eigenvalues of L D LT, W(IFIRST) through W(ILAST), to more accuracy. | |
| SLARRE | Given the tridiagonal matrix T, SLARRE sets ``small'' off-diagonal elements to zero, and for each unreduced block Ti, it finds the numbers , the base representations and the eigenvalues of each Li Di LiT. | |
| SLARRF | Finds a new relatively robust representation such that at least one of the eigenvalues of L(+) D(+) L(+)T is relatively isolated. | |
| SLARRV | CLARRV | Computes the eigenvectors of the tridiagonal matrix T = L D LT given L, D and the eigenvalues of L D LT. |
| SLARTG | CLARTG | Generates a plane rotation with real cosine and real/complex sine. |
| SLARTV | CLARTV | Applies a vector of plane rotations with real cosines and real/complex sines to the elements of a pair of vectors. |
| SLARUV | Returns a vector of n random real numbers from a uniform (0,1) distribution (). | |
| SLARZ | CLARZ | Applies an elementary reflector (as returned by xTZRZF) to a general matrix. |
| SLARZB | CLARZB | Applies a block reflector or its transpose/conjugate-transpose to a general matrix. |
| SLARZT | CLARZT | Forms the triangular factor T of a block reflector H = I - V T VH. |
| SLAS2 | Computes the singular values of a 2-by-2 triangular matrix. | |
| SLASCL | CLASCL | Multiplies a general rectangular matrix by a real scalar defined as cto/cfrom. |
| SLASD0 | Used by SBDSDC. Computes via a divide and conquer method the singular values of a real upper bidiagonal n-by-m matrix with diagonal D and offdiagonal E, where M = N + SQRE. | |
| SLASD1 | Used by SBDSDC. Computes the SVD of an upper bidiagonal N-by-M matrix, where N = NL + NR + 1 and M = N + SQRE. | |
| SLASD2 | Used by SBDSDC. Merges the two sets of singular values together into a single sorted set, and then it tries to deflate the size of the problem. | |
| SLASD3 | Used by SBDSDC. Finds all the square roots of the roots of the secular equation, as defined by the values in D and Z, and then updates the singular vectors by matrix multiplication. |
| Routine | Description | |
| real | complex | |
| SLASD4 | Used by SBDSDC. Computes the square root of the I-th updated eigenvalue of a positive symmetric rank-one modification to a positive diagonal matrix. | |
| SLASD5 | Used by SBDSDC. Computes the square root of the I-th eigenvalue of a positive symmetric rank-one modification of a 2-by-2 diagonal matrix. | |
| SLASD6 | Used by SBDSDC. Computes the SVD of an updated upper bidiagonal matrix obtained by merging two smaller ones by appending a row. | |
| SLASD7 | Used by SBDSDC. Merges the two sets of singular values together into a single sorted set, and then it tries to deflate the size of the problem. | |
| SLASD8 | Used by SBDSDC. Finds the square roots of the roots of the secular equation, and stores, for each element in D, the distance to its two nearest poles (elements in DSIGMA). | |
| SLASD9 | Used by SBDSDC. Finds the square roots of the roots of the secular equation, and stores, for each element in D, the distance to its two nearest poles (elements in DSIGMA). | |
| SLASDA | Used by SBDSDC. Computes the singular value decomposition (SVD) of a real upper bidiagonal N-by-M matrix with diagonal D and offdiagonal E, where M = N + SQRE. | |
| SLASDQ | Used by SBDSDC. Computes the singular value decomposition (SVD) of a real (upper or lower) bidiagonal matrix with diagonal D and offdiagonal E, accumulating the transformations if desired. | |
| SLASDT | Used by SBDSDC. Creates a tree of subproblems for bidiagonal divide and conquer. | |
| SLASET | CLASET | Initializes the off-diagonal elements of a matrix to and the diagonal elements to . |
| SLASQ1 | Used by SBDSQR. Computes the singular values of a real n-by-n bidiagonal matrix with diagonal D and offdiagonal E. | |
| SLASQ2 | Used by SBDSQR and SSTEGR. Computes all the eigenvalues of the symmetric positive definite tridiagonal matrix associated with the qd array Z to high relative accuracy. | |
| SLASQ3 | Used by SBDSQR. Checks for deflation, computes a shift (TAU) and calls dqds. | |
| SLASQ4 | Used by SBDSQR. Computes an approximation TAU to the smallest eigenvalue using values of d from the previous transform. | |
| SLASQ5 | Used by SBDSQR and SSTEGR. Computes one dqds transform in ping-pong form. | |
| SLASQ6 | Used by SBDSQR and SSTEGR. computes one dqds transform in ping-pong form. | |
| SLASR | CLASR | Applies a sequence of plane rotations to a general rectangular matrix. |


8 RDF Views: Relational Data as RDF
You can create and use RDF views over relational data in Oracle Spatial and Graph RDF Semantic Graph.
Relational data is viewed as virtual RDF triples using one of the two forms of RDB2RDF mapping described in W3C documents on Direct Mapping and R2RML mapping:
-
R2RML: RDB to RDF Mapping Language, W3C Recommendation (
http://www.w3.org/TR/r2rml/
) -
A Direct Mapping of Relational Data to RDF, W3C Recommendation (
http://www.w3.org/TR/rdb-direct-mapping/
)
Topics:
- Why Use RDF Views on Relational Data?
Using RDF views on relational data enables you to integrate data available from different sources. - API Support for RDF Views
Subprograms are included in the SEM_APIS package for creating, dropping, and exporting (that is, materializing the content of) RDF views. - Example: Using an RDF View with Direct Mapping
This topic provides an example of using an RDF view with direct mapping. - Combining Native RDF Data with Virtual RDB2RDF Data
You can combine native triple data with virtual RDB2RDF triple data in a single SEM_MATCH query by means of the SERVICE keyword.
8.1 Why Use RDF Views on Relational Data?
Using RDF views on relational data enables you to integrate data available from different sources.
You can exploit the advantages of relational data without the need for physical storage of the RDF triples that correspond to the relational data. Before RDF views were included in RDF Semantic Graph in Oracle Database 12c Release 1 (12.1), you needed to write custom SQL queries or use non-standard mappings and physically store the generated RDF triples in an RDF model.
The simplest way to create a mapping of relational data to RDF data is by calling the SEM_APIS.CREATE_RDFVIEW_MODEL procedure to create an RDF view and supplying the list of tables or views whose content you would like to be viewed as RDF. This provides a direct mapping of those relational tables or views.
To get a more customized mapping, you can write an R2RML mapping document (in RDF using Turtle, for example) to specify the desired mapping, load the mapping document (after converting it to N-Triple format) into a staging table (for the table definition, see Bulk Loading Semantic Data Using a Staging Table), and then call the SEM_APIS.CREATE_RDFVIEW_MODEL procedure to create an RDF view by supplying the name of the staging table.
8.2 API Support for RDF Views
Subprograms are included in the SEM_APIS package for creating, dropping, and exporting (that is, materializing the content of) RDF views.
An RDF view is created as an RDF model, but the RDF model physically contains only metadata. The actual data is still stored in the relational tables for which the RDF view has been created. (The SEM_APIS subprograms are documented in SEM_APIS Package Subprograms.)
For the examples in the rest of this section, assume that the following relational tables exist in the invoker's schema:
CREATE TABLE dept ( deptno NUMBER CONSTRAINT pk_DeptTab_deptno PRIMARY KEY, dname VARCHAR2(30), loc VARCHAR2(30) ); CREATE TABLE emp ( empno NUMBER PRIMARY KEY, ename VARCHAR2(30), job VARCHAR2(20), deptno NUMBER REFERENCES dept (deptno) );
Note that if these tables are in a different schema (for example, SCOTT
) than the invoker's, when specifying the names of these tables, you need to use schema-qualified table names: "SCOTT"."DEPT"
and "SCOTT"."EMP"
.
Topics:
8.2.1 Creating an RDF View with Direct Mapping
Example 8-1 creates an RDF view model using direct mapping of two tables, EMP and DEPT, with a base prefix of http://empdb/
. The (virtual) RDF terms are generated according to A Direct Mapping of Relational Data to RDF, W3C Recommendation (http://www.w3.org/TR/rdb-direct-mapping/
).
Example 8-1 Creating an RDF View with Direct Mapping
BEGIN sem_apis.create_rdfview_model( model_name => 'empdb_model', tables => SYS.ODCIVarchar2List('EMP', 'DEPT'), prefix => 'http://empdb/', options => 'KEY_BASED_REF_PROPERTY=T' ); END; /
To see the properties that are generated, enter the following statement (which assumes that the objects are created in the schema of a user named TESTUSER):
SELECT DISTINCT p FROM TABLE(SEM_MATCH( '{?s ?p ?o}', SEM_Models('empdb_model'), NULL, NULL, NULL)); P -------------------------------------------------------------------------------- http://empdb/TESTUSER.EMP#DEPTNO http://empdb/TESTUSER.DEPT#LOC http://empdb/TESTUSER.EMP#JOB http://empdb/TESTUSER.DEPT#DEPTNO http://empdb/TESTUSER.EMP#ENAME http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://empdb/TESTUSER.DEPT#DNAME http://empdb/TESTUSER.EMP#EMPNO http://empdb/TESTUSER.EMP#ref-DEPTNO 9 rows selected.
Example 8-2 Using CONFORMANCE=T
Example 8-2 is essentially the same as Example 8-1, but it uses the CONFORMANCE=T
option (see the options
parameter description for SEM_APIS.CREATE_RDFVIEW_MODEL). Notice in the output that the schema name is not included in the list of properties; for example, the first output record in Example 8-2 is http://empdb/DEPT#LOC
, whereas its counterpart generated by Example 8-1 is http://empdb/TESTUSER.DEPT#LOC
.
BEGIN
sem_apis.create_rdfview_model(
model_name => 'empdb_model',
tables => SYS.ODCIVarchar2List('EMP', 'DEPT'),
prefix => 'http://empdb/',
options => 'CONFORMANCE=T'
);
END;
/
SELECT DISTINCT p
FROM TABLE(SEM_MATCH(
'{?s ?p ?o}',
SEM_Models('empdb_model'),
NULL,
NULL,
NULL));
P
--------------------------------------------------------------------------------
http://empdb/DEPT#LOC
http://empdb/EMP#ref-DEPTNO
http://empdb/EMP#ENAME
http://empdb/DEPT#DEPTNO
http://empdb/EMP#JOB
http://empdb/EMP#EMPNO
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://empdb/DEPT#DNAME
http://empdb/EMP#DEPTNO
9 rows selected.
8.2.2 Creating an RDF View with an R2RML Mapping
If you wanted to create an RDF view using the two tables EMP and DEPT, but with your own customizations, you could create an R2RML mapping document specified using Turtle, such as the following:
@prefix rr: <http://www.w3.org/ns/r2rml#>. @prefix xsd: <http://www.w3.org/2001/XMLSchema#>. @prefix ex: <http://example.com/ns#>. ex:TriplesMap_Dept rr:logicalTable [ rr:tableName "DEPT" ]; rr:subjectMap [ rr:template "http://data.example.com/department/{DEPTNO}"; rr:class ex:Department; ]; rr:predicateObjectMap [ rr:predicate ex:deptNum; rr:objectMap [ rr:column "DEPTNO" ; rr:datatype xsd:integer ]; ]; rr:predicateObjectMap [ rr:predicate ex:deptName; rr:objectMap [ rr:column "DNAME" ]; ]; rr:predicateObjectMap [ rr:predicate ex:deptLocation; rr:objectMap [ rr:column "LOC" ]; ]. ex:TriplesMap_Emp rr:logicalTable [ rr:tableName "EMP" ]; rr:subjectMap [ rr:template "http://data.example.com/employee/{EMPNO}"; rr:class ex:Employee; ]; rr:predicateObjectMap [ rr:predicate ex:empNum; rr:objectMap [ rr:column "EMPNO" ; rr:datatype xsd:integer ]; ]; rr:predicateObjectMap [ rr:predicate ex:empName; rr:objectMap [ rr:column "ENAME" ]; ]; rr:predicateObjectMap [ rr:predicate ex:jobType; rr:objectMap [ rr:column "JOB" ]; ]; rr:predicateObjectMap [ rr:predicate ex:worksForDeptNum; rr:objectMap [ rr:column "DEPTNO" ; rr:dataType xsd:integer ]; ]; rr:predicateObjectMap [ rr:predicate ex:worksForDept; rr:objectMap [ rr:parentTriplesMap ex:TriplesMap_Dept ; rr:joinCondition [ rr:child "DEPTNO"; rr:parent "DEPTNO" ]]].
Then, load your R2RML mapping (converted into N-Triples format) into a staging table, such as SCOTT.R2RTAB, and grant the SELECT
privilege for this table to MDSYS.
Next, call SEM_APIS.CREATE_RDFVIEW_MODEL, as in Example 8-3.
Example 8-3 Creating an RDF View with an R2RML Mapping
BEGIN sem_apis.create_rdfview_model( model_name => 'empdb_model', tables => NULL, r2rml_table_owner => 'SCOTT', r2rml_table_name => 'R2RTAB' ); END; /
8.2.3 Dropping an RDF View
An RDF view can be dropped using the SEM_APIS.DROP_RDFVIEW_MODEL procedure, as shown in Example 8-4.
Example 8-4 Dropping an RDF View
BEGIN sem_apis.drop_rdfview_model( model_name => 'empdb_model' ); END; /
8.2.4 Exporting Virtual Content of an RDF View into a Staging Table
The content of an RDF view is virtual; that is, the RDF triples corresponding to the underlying relational data, as mapped by direct mapping or R2RML mapping, are not materialized and stored anywhere. You may, however, want to materialize and store these virtual RDF triples in an RDF model for your testing purposes. The SEM_APIS.EXPORT_RDFVIEW_MODEL subprogram lets you store the RDF triples of an RDF view in a staging table. The staging table can then be used for loading into an RDF model.
Example 8-5 materializes (in N-Triples format) the content of RDF view empdb_model
into the staging table SCOTT.RDFTAB.
Example 8-5 Exporting an RDF View
BEGIN sem_apis.export_rdfview_model( model_name => 'empdb_model', rdf_table_owner => 'SCOTT', rdf_table_name => 'RDFTAB' ); END;
8.3 Example: Using an RDF View with Direct Mapping
This topic provides an example of using an RDF view with direct mapping.
Example 8-6 shows a simple workflow using an RDF view with direct mapping. In it, you:
-
Create two relational tables (EMP and DEPT).
-
Insert data into the tables.
-
Create an RDF view model (
empdb_model
) using direct mapping of the two tables. -
Query the RDF view using SPARQL in a SEM_MATCH-based SQL query.
Example 8-7 shows the output of the statements in Example 8-6.
Example 8-6 Using an RDF View with Direct Mapping
-- Use the following relational tables. CREATE TABLE dept ( deptno NUMBER CONSTRAINT pk_DeptTab_deptno PRIMARY KEY, dname VARCHAR2(30), loc VARCHAR2(30) ); CREATE TABLE emp ( empno NUMBER PRIMARY KEY, ename VARCHAR2(30), job VARCHAR2(20), deptno NUMBER REFERENCES dept (deptno) ); -- Insert some data. INSERT INTO dept (deptno, dname, loc) VALUES (1, 'Sales', 'Boston'); INSERT INTO dept (deptno, dname, loc) VALUES (2, 'Manufacturing', 'Chicago'); INSERT INTO dept (deptno, dname, loc) VALUES (3, 'Marketing', 'Boston'); INSERT INTO emp (empno, ename, job, deptno) VALUES (1, 'Alvarez', 'SalesRep', 1); INSERT INTO emp (empno, ename, job, deptno) VALUES (2, 'Baxter', 'Supervisor', 2); INSERT INTO emp (empno, ename, job, deptno) VALUES (3, 'Chen', 'Writer', 3); INSERT INTO emp (empno, ename, job, deptno) VALUES (4, 'Davis', 'Technician', 2); -- Create an RDF view model using direct mapping of two tables, EMP and DEPT, -- with a base prefix of http://empdb/. -- Specify KEY_BASED_REF_PROPERTY=T for the options parameter. BEGIN sem_apis.create_rdfview_model( model_name => 'empdb_model', tables => SYS.ODCIVarchar2List('EMP', 'DEPT'), prefix => 'http://empdb/', options => 'KEY_BASED_REF_PROPERTY=T' ); END; / -- Query an RDF view using SPARQL in a SEM_MATCH-based SQL query. -- The next statament is a query against an RDF view named empdb_model -- to find the employees who work for any department located in Boston. SELECT emp FROM TABLE(SEM_MATCH( '{?emp emp:ref-DEPTNO ?dept . ?dept dept:LOC "Boston"}', SEM_Models('empdb_model'), NULL, SEM_ALIASES( SEM_ALIAS('dept','http://empdb/TESTUSER.DEPT#'), SEM_ALIAS('emp','http://empdb/TESTUSER.EMP#') ), null)); -- The preceding query is functionally comparable to this: SELECT e.empno FROM emp e, dept d WHERE e.deptno = d.deptno AND d.loc = 'Boston';
Example 8-7 Output of Example 8-6
SQL> -- Use the following relational tables. SQL> SQL> CREATE TABLE dept ( 2 deptno NUMBER CONSTRAINT pk_DeptTab_deptno PRIMARY KEY, 3 dname VARCHAR2(30), 4 loc VARCHAR2(30) 5 ); Table created. SQL> SQL> CREATE TABLE emp ( 2 empno NUMBER PRIMARY KEY, 3 ename VARCHAR2(30), 4 job VARCHAR2(20), 5 deptno NUMBER REFERENCES dept (deptno) 6 ); Table created. SQL> SQL> -- Insert some data. SQL> SQL> INSERT INTO dept (deptno, dname, loc) 2 VALUES (1, 'Sales', 'Boston'); 1 row created. SQL> INSERT INTO dept (deptno, dname, loc) 2 VALUES (2, 'Manufacturing', 'Chicago'); 1 row created. SQL> INSERT INTO dept (deptno, dname, loc) 2 VALUES (3, 'Marketing', 'Boston'); 1 row created. SQL> SQL> INSERT INTO emp (empno, ename, job, deptno) 2 VALUES (1, 'Alvarez', 'SalesRep', 1); 1 row created. SQL> INSERT INTO emp (empno, ename, job, deptno) 2 VALUES (2, 'Baxter', 'Supervisor', 2); 1 row created. SQL> INSERT INTO emp (empno, ename, job, deptno) 2 VALUES (3, 'Chen', 'Writer', 3); 1 row created. SQL> INSERT INTO emp (empno, ename, job, deptno) 2 VALUES (4, 'Davis', 'Technician', 2); 1 row created. SQL> SQL> -- Create an RDF view model using direct mapping of two tables, EMP and DEPT, SQL> -- with a base prefix of http://empdb/. SQL> -- Specify KEY_BASED_REF_PROPERTY=T for the options parameter. SQL> SQL> BEGIN 2 sem_apis.create_rdfview_model( 3 model_name => 'empdb_model', 4 tables => SYS.ODCIVarchar2List('EMP', 'DEPT'), 5 prefix => 'http://empdb/', 6 options => 'KEY_BASED_REF_PROPERTY=T' 7 ); 8 END; 9 / PL/SQL procedure successfully completed. SQL> SQL> -- Query an RDF view using SPARQL in a SEM_MATCH-based SQL query. SQL> -- The next statament is a query against an RDF view named empdb_model SQL> -- to find the employees who work for any department located in Boston. SQL> SQL> SELECT emp 2 FROM TABLE(SEM_MATCH( 3 '{?emp emp:ref-DEPTNO ?dept . ?dept dept:LOC "Boston"}', 4 SEM_Models('empdb_model'), 5 NULL, 6 SEM_ALIASES( 7 SEM_ALIAS('dept','http://empdb/TESTUSER.DEPT#'), 8 SEM_ALIAS('emp','http://empdb/TESTUSER.EMP#') 9 ), 10 null)); EMP -------------------------------------------------------------------------------- http://empdb/TESTUSER.EMP/EMPNO=1 http://empdb/TESTUSER.EMP/EMPNO=3 SQL> SQL> -- The preceding query is functionally comparable to this: SQL> SELECT e.empno FROM emp e, dept d WHERE e.deptno = d.deptno AND d.loc = 'Boston'; EMPNO ---------- 1 3
8.4 Combining Native RDF Data with Virtual RDB2RDF Data
You can combine native triple data with virtual RDB2RDF triple data in a single SEM_MATCH query by means of the SERVICE keyword.
The SERVICE keyword (explained in Graph Patterns: Support for SPARQL 1.1 Federated Query) is overloaded through the use of special SERVICE URLs that signify local (virtual) RDF data. The following prefixes are used to denote special SERVICE URLs:
-
Native models -
oram
: <http://xmlns.oracle.com/models/> -
Native virtual models -
oravm
: <http://xmlns.oracle.com/virtual_models/> -
RDB2RDF models -
orardbm
: <http://xmlns.oracle.com/rdb_models/>
Example 8-8 Querying Multiple Data Sets
Example 8-8 queries multiple data sets. In this query, the first triple pattern { ?x rdf:type :Person }
will go against native model m1
as usual, but { ?x :name ?name }
will go against the local native model m2
, and { ?x :email ?email }
will go against the local RDB2RDF model rdfview1
.
select * from table (sem_match( 'SELECT ?x ?name ?email WHERE { ?x rdf:type :Person . OPTIONAL { SERVICE oram:m2 { ?x :name ?name } } OPTIONAL { SERVICE orardbm:rdfview1 { ?x :email ?email } } }' sem_models('m1'), null, null, null, null, ' '));
Overloaded SERVICE use is only allowed with a single model specified in the models
argument of SEM_MATCH. Overloaded SERVICE queries do not allow multiple models or a rulebase as input. A virtual model that contains multiple models and/or entailments should be used instead for such combinations. In addition, the index_status
argument for SEM_MATCH will only check the entailment contained in the virtual model passed as input in the models parameter. This means the status of entailments that are referenced in overloaded SERVICE calls will not be checked.
Example 8-9 Querying Virtual RDB2RDF Data and Native RDF Data
Example 8-9 queries two data sets: the empdb_model
from Example 8-6 and a native model named people
.
 Consider the following examlpe query against multiple data sets, which finds the properties of all the departments with people who are 35 years old.
SELECT emp, dept, p, o
FROM TABLE(SEM_MATCH(
'SELECT * WHERE{
?emp peop:age 35
SERVICE orardbm:empdb_model{ ?emp emp:ref-DEPTNO ?dept . ?dept ?p ?o }
}',
SEM_Models('people'),
NULL,
SEM_ALIASES(
SEM_ALIAS('dept','http://empdb/TESTUSER.DEPT#'),
SEM_ALIAS('emp','http://empdb/TESTUSER.EMP#'),
SEM_ALIAS('peop','http://people.org/')
),
NULL));
To get all the results that match for given graph pattern, first the triple { ?emp peop:age 35 }
is matched against model people
, then the triples { ?emp emp:ref-DEPTNO ?d . ?d dept:DNAME ?dept }
are matched against model empdb_model
, and finally the results are joined. Assume that there is only one 35-year-old person in the model people
, but there are 100,000 triples with information about departments. Obviously, a strategy that retrieves all the results is not the most efficient, and query may have poor performance because a large numberof results that need to be processed before being joined with the rest of the query.
An nested-loop service can improve performance in this case. If the hint OVERLOADED_NL=T
is used, the results of the first part of the query are computed and the SERVICE pattern is executed procedurally in a nested loop once for each ?emp
value from the root triple pattern. The ?emp
subject variable in the SERVICE pattern is replaced with a constant from the root triple pattern in each execution. This effectively pushes the join condition down into the SERVICE clause.
The following example shows the use of the OVERLOADED_NL=T
hint for the preceding query.
SELECT emp, dept, p, o
FROM TABLE(SEM_MATCH(
'SELECT * WHERE{
?emp peop:age 35
SERVICE orardbm:empdb_model { ?emp emp:ref-DEPTNO ?dept . ?dept ?p ?o }
}',
SEM_Models('people'),
NULL,
SEM_ALIASES(
SEM_ALIAS('dept','http://empdb/TESTUSER.DEPT#'),
SEM_ALIAS('emp','http://empdb/TESTUSER.EMP#'),
SEM_ALIAS('peop','http://people.org/')
),
NULL,null,' OVERLOADED_NL=T '));
The hint OVERLOADED_NL=T
can be specified among SEM_MATCH options or among inline comments for a given SERVICE graph.


10.9 Interactive Command Sessions
The
cmd module offers a simple way to handle
interactive sessions of commands. Each command is a line of text. The
first word of each command is a verb defining the requested action.
The rest of the line is passed as an argument to the method that
implements the action that the verb requests.
Module cmd supplies class Cmd
to use as a base class, and you define your own subclass of
cmd.Cmd. The subclass supplies methods with names
starting with do_ and help_,
and may also optionally override some of
Cmd's methods. When the user
enters a command line such as verb
and the
rest, as long as the subclass defines a
method named do_verb,
Cmd.onecmd calls:
self.do_verb('and the rest')
Similarly, as long as the subclass defines a method named
help_verb,
Cmd.do_help calls it when the command line starts
with either 'help
verb' or
'?verb'.
Cmd, by default, also shows suitable error
messages if the user tries to use, or asks for help about, a verb for
which the subclass does not define a needed method.
10.9.1 Methods of Cmd Instances
An instance
c of a subclass of class
Cmd supplies the following methods (many of these
methods are meant to be overridden by the subclass).
Performs an entire interactive
session of line-oriented commands. cmdloop starts
by calling c.preloop(
), then outputs string intro
(c.intro, if
intro is None). Then
c.cmdloop enters a
loop. In each iteration of the loop, cmdloop reads
line s with
s=raw_input(c.prompt).
When standard input reaches end-of-file, cmdloop
sets s='EOF'. If
s is not 'EOF',
cmdloop preprocesses string
s with
s=c.precmd(s),
then calls
flag=c.onecmd(s).
When onecmd returns a true value, this is a
tentative request to terminate the command loop. Now
cmdloop calls
flag=c.postcmd(flag,s)
to check if the loop should terminate. If
flag is now true, the loop terminates;
otherwise another iteration of the loop executes. If the loop is to
terminate, cmdloop calls
c.postloop( ), then
terminates. This structure of cmdloop is probably
easiest to understand by showing Python code equivalent to the method
just described:
def cmdloop(self, intro=None):
self.preloop( )
if intro is None: intro = self.intro
print intro
while True:
try: s = raw_input(self.prompt)
except EOFError: s = `EOF'
else: s = self.precmd(s)
flag = self.onecmd(s)
flag = self.postcmd(flag, s)
if flag: break
self.postloop( ) cmdloop is a good example of the design pattern
known as Template Method. Such a method performs little substantial
work itself; rather, it structures and organizes calls to other
methods. Subclasses may override the other methods, to define the
details of class behavior within the overall framework thus
established. When you inherit from Cmd, you almost
never override method cmdloop, since
cmdloop's structure is the main
thing you get by subclassing Cmd.
c .onecmd calls
c.default(s)
when there is no method
c.do_verb
for the first word verb of line
s. Subclasses often override
default. The base class
Cmd.default method prints an error message.
c .onecmd calls
c.do_help(verb)
when command line s starts with
'help
verb' or
'?verb'.
Subclasses rarely override do_help. The
Cmd.do_help method calls method
help_verb if the
subclass supplies it, otherwise it displays the docstring of method
do_verb if the subclass
supplies that method with a non-empty docstring. If the subclass does
not supply either source of help, Cmd.do_help
outputs a message to inform the user that no help is available on
verb.
c .onecmd calls
c.emptyline( ) when
command line s is empty or blank. Unless a
subclass overrides this method, the base-class method
Cmd.emptyline is called and re-executes the last
non-blank command line seen, stored in the attribute
c.lastcmd of
c.
c .cmdloop calls
c.onecmd(s)
for each command line s that the user
inputs. You can also call onecmd directly, if you
have independently obtained a line s that
you need to process as a command. Normally, subclasses do not
override method onecmd.
Cmd.onecmd unconditionally sets
c.lastcmd=s.
Then, onecmd calls
do_verb if
s starts with the word
verb and if the subclass supplies such a
method, or else methods emptyline or
default, as explained earlier. In any case,
Cmd.onecmd returns the result of whatever other
method it ends up calling, to be interpreted by
postcmd as a termination-request flag.
c .cmdloop calls
c.postcmd(flag,s)
for each command line s, after
c.onecmd(s)
has returned value flag. If
flag is true, the command just executed is
posing a conditional request to terminate the command loop. If
postcmd returns a true value,
cmdloop's loop terminates. Unless
your subclass overrides this method, the base-class method
Cmd.postcmd is called, and returns
flag itself as the
method's result.
c .cmdloop calls
c.postloop( ) when
cmdloop's loop terminates. Unless
your subclass overrides this method, the base-class method
Cmd.postloop is called, and does nothing at all.
c .cmdloop calls
s=c.precmd(s)
to preprocess each command line s. The
current leg of the loop bases all further processing on the string
that precmd returns. Unless your subclass
overrides this method, the base-class method
Cmd.precmd is called, and returns
s itself as the method's
result.
c .cmdloop calls
c.preloop( ) before
cmdloop's loop begins. Unless
your subclass overrides this method, the base class
Cmd.preloop method is called, and does nothing at
all.
10.9.2 Attributes of Cmd Instances
An
instance c of a subclass of class
Cmd supplies the following attributes:
- identchars
-
A string that contains all characters that can be part of a verb; by
default, c.identchars
contains letters, digits, and underscore (_)
- intro
-
The message that cmdloop outputs first, when
called with no argument
- lastcmd
-
The last non-blank command line seen by onecmd
- prompt
-
The string that cmdloop uses to prompt the user
for interactive input. You almost always bind
c.prompt explicitly, or
override prompt as a class attribute of your
subclass, because the default Cmd.prompt is just
'(Cmd) '.
- use_rawinput
-
When false (default is true), cmdloop prompts and
inputs via calls to methods of sys.stdout and
sys.stdin, rather than via
raw_input
Other attributes of Cmd instances, which are not
covered here, let you exert fine-grained control on many formatting
details of help messages.
10.9.3 A Cmd Example
The following example shows how to use cmd.Cmd to
supply the verbs print (to output the rest of the
line) and stop (to end the loop):
import cmd
class X(cmd.Cmd):
def do_print(self, rest): print rest
def help_print(self): print "print (any string): outputs (any string)"
def do_stop(self, rest): return 1
def help_stop(self): print "stop: terminates the command loop"
if _ _name_ _= ='_ _main_ _': X( ).cmdloop( )
A session using this example might proceed as follows:
C:\>\python22\python \examples\chapter19\CmdEx.py
(Cmd) help
Documented commands (type help <topic>):
= == == == == == == == == == == == == == == == == == == == =
print stop
Undocumented commands:
= == == == == == == == == == == =
help
(Cmd) help print
print (whatever): outputs string (whatever)
(Cmd) print hi there
hi there
(Cmd) stop
|


A B C D G I L M P R T U
All Classes All Packages
All Classes All Packages
All Classes All Packages
A
- addAssistant() - Method in class BookingSystem
-
Adds an AssistantOnShift to the system, given user input
- addAssistant(Assistant) - Method in class University
-
Adds Assistant to the list of Assistants in the University
- addBookableRoom() - Method in class BookingSystem
-
Adds a BookableRoom to the list and to the respective Room's list of BookableRooms
- addBooking() - Method in class BookingSystem
-
Adds new Booking to the system based upon user input
- addRoom(Room) - Method in class University
-
Adds Room to the list of Rooms in the University
- addSchedule(BookableRoom) - Method in class Room
-
Adds a BookableRoom to the schedule of the Room
- addSchedule(String) - Method in class Assistant
-
Adds AssistantOnShifts for the whole day to the list of AssistantOnShifts
- assignBooking() - Method in class AssistantOnShift
-
Sets the status of the AssistantOnShift to BUSY
- Assistant - Class in <Unnamed>
-
An Assistant represents a volunteer at the University that will administer a COVID test
- Assistant(String, String) - Constructor for class Assistant
-
Constructor for objects of class Assistant
- AssistantOnShift - Class in <Unnamed>
-
An AssistantOnShift represents a timeslot for an assistant to administer a test
- AssistantOnShift(String, String, String) - Constructor for class AssistantOnShift
-
Constructor for AssistantOnShift
B
- BookableRoom - Class in <Unnamed>
-
A BookableRoom represents a timeslot for a Room to be used to administer a COVID test
- BookableRoom(String, String, int) - Constructor for class BookableRoom
-
Constructor for objects of class AssistantOnShift
- Booking - Class in <Unnamed>
-
Booking represents an appointment for a COVID test
- Booking(BookableRoom, AssistantOnShift, String, String) - Constructor for class Booking
-
Constructor for Booking
- BookingApp - Class in <Unnamed>
-
Initialises and runs the Booking System.
- BookingApp() - Constructor for class BookingApp
- BookingSystem - Class in <Unnamed>
-
BookingSystem is the main section of the BookingApp, managing the Bookings and attributes associated with them
- BookingSystem() - Constructor for class BookingSystem
C
- cancelTest() - Method in class Booking
-
Cancels the test and frees the room and assistant from this timeslot
- clearConsole() - Static method in class BookingSystem
-
Clears the console for between screens
- completeTest() - Method in class Booking
-
Updates the status of the Booking to completed
- concludeBooking() - Method in class BookingSystem
-
Concludes a booking, chosen by the user, by setting the status of the booking to COMPLETED
- createBooking(String, String) - Method in class BookingSystem
-
Creates a booking by finding a free room and free assistant
D
- decreaseOccupancy() - Method in class BookableRoom
-
Decreases the occupancy of the BookableRoom
G
- getAssistants() - Method in class University
-
Returns list of Assistants in the University
- getCapacity() - Method in class Room
-
Gets the capacity of a Room
- getCode() - Method in class Room
-
Gets the code of the Room
- getEmail() - Method in class Assistant
-
Returns the email of the Assistant
- getEmail() - Method in class AssistantOnShift
-
Gets the email of the AssistantOnShift
- getName() - Method in class Assistant
-
Returns the name of the Assistant
- getOccupancy() - Method in class BookableRoom
-
Gets the occupancy of the BookableRoom
- getRoomCode() - Method in class BookableRoom
-
Gets the code of the BookableRoom
- getRooms() - Method in class University
-
Returns list of Rooms in the University
- getSchedule() - Method in class Assistant
-
Returns the Assistant's schedule
- getSchedule() - Method in class Room
-
Gets the schedule of a Room
- getStatus() - Method in class AssistantOnShift
-
Gets the status of the AssistantOnShift
- getStatus() - Method in class BookableRoom
-
Gets the status of the BookableRoom
- getStatus() - Method in class Booking
-
Gets the status of the Booking
- getTimeSlot() - Method in class AssistantOnShift
-
Gets the timeslot of the AssistantOnShift
- getTimeSlot() - Method in class BookableRoom
-
Gets the timeslot of the BookableRoom
- getTimeSlots() - Method in class BookingSystem
-
Gets the list of all valid timeslots with no duplicates
I
- increaseOccupancy() - Method in class BookableRoom
-
Increases the occupancy of the BookableRoom
- initialiseData() - Method in class BookingSystem
-
Initialises data for the system to test, with 3 Assistants, 3 Rooms, 9 BookableRooms, 9 AssistantOnShift, and 6 Bookings
- input - Variable in class BookingSystem
- isAlreadyScheduled(AssistantOnShift) - Method in class BookingSystem
-
Checks to see if an assistant is already scheduled for the timeslot
- isDate(String) - Method in class BookingSystem
-
Checks to see if a String fits into the format dd/mm/yyyy
- isDateTime(String) - Method in class BookingSystem
-
Checks to see if a String fits into the format dd/mm/yyyy HH:MM
- isInList(BookableRoom) - Method in class BookingSystem
-
Checks to see if a BookableRoom already exists in the list
- isNumeric(String) - Method in class BookingSystem
-
Checks to see if a String is numerical or not
L
- listAssistant() - Method in class BookingSystem
-
Lists all AssistantsOnShift in the system
- listBookableRooms() - Method in class BookingSystem
-
Lists all the Bookable Rooms in the Booking System
- listBooking() - Method in class BookingSystem
-
Lists all the Bookings registered in the system, with no duplicates
M
- main(String[]) - Static method in class BookingApp
-
Initialises the data, then runs the main menu
- mainMenu() - Method in class BookingSystem
-
Main menu options for the Booking System.
P
- printMainMenu() - Method in class BookingSystem
-
Prints the main menu screen
R
- reader - Variable in class BookingSystem
- removeAssistant() - Method in class BookingSystem
-
Removes AssistantOnShift from the system and the assistant it's assigned to, by getting user choice
- removeBookableRoom() - Method in class BookingSystem
-
Displays all removable BookableRooms, then takes the user input and removes that room
- removeBooking() - Method in class AssistantOnShift
-
Sets the status of the AssistantOnShift to FREE
- removeBooking() - Method in class BookingSystem
-
Removes booking from system based upon user input
- removeSchedule(AssistantOnShift) - Method in class Assistant
-
Deletes an appointment from the schedule
- removeSchedule(BookableRoom) - Method in class Room
-
Removes a BookableRoom from the schedule of the Room
- removingAssistant(AssistantOnShift) - Method in class BookingSystem
-
Removes an AssistantOnShift from the system and its respective Assistant
- removingRoom(BookableRoom) - Method in class BookingSystem
-
Removes a BookableRoom from the list and from the Room it's assigned to
- Room - Class in <Unnamed>
-
A Room represents a room within the University that will have COVID tests being administered in
- Room(int) - Constructor for class Room
-
Constructor for Room
T
- toString() - Method in class Assistant
-
Returns String with name and email
- toString() - Method in class AssistantOnShift
-
Returns String formatted to include timeslot, status, and email
- toString() - Method in class BookableRoom
-
Returns a String formatted to include timeslot, status, roomCode, and occupancy
- toString() - Method in class Booking
-
Returns a formatted String for the Booking
- toString() - Method in class Room
-
Returns String with code and capacity of Room
U
- University - Class in <Unnamed>
-
A University holds the list of Assistants and Rooms
- University() - Constructor for class University
All Classes All Packages