S-SQL Reference Manual
Table of Contents
- Interface
- macro sql (form)
- function sql-compile (form)
- function sql-template (form)
- function enable-s-sql-syntax (&optional (char #\Q))
- function sql-escape-string (string)
- method sql-escape (value)
- variable standard-sql-strings
- variable escape-sql-names-p
- function sql-type-name (type)
- function to-sql-name (name &optional (escape-p escape-sql-names-p))
- function from-sql-name (string)
- macro register-sql-operators (arity &rest names)
- SQL Types
- SQL Syntax
- sql-op :select (&rest args)
- sql-op :+, :*, :%, :&, :|, :||, :and, :or, :=, :/, :!=, :<, :>, :<=, :>=, :^, :union, :union-all, :intersect, :intersect-all, :except, :except-all (&rest args)
- sql-op :~, :not (arg)
- sql-op :function (name (&rest arg-types) return-type stability body)
- sql-op :~, :~*, :!~, :!~* (string pattern)
- sql-op :like, :ilike (string pattern)
- sql-op :@@
- sql-op :desc (column)
- sql-op :nulls-first, :nulls-last (column)
- sql-op :as (form name &rest fields)
- sql-op :cast (query)
- sql-op :type (query)
- sql-op :create-composite-type (type-name &rest args)
- sql-op :exists (query)
- sql-op :is-null (arg)
- sql-op :not-null (arg)
- sql-op :in (value set)
- sql-op :not-in (value set)
- sql-op :set (&rest elements)
- sql-op :array (query)
- sql-op :array[] (&rest args)
- sql-op :[] (form start &optional end)
- sql-op :extract (unit form)
- sql-op :case (&rest clauses)
- sql-op :between (n start end)
- sql-op :between-symmetric (n start end)
- sql-op :dot (&rest names)
- sql-op :type (form type)
- sql-op :raw (string)
- sql-op :limit (query amount &optional offset)
- sql-op :order-by (query &rest exprs)
- sql-op :values
- sql-op :empty-set
- sql-op :group-by
- sql-op :grouping-sets
- Time, Date and Interval Operators
- Aggregation Operators
- sql-op :count (&rest args)
- sql-op :avg (&rest rest args)
- sql-op :sum (&rest rest args)
- sql-op ::max (&rest args)
- sql-op ::min (&rest args)
- sql-op ::every (&rest args)
- sql-op :percentile-cont (&rest args)
- sql-op :percentile-dist (&rest args)
- sql-op :corr (y x)
- sql-op :covar-pop (y x)
- sql-op :covar-samp (y x)
- sql-op :string-agg (&rest args)
- sql-op :array-agg (&rest args)
- sql-op :mode (&rest args)
- sql-op :regr_avgx (y x)
- sql-op :regr_avgy (y x)
- sql-op :regr_count (y x)
- sql-op :regr_intercept (y x)
- sql-op :regr_r2 (y x)
- sql-op :regr_slope (y x)
- sql-op :regr_sxx (y x)
- sql-op :regr_sxy (y x)
- sql-op :regr_syy (y x)
- sql-op :stddev (&rest args)
- sql-op :stddev-pop (&rest args)
- sql-op :stddev-samp (&rest args)
- sql-op :variance (&rest args)
- sql-op :var-pop (&rest args)
- sql-op :var-samp (&rest args)
- sql-op :over (form &rest args)
- sql-op :partition-by (&rest args)
- sql-op :window (form)
- sql-op :with (&rest args)
- sql-op :with-recursive (&rest args)
- Table Functions
- sql-op :for-update (query &key of nowait)
- sql-op :for-share (query &key of nowait)
- sql-op :insert-into (table &rest rest)
- sql-op :insert-rows-into (table &rest rest)
- sql-op :update (table &rest rest)
- sql-op :delete-from (table &rest rest)
- sql-op :create-table (name (&rest columns) &rest options)
- sql-op :alter-table (name action &rest args)
- sql-op :drop-table (name)
- sql-op :truncate (&rest args)
- sql-op :create-index (name &rest args)
- sql-op :create-unique-index (name &rest args)
- sql-op :drop-index (name)
- sql-op :create-sequence (name &key increment min-value max-value start cache cycle)
- sql-op :alter-sequence (name)
- sql-op :drop-sequence (name)
- sql-op :create-view (name query)
- sql-op :drop-view (name)
- sql-op :set-constraints (state &rest constraints)
- sql-op :listen (channel)
- sql-op :unlisten (channel)
- sql-op :notify (channel &optional payload)
- sql-op :create-role (role &rest args)
- sql-op :create-database (name)
- sql-op :drop-database (name)
- sql-op :copy (table &rest args)
- Dynamic Queries and Composition
This is the reference manual for the S-SQL component of the postmodern library.
S-SQL provides a lispy syntax for SQL queries, and knows how to convert various lisp types to their textual SQL representation. It takes care to do as much of the work as possible at compile-time, so that at runtime a string concatenation is all that is needed to produce the final SQL query.
Interface
macro sql (form)
→ string
Convert the given form (a list starting with a keyword) to an SQL query string at compile time, according to the rules described here.
function sql-compile (form)
→ string
This is the run-time variant of the sql macro. It converts the given list to an SQL query, with the same rules except that symbols in this list do not have to be quoted to be interpreted as identifiers.
function sql-template (form)
In cases where you do need to build the query at run time, yet you do not want to re-compile it all the time, this function can be used to compile it once and store the result. It takes an S-SQL form, which may contain \[ placeholder symbols, and returns a function that takes one argument for every \]. When called, this returned function produces an SQL string in which the placeholders have been replaced by the values of the arguments.
function enable-s-sql-syntax (&optional (char #\Q))
Modifies the current readtable to add a #Q syntax that is read as (sql …). The character to use can be overridden by passing an argument.
function sql-escape-string (string)
→ string
Escapes a string for inclusion in a PostgreSQL query.
method sql-escape (value)
→ string
A generalisation of sql-escape-string Looks at the type of the value passed, and properly writes it out it for inclusion in an SQL query. Symbols will be converted to SQL names.
variable standard-sql-strings
Used to configure whether S-SQL will use standard SQL strings (just replace #\' with ''), or backslash-style escaping. Setting this to NIL is always safe, but when the server is configured to allow standard strings (compile-time parameter 'standard_conforming_strings' is 'on', which will become the default in future versions of PostgreSQL), the noise in queries can be reduced by setting this to T.
variable escape-sql-names-p
Determines whether double quotes are added around column, table, and ** function names in queries. Valid values:
- T, in which case every name is escaped,
- NIL, in which case no name is escape,
- :auto, which causes only reserved words to be escaped, or.
- :literal which is the same as :auto except it has added consequence in to-sql-name (see below).
The default value is :auto.
Be careful when binding this with let and such ― since a lot of SQL compilation tends to happen at compile-time, the result might not be what you expect. Mixed case sensitivity is not currently well supported. Postgresql itself will downcase unquoted identifiers. This will be revisited in the future if requested.
function sql-type-name (type)
→ string
Create the SQL equivalent of the given Lisp type, if one is known. See types.
function to-sql-name (name &optional (escape-p escape-sql-names-p))
→ string
Convert a symbol or string to a name that can be used as an SQL identifier by converting all non-alphanumeric characters to underscores. Also lowercases the name to make queries look a bit less hideous. When a second argument is given, this overrides the current value of escape-sql-names-p. If the second argument is :literal then the name will be escaped only and this will be a a delimited identifier or quoted identifier. See
function from-sql-name (string)
→ keyword
Convert a string that represents an SQL identifier to a keyword by uppercasing it and converting the underscores to dashes.
macro register-sql-operators (arity &rest names)
Define simple SQL operators. Arity is one of :unary (like 'not'), :unary-postfix (the operator comes after the operand), :n-ary (like '\+': the operator falls away when there is only one operand), :2+-ary (like '=', which is meaningless for one operand), or :n-or-unary (like '-', where the operator is kept in the unary case). After the arity may follow any number of operators, either just a keyword, in which case the downcased symbol name is used as the SQL operator, or a two-element list containing a keyword and a name string.
SQL Types
S-SQL knows the SQL equivalents to a number of Lisp types, and defines some extra types that can be used to denote other SQL types. The following table shows the correspondence:
| Lisp type | SQL type |
| smallint | smallint |
| integer | integer |
| bigint | bigint |
| (numeric X Y) | numeric(X, Y) |
| float, real | real |
| double-float, double-precision | double-precision |
| string, text | text |
| (string X) | char(X) |
| (varchar X) | varchar(X) |
| boolean | boolean |
| bytea | bytea |
| date | date |
| timestamp | timestamp |
| interval | interval |
| array | array |
**type db-null
This is a type of which only the keyword :null is a member. It is used to represent NULL values from the database.
SQL Syntax
An S-SQL form is converted to a query through the following rules:
- Lists starting with a keyword are operators. They are expanded as described below if they are known, otherwise they are expanded in the standard way: operator(arguments, …)
- Quoted symbols or keywords are interpreted as names of columns or tables, and converted to strings with to-sql-name.
- Anything else is evaluated and the resulting Lisp value is converted to its textual SQL representation (or an error is raised when there is no rule for converting objects of this type). Self-quoting atoms may be converted to strings at compile-time.
sql-op :select (&rest args)
Creates a select query. The arguments are split on the keywords found among them. The group of arguments immediately after :select is interpreted as the expressions that should be selected. After this, an optional :distinct may follow, which will cause the query to only select distinct rows, or alternatively :distinct-on followed by a group of row names. Next comes the optional keyword :from, followed by at least one table name and then any number of join statements. Join statements start with one of :left-join, :right-join, :inner-join, :outer-join or :cross-join, then a table name or subquery, then the keyword :on or :using, if applicable, and then a form. A join can be preceded by :natural (leaving off the :on clause) to use a natural join. After the joins an optional :where followed by a single form may occur. And finally :group-by and :having can optionally be specified. The first takes any number of arguments, and the second only one. An example:
(query (:select (:+ 'field-1 100) 'field-5 :from (:as 'my-table 'x) :left-join 'your-table :on (:= 'x.field-2 'your-table.field-1) :where (:not-null 'a.field-3)))
The following operators are defined:
sql-op :+, :*, :%, :&, :|, :||, :and, :or, :=, :/, :!=, :<, :>, :<=, :>=, :^, :union, :union-all, :intersect, :intersect-all, :except, :except-all (&rest args)
These are expanded as infix operators. When meaningful, they allow more than two arguments. :- can also be used as a unary operator to negate a value. Note that the arguments to :union, :union-all, :intersect, and :except should be queries (:select forms).
Note that you'll have to escape pipe characters to enter them as keywords. S-SQL handles the empty keyword symbol (written :||) specially, and treats it like :\|\|, so that it can be written without escapes. With :\|, this doesn't work.
sql-op :~, :not (arg)
Unary operators for bitwise and logical negation.
sql-op :function (name (&rest arg-types) return-type stability body)
Create a stored procedure. The argument and return types are interpreted as type names and not evaluated. Stability should be one of :immutable, :stable, or :volatile (see the PostgreSQL documentation). For example, a function that gets foobars by id:
(:function 'get-foobar (integer) foobar :stable (:select '* :from 'foobar :where (:= 'id '$1)))
sql-op :~, :~*, :!~, :!~* (string pattern)
Regular expression matching operators. The exclamation mark means 'does not match', the asterisk makes the match case-insensitive.
sql-op :like, :ilike (string pattern)
Simple SQL string matching operators (:ilike is case-insensitive).
sql-op :@@
Fast Text Search match operator.
sql-op :desc (column)
Used to invert the meaning of an operator in an :order-by clause.
sql-op :nulls-first, :nulls-last (column)
Used to determine where :null values appear in an :order-by clause.
sql-op :as (form name &rest fields)
Assigns a name to a column or table in a :select form. When fields are given, they are added after the name, in parentheses. For example, (:as 'table1 't1 'foo 'bar) becomes table1 AS t1(foo, bar). When you need to specify types for the fields, you can do something like (:as 'table2 't2 ('foo integer)). Note that names are quoted, types are not (when using sql-compile or sql-template, you can leave out the quotes entirely).
sql-op :cast (query)
The CAST operator. Takes a query as an argument, and returns the result explicitly cast by postgresql to a specific type.
(query (:select (:cast (:as "20" 'integer))) :single) 20 (query (:union (:select (:as 1 'real)) (:select (:cast (:as "2.2" 'real))))) ((1.0) (2.2))
sql-op :type (query)
Is similar to cast but uses the postgresql :: formating. E.g.
(sql (:select (:as (:- (:type (:now) date) 'x) 'some-date) :from (:as (:generate-series 1 10) 'x))) "(SELECT (now()::DATE - x) AS some_date FROM generate_series(1, 10) AS x)"
sql-op :create-composite-type (type-name &rest args)
Creates a composite type with a type-name and two or more columns. E.g.
(query (:create-composite-type 'fullname (first-name text) (last-name text)))
sql-op :exists (query)
The EXISTS operator. Takes a query as an argument, and returns true or false depending on whether that query returns any rows.
sql-op :is-null (arg)
Test whether a value is null.
sql-op :not-null (arg)
Test whether a value is not null.
sql-op :in (value set)
Test whether a value is in a set of values.
sql-op :not-in (value set)
Inverse of the above.
sql-op :set (&rest elements)
Denote a set of values. This operator has two interfaces. When the elements are known at compile-time, they can be given as multiple arguments to the operator. When they are not, a single argument that evaluates to a list should be used.
sql-op :array (query)
This is used when calling a select query into an array. See array-notes.html for more detailed notes on the use of arrays.
(query (:order-by (:select 'r.rolename (:as (:array (:select 'b.rolename :from (:as 'pg_catalog.pg-auth-members 'm) :inner-join (:as 'pg-catalog.pg-roles 'b) :on (:= 'm.roleid 'b.oid) :where (:= 'm.member 'r.oid ))) 'memberof) :from (:as 'pg-catalog.pg-roles 'r)) 1))
sql-op :array[] (&rest args)
This is the general operator for arrays. It also handles statements that include functions in the query such as (:+ 1 2), (:pi) in the array. See array-notes.html for more detailed notes on the use of arrays.
(query (:select (:array-prepend 1 (:array[] 2 3)))) ((#(1 2 3))) (query (:select (:array-prepend 1 (:array[] 2 3))) :single) #(1 2 3)
sql-op :[] (form start &optional end)
Dereference an array value. If end is provided, extract a slice of the array. Sample usage below, but also see array-notes.html for more detailed notes on the use of arrays.
(query (:select 'receipe-id (:[] 'tags 2 3) :from 'receipe-tags-array :where (:= 'receipe-id 3)))
sql-op :extract (unit form)
Extract a field from a date/time value. For example, (:extract :month (:now)).
sql-op :case (&rest clauses)
A conditional expression. Clauses should take the form (test value). If test is :else, an ELSE clause will be generated.
sql-op :between (n start end)
Test whether a value lies between two other values.
sql-op :between-symmetric (n start end)
Works like :between, except that the start value is not required to be less than the end value.
sql-op :dot (&rest names)
Can be used to combine multiple names into a name of the form A.B to refer to a column in a table, or a table in a schema. Note that you can also just use a symbol with a dot in it.
sql-op :type (form type)
Add a type declaration to a value, as in in "4.3::real". The second argument is not evaluated normally, but put through sql-type-name to get a type identifier.
sql-op :raw (string)
Insert a string as-is into the query. This can be useful for doing things that the syntax does not support, or to re-use parts of a query across multiple queries:
(let* ((test (sql (:and (:= 'foo 22) (:not-null 'bar)))) (rows (query (:select '* :from 'baz :where (:raw test))))) (query (:delete-from 'baz :where (:raw test))) (do-stuff rows))
sql-op :limit (query amount &optional offset)
In S-SQL limit is not part of the select operator, but an extra operator that is applied to a query (this works out better when limiting the union or intersection of multiple queries, same for sorting). It limits the number of results to the amount given as the second argument, and optionally offsets the result by the amount given as the third argument.
sql-op :order-by (query &rest exprs)
Order the results of a query by the given expressions. See :desc for when you want to invert an ordering. Note: This is not the same as passing an :order-by parameter to an aggregation operator. See Aggregation Operators.
sql-op :values
Values computes a row value or set of row values for use in a specific query. See the postgresql docs at: https://www.postgresql.org/docs/current/static/queries-values.html and https://www.postgresql.org/docs/current/static/sql-values.html Example:
(query (:select '* :from (:as (:values (:set 1 "one") (:set 2 "two") (:set 3 "three")) (:t1 'num 'letter)))) (query (:select 'a 'b 'c (:cast (:as (:* 50 (:random)) 'int)) :from (:as (:values (:set "a") (:set "b")) (:d1 'a)) (:as (:values (:set "c") (:set "d")) (:d2 'b)) (:as (:values (:set "e") (:set "f")) (:d3 'c)))) (query (:with-recursive (:as (:t1 'n) (:union-all (:values (:set 1)) (:select (:+ 'n 1) :from 't1 :where (:< 'n 100)))) (:select (:sum 'n) :from 't1)) :single)
sql-op :empty-set
This is a fudge. It returns a string "()" where something like '() would return "false" or :() would throw an error. Example:
(query (:select 'appnumber 'day (:sum 'inserts) (:sum 'updates) (:sum 'deletes) (:sum 'transactions) :from 'db-details :group-by (:grouping-sets (:set 'appnumber 'day (:empty-set)))))
sql-op :group-by
https://www.postgresql.org/docs/current/static/queries-table-expressions.html#QUERIES-GROUPING-SETS The GROUP BY Clause is used to group together those rows in a table that have the same values in all the columns listed. The order in which the columns are listed does not matter. The effect is to combine each set of rows having common values into one group row that represents all rows in the group. This is done to eliminate redundancy in the output and/or compute aggregates that apply to these groups. Example:
(query (:order-by (:select 'mems.surname 'mems.firstname 'mems.memid (:as (:min 'bks.starttime) 'starttime) :from (:as 'cd.bookings 'bks) :inner-join (:as 'cd.members 'mems) :on (:= 'mems.memid 'bks.memid) :where (:>= 'starttime "2012-09-01") :group-by 'mems.surname 'mems.firstname 'mems.memid) 'mems.memid))
sql-op :grouping-sets
https://www.postgresql.org/docs/current/static/queries-table-expressions.html#QUERIES-GROUPING-SETS More complex grouping operations are possible using the concept of grouping sets. The data selected by the FROM and WHERE clauses is grouped separately by each specified grouping set, aggregates computed for each group just as for simple GROUP BY clauses, and then the results returned. This operator requires postgresql 9.5 or later. For example:
(query (:select 'city (:as (:extract 'year 'start-date) 'joining-year) (:as (:count 1) 'employee_count) :from 'employee :group-by (:grouping-sets (:set 'city (:extract 'year 'start-date)))))
Time, Date and Interval Operators
sql-op :interval (arg)
Creates an interval data type, generally represented in postmodern as an alist
sql-op :current-date ()
sql-op :current-time ()
sql-op :current-timestamp ()
sql-op :timestamp (arg)
sql-op :age (&rest args)
sql-op :date (arg)
Aggregation Operators
sql-op :count (&rest args)
Count returns the number of rows for which the expression is not null. It can be the number of rows collected by the select statement as in:
(query (:select (:count '*) :from 'table1 :where (:= 'price 100)))
or it can be a smaller number of rows based on the allowed keyword parameters :distinct and :filter or some other type of condition as in:
(query (:select (:count 'memid :distinct) :from 'cd.bookings))
or
(query (:select (:as (:count '* :distinct) 'unfiltered) (:as (:count '* :filter (:= 1 'bid)) 'filtered) :from 'testtable))
Note that if used, the filter must be last in the count args. If distinct is used, it must come before filter. Unlike standard sql, the word 'where' is not used inside the filter clause. E.g.
(query (:select (:count '*) (:count '* :filter (:= 1 'bid)) 'id :from 'pbbench-history))
See tests.lisp for examples.
sql-op :avg (&rest rest args)
Avg calculates the average value of a list of values. Note that if the filter keyword is used, the filter must be last in the avg args. If distinct is used, it must come before filter. E.g. See tests.lisp for more examples.
(query (:select (:avg '*) (:avg '* :filter (:= 1 'bid)) 'id :from 'pbbench-history))
sql-op :sum (&rest rest args)
Sum calculates the total of a list of values. Note that if the keyword filter is used, the filter must be last in the sum args. If distinct is used, it must come before filter. Unlike standard sql, the word 'where' is not used inside the filter clause (s-sql will properly expand it). See tests.lisp for more examples.
(query (:select (:sum '*) (:sum '* :filter (:= 1 'bid)) 'id :from 'pbbench-history))
sql-op ::max (&rest args)
max returns the maximum value of a set of values. Note that if the filter keyword is used, the filter must be last in the max args. If distinct is used, it must come before filter. Unlike standard sql, the word 'where' is not used inside the filter clause (s-sql will properly expand it). See tests.lisp for more examples.
(query (:select (:max '*) (:max '* :filter (:= 1 'bid)) 'id :from 'pbbench-history))
sql-op ::min (&rest args)
min returns the minimum value of a set of values. Note that if the filter keyword is used, the filter must be last in the min args. If distinct is used, it must come before filter. Unlike standard sql, the word 'where' is not used inside the filter clause (s-sql will properly expand it). See tests.lisp for more examples.
(query (:select (:min '*) (:min '* :filter (:= 1 'bid)) 'id :from 'pbbench-history))
sql-op ::every (&rest args)
Every returns true if all input values are true, otherwise false. Note that if the filter keyword is used, the filter must be last in the every args. If distinct is used, it must come before filter. Unlike standard sql, the word 'where' is not used inside the filter clause (s-sql will properly expand it). See tests.lisp for more examples.
(query (:select '* (:every (:like 'studname "%h")) :from 'tbl-students :group-by 'studname 'studid 'studgrades))
sql-op :percentile-cont (&rest args)
Requires Postgresql 9.4 or higher. Percentile-cont returns a value corresponding to the specified fraction in the ordering, interpolating between adjacent input items if needed. There are two required keyword parameters :fraction and :order-by. If the fraction value is an array, then it returns an array of results matching the shape of the fractions parameter, with each non-null element replaced by the value corresponding to that percentile. Examples:
(query (:select (:percentile-cont :fraction 0.5 :order-by 'number-of-staff) :from 'schools)) (query (:select (:percentile-cont :fraction array[0.25 0.5 0.75 1] :order-by 'number-of-staff) :from 'schools))
sql-op :percentile-dist (&rest args)
Requires Postgresql 9.4 or higher. There are two required keyword parameters :fraction and :order-by. Percentile-dist returns the first input value whose position in the ordering equals or exceeds the specified fraction. If the fraction parameter is an array eturns an array of results matching the shape of the fractions parameter, with each non-null element replaced by the input value corresponding to that percentile. Examples:
(query (:select (:percentile-dist :fraction 0.5 :order-by 'number-of-staff) :from 'schools)) (query (:select (:percentile-dist :fraction array[0.25 0.5 0.75 1] :order-by 'number-of-staff) :from 'schools))
sql-op :corr (y x)
The corr function returns the correlation coefficient between a set of dependent and independent variables. Example:
(query (:select (:corr 'height 'weight) :from 'people))
sql-op :covar-pop (y x)
The covar-pop function returns the population covariance between a set of dependent and independent variables. Example:
(query (:select (:covar-pop 'height 'weight) :from 'people))
sql-op :covar-samp (y x)
(query (:select (:covar-samp 'height 'weight) :from 'people))
The covar-samp function returns the sample covariance between a set of dependent and independent variables. Example:
sql-op :string-agg (&rest args)
String-agg allows you to concatenate strings using different types of delimiter symbols. Allowable optional keyword parameters are :distinct, :order-by and :filter Note that order-by in string-agg requires postgresql 9.0 or later. Filter requires postgresql 9.4 or later. See tests.lisp for more examples.
(query (:select (:as (:string-agg 'bp.step-type \",\" ) 'step-summary) :from 'business-process)) (query (:select 'mid (:as (:string-agg 'y \",\" :distinct :order-by (:desc 'y)) 'words) :from 'moves)) (query (:select (:string-agg 'name "," :order-by (:desc 'name) :filter (:< 'id 4)) :from 'employee))
sql-op :array-agg (&rest args)
Array-agg returns a list of values concatenated into an arrays. Allowable optional keyword parameters are :distinct, :order-by and :filter.
Note that order-by in array-agg requires postgresql 9.0 or later. Filter requires postgresql 9.4 or later. See array-notes.html for more detailed notes on the use of arrays.
Example with Filter:
(query (:select 'g.id (:as (:array-agg 'g.users :filter (:= 'g.canonical \"Y\")) 'canonical-users) (:as (:array-agg 'g.users :filter (:= 'g.canonical \"N\")) 'non-canonical-users) :from (:as 'groups 'g) :group-by 'g.id))
sql-op :mode (&rest args)
Mode is used to find the most frequent input value in a group. See e.g. https://www.postgresql.org/docs/10/static/functions-aggregate.html#FUNCTIONS-ORDEREDSET-TABLE and article at https://tapoueh.org/blog/2017/11/the-mode-ordered-set-aggregate-function
(query (:select (:mode 'items) :from 'item-table))
sql-op :regr_avgx (y x)
The regr_avgx function returns the average of the independent variable (sum(X)/N) Example:
(query (:select (:regr_avgx 'height 'weight) :from 'people))
sql-op :regr_avgy (y x)
The regr_avgy function returns the average of the dependent variable (sum(Y)/N). Example:
(query (:select (:regr_avgy 'height 'weight) :from 'people))
sql-op :regr_count (y x)
The regr_count function returns the number of input rows in which both expressions are nonnull. Example:
(query (:select (:regr_count 'height 'weight) :from 'people))
sql-op :regr_intercept (y x)
The regr_intercept function returns the y-intercept of the least-squares-fit linear equation determined by the (X, Y) pairs. Example:
(query (:select (:regr_intercept 'height 'weight) :from 'people))
sql-op :regr_r2 (y x)
The regr_r2 function returns the square of the correlation coefficient. Example:
(query (:select (:regr_r2 'height 'weight) :from 'people))
sql-op :regr_slope (y x)
The regr_slope function returns the slope of the least-squares-fit linear equation determined by the (X, Y) pairs. Example:
(query (:select (:regr_slope 'height 'weight) :from 'people))
sql-op :regr_sxx (y x)
The regr_sxx function returns the sum(X^2) - sum(X)^2/N (“sum of squares” of the independent variable). Example:
(query (:select (:regr_sxx 'height 'weight) :from 'people))
sql-op :regr_sxy (y x)
The regr_sxy function returns the sum(X*Y) - sum(X) * sum(Y)/N (“sum of products” of independent times dependent variable). Example:
(query (:select (:regr_sxy 'height 'weight) :from 'people))
sql-op :regr_syy (y x)
The regr_syy function returns the sum(Y^2) - sum(Y)^2/N (“sum of squares” of the dependent variable). Example:
(query (:select (:regr_syy 'salary 'age) :from 'employee))
sql-op :stddev (&rest args)
The stddev function returns the the sample standard deviation of the input values. It is a historical alias for stddev-samp. Example:
(query (:select (:stddev 'salary) :from 'employee))
sql-op :stddev-pop (&rest args)
The stddev-pop function returns the population standard deviation of the input values. Example:
(query (:select (:stddev-pop 'salary) :from 'employee))
sql-op :stddev-samp (&rest args)
The stddev-samp function returns the sample standard deviation of the input values. Example:
(query (:select (:stddev-samp 'salary) :from 'employee))
sql-op :variance (&rest args)
Variance is a historical alias for var_samp. The variance function returns the sample variance of the input values (square of the sample standard deviation). Example:
(query (:select (:variance 'salary) :from 'employee))
sql-op :var-pop (&rest args)
The var-pop function returns the population variance of the input values (square of the population standard deviation). Example:
(query (:select (:var-pop 'salary) :from 'employee) :single)
sql-op :var-samp (&rest args)
The var-samp function returns the sample variance of the input values (square of the sample standard deviation). Example:
(query (:select (:var-samp 'salary) :from 'employee) :single)
Window Functions
sql-op :over (form &rest args)
Over, partition-by and window are so-called window functions. A window function performs a calculation across a set of table rows that are somehow related to the current row.
(query (:select 'salary (:over (:sum 'salary)) :from 'empsalary))
sql-op :partition-by (&rest args)
Args is a list of one or more columns to partition by, optionally followed by an :order-by clause.
(query (:select 'depname 'subdepname 'empno 'salary (:over (:avg 'salary) (:partition-by 'depname 'subdepname)) :from 'empsalary))
Note the use of :order-by without parens:
(query (:select 'depname 'empno 'salary (:over (:rank) (:partition-by 'depname :order-by (:desc 'salary))) :from 'empsalary))
sql-op :window (form)
(query (:select (:over (:sum 'salary) 'w) (:over (:avg 'salary) 'w) :from 'empsalary :window (:as 'w (:partition-by 'depname :order-by (:desc 'salary)))))
sql-op :with (&rest args)
With provides a way to write auxillary statements for use in a larger query, often referred to as Common Table Expressions or CTEs.
(query (:with (:as 'upd (:parens (:update 'employees :set 'sales-count (:+ 'sales-count 1) :where (:= 'id (:select 'sales-person :from 'accounts :where (:= 'name "Acme Corporation"))) :returning '*))) (:insert-into 'employees-log (:select '* (:current-timestamp) :from 'upd))))
sql-op :with-recursive (&rest args)
Recursive modifier to a WITH statement, allowing the query to refer to its own output.
(query (:with-recursive (:as (:t1 'n) (:union-all (:values (:set 1)) (:select (:+ 'n 1) :from 't1 :where (:< 'n 100)))) (:select (:sum 'n) :from 't1))) (query (:with-recursive (:as (:included_parts 'sub-part 'part 'quantity) (:union-all (:select 'sub-part 'part 'quantity :from 'parts :where (:= 'part "our-product")) (:select 'p.sub-part 'p.part 'p.quantity :from (:as 'included-parts 'pr) (:as 'parts 'p) :where (:= 'p.part 'pr.sub-part) ))) (:select 'sub-part (:as (:sum 'quantity) 'total-quantity) :from 'included-parts :group-by 'sub-part))) (query (:with-recursive (:as (:search-graph 'id 'link 'data 'depth) (:union-all (:select 'g.id 'g.link 'g.data 1 :from (:as 'graph 'g)) (:select 'g.id 'g.link 'g.data (:+ 'sg.depth 1) :from (:as 'graph 'g) (:as 'search-graph 'sg) :where (:= 'g.id 'sg.link)))) (:select '* :from 'search-graph))) (query (:with-recursive (:as (:search-graph 'id 'link 'data'depth 'path 'cycle) (:union-all (:select 'g.id 'g.link 'g.data 1 (:[] 'g.f1 'g.f2) nil :from (:as 'graph 'g)) (:select 'g.id 'g.link 'g.data (:+ 'sg.depth 1) (:|| 'path (:row 'g.f1 'g.f2)) (:= (:row 'g.f1 'g.f2) (:any* 'path)) :from (:as 'graph 'g) (:as 'search-graph 'sg) :where (:and (:= 'g.id 'sg.link) (:not 'cycle))))) (:select '* :from 'search-graph)))
Table Functions
sql-op :for-update (query &key of nowait)
Locks the selected rows against concurrent updates. This will prevent the rows from being modified or deleted by other transactions until the current transaction ends. The :of keyword should be followed by one or more table names. If provided, PostgreSQL will lock these tables instead of the ones detected in the select statement. The :nowait keyword should be provided by itself (with no argument attached to it), after all the :of arguments. If :nowait is provided, PostgreSQL will throw an error if a table cannot be locked immediately, instead of pausing until it's possible.
(query (:for-update (:select :* :from 'foo 'bar 'baz) :of 'bar 'baz :nowait))
sql-op :for-share (query &key of nowait)
Similar to :for-update, except it acquires a shared lock on the table, allowing other transactions to perform :for-share selects on the locked tables.
sql-op :insert-into (table &rest rest)
Insert a row into a table. When the second argument is :set, the other arguments should be alternating field names and values, otherwise it should be a :select form that will produce the values to be inserted. Example:
(query (:insert-into 'my-table :set 'field-1 42 'field-2 "foobar"))
It is possible to add :returning, followed by a list of field names or expressions, at the end of the :insert-into form. This will cause the query to return the values of these expressions as a single row.
In postgresql versions 9.5 and above, it is possible to add :on-conflict-do-nothing (if the item already exists, do nothing), or :on-conflict-update (if the item already exists, update the values) followed by a list of field names which are checked for the conflict then using :update-set followed by a list of field names or expressions following the syntax for updating a table. This is sometimes called an "upsert". Note that as per the postgresql sql documentation you must prepend the table name to the column in the where statement if you are updating.
(query (:insert-into 'test-table :set 'column-A '$1 'column-B '$2 :on-conflict-update 'column-A :update-set 'column-B '$2 :where (:= 'test-table.column-A '$1)) "c" 37)
sql-op :insert-rows-into (table &rest rest)
Insert multiple rows into a table. Specify the columns first with the keyword :columns then provide a list of lists of the values as a parameter to the keyword :values. Example:
(query (:insert-rows-into 'my-table :columns 'field-1 'field-2 :values '((42 "foobar") (23 "foobaz"))))
If you will use the default columns, this can be simplified and the :columns parameters can be dropped. Example:
(query (:insert-rows-into 'my-table :values '((42 "foobar") (23 "foobaz"))))
sql-op :update (table &rest rest)
Update values in a table. After the table name there should follow the keyword :set and any number of alternating field names and values, like for :insert-into. Next comes the optional keyword :from, followed by at least one table name and then any number of join statements, like for :select. After the joins, an optional :where keyword followed by the condition, and :returning keyword followed by a list of field names or expressions indicating values to be returned as query result.
sql-op :delete-from (table &rest rest)
Delete rows from the named table. Can be given a :where argument followed by a condition, and a :returning argument, followed by one or more expressions that should be returned for every deleted row.
sql-op :create-table (name (&rest columns) &rest options)
Create a new table. The simplest example would pass two parameters, the table name and a list of lists providing information for each column. For example:
(query (:create-table 'george ((id :type integer))))
where 'george is the name of the table, it has 1 column named id which is limited to integers. There are no indexes or keys in this example.
See create-tables.html for more detailed examples.
Column Definition parameters
After the table name a list of column definitions follows, which are lists that start with a name, followed by one or more of the following keyword arguments:
- :type
This one is required. It specifies the type of the column. Use a type like (or db-null integer) to specify a column that may have NULL values.
- :default
Provides a default value for the field.
- :unique
If this argument is non-nil, the values of the column must be unique.
- :primary-key
When non-nil, the column is a primary key of the table.
- :check
Adds a constraint to this column. The value provided for this argument must be an S-SQL expression that returns a boolean value. It can refer to other columns in the table if needed.
- :references
Adds a foreign key constraint to this table. The argument provided must be a list of the form (target &optional on-delete on-update). When target is a symbol, it names the table to whose primary key this constraint refers. When it is a list, its first element is the table, and its second element the column within that table that the key refers to. on-delete and on-update can be used to specify the actions that must be taken when the row that this key refers to is deleted or changed. Allowed values are :restrict, :set-null,
- :set-default, :cascade, and :no-action.
Table Constraints
After the list of columns, zero or more extra options (table constraints) can be specified. These are lists starting with one of the following keywords:
- :check
Adds a constraint to the table. Takes a single S-SQL expression that produces a boolean as its argument.
- :primary-key
Specifies a primary key for the table. The arguments to this option are the names of the columns that this key consists of.
- :unique
Adds a unique constraint to a group of columns. Again, the arguments are a list of symbols that indicate the relevant columns.
- :foreign-key
Create a foreign key. The arguments should have the form (columns target &optional on-delete on-update), where columns is a list of columns that are used by this key, while the rest of the arguments have the same meaning as they have in the :references option for columns. Every list can start with :constraint name to create a specifically named constraint.
Note that, unlike most other operators, :create-table expects most of its arguments to be unquoted symbols. The exception to this is the value of :check constraints: These must be normal S-SQL expressions, which means that any column names they contain should be quoted. When programmatically generating table definitions, sql-compile is usually more practical than the sql macro.
Here is an example of a :create-table form:
(:create-table enemy ((name :type string :primary-key t) (age :type integer) (address :type (or db-null string) :references (important-addresses :cascade :cascade)) (fatal-weakness :type text :default "None") (identifying-color :type (string 20) :unique t)) (:foreign-key (identifying-color) (colors name)) (:constraint enemy-age-check :check (:> 'age 12)))
For more detail and examples on building tables using the s-sql approach, see create-tables.html
sql-op :alter-table (name action &rest args)
Alters named table. Currently changing a column's data type is not supported. The meaning of args depends on action:
- :add-column
Adds column to table. args should be a column in the same form as for :create-table.
- :drop-column
Drops a column from the table.
- :add-constraint
Adds a named constraint to the table.
- :drop-constraint
Drops constraint. First of args should name a constraint to be dropped; second, optional argument specifies behaviour regarding objects dependent on the constraint and it may equal :cascade or :restrict.
- :add
Adds an unnamed constraint to table. args should be a constraint in the same form as for :create-table. (This is for backwards-compatibility, you should use named constraints.)
- :rename
Adds the ability to rename a table.
- :rename-column
Adds the ability to rename a column of a table.
Here is an example using the table defined above:
(query (alter-table enemy :drop-constraint enemy-age-check)) (query (:alter-table enemy :add-constraint enemy-age-check :check (:> 'age 21)))
sql-op :drop-table (name)
Drops the named table. You may optionally pass :if-exists before the name to suppress the error message. You can also optionally pass :cascade after the name to indicate that it should also drop any other tables, indices, etc which depend on that table.
(query (:drop-table 'table1)) (query (:drop-table :if-exists 'table1)) (query (:drop-table :if-exists 'table1 :cascade))
sql-op :truncate (&rest args)
Truncates one or more tables, deleting all the rows. Optional keyword arguments are allowed in the following order. Note that :continue-identity and :restart-identity make no sense if both are included.
- :only (if not specified, the table and its descendants are truncated).
- :continue-identity (the values of sequences will not be changed. This is the default)
- :restart-identity (the values of sequences owned by the table(s) will be restarted)
- :cascade (will cascade the truncation through tables using foreign keys.)
Example calls would be:
(query (:truncate 'bigtable 'fattable)) (query (:truncate 'bigtable 'fattable :only)) (query (:truncate 'bigtable 'fattable :only :continue-identity)) (query (:truncate 'bigtable 'fattable :restart-identity)) (query (:truncate 'bigtable 'fattable :only :restart-identity :cascade ))
sql-op :create-index (name &rest args)
Create an index on a table. After the name of the index the keyword :on should follow, with the table name after it. Then the keyword :fields, followed by one or more column names. Optionally, a :where clause with a condition can be added at the end to make a partial index.
(sql (:create-index 'gin-idx :on "historical-events" :using gin :fields 'data)) "CREATE INDEX gin_idx ON historical_events USING GIN (data)"
sql-op :create-unique-index (name &rest args)
Works like :create-index, except that the index created is unique.
sql-op :drop-index (name)
Drop an index. Takes :if-exists and/or :cascade arguments like :drop-table.
(query (:drop-index 'index1)) (query (:drop-index :if-exists 'index1)) (query (:drop-index :if-exists 'index1 :cascade))
sql-op :create-sequence (name &key increment min-value max-value start cache cycle)
Create a sequence with the given name. The rest of the arguments control the way the sequence selects values.
sql-op :alter-sequence (name)
Alters a sequence. See Postgresql documentation for parameters.
- :increment
Sets the amount by which each subsequent increment will be increased.
- :min-value
- :max-value
- :no-min
- :no-max
- :start
- :restart
- :cache
- :cycle
- :no-cycle
- :owned-by
- :if-exists before the name to suppress the error message.
sql-op :drop-sequence (name)
Drop a sequence. Takes :if-exists and/or :cascade arguments like :drop-table.
(query (:drop-sequence 'sequence1)) (query (:drop-sequence :if-exists 'sequence1)) (query (:drop-sequence :if-exists 'sequence1 :cascade))
sql-op :create-view (name query)
Create a view from an S-SQL-style query.
sql-op :drop-view (name)
Drop a view. Takes optional :if-exists argument.
sql-op :set-constraints (state &rest constraints)
Configure whether deferrable constraints should be checked when a statement is executed, or when the transaction containing that statement is completed. The provided state must be either :immediate, indicating the former, or :deferred, indicating the latter. The constraints must be either the names of the constraints to be configured, or unspecified, indicating that all deferrable constraints should be thus configured.
sql-op :listen (channel)
Tell the server to listen for notification events on channel channel, a string, on the current connection.
sql-op :unlisten (channel)
Stop listening for events on channel.
sql-op :notify (channel &optional payload)
Signal a notification event on channel channel, a string. The optional payload string can be used to send additional event information to the listeners.
sql-op :create-role (role &rest args)
Create a new role (user). Following the role name are optional keywords arguments:
- :options
One or more of the no-parameter options to PostgreSQL's CREATE ROLE SQL command.
- :password
Sets the role's password. (A password is only of use for roles having the LOGIN attribute, but you can nonetheless define one for roles without it.) If you do not plan to use password authentication you can omit this option. If no password is specified, the password will be set to null and password authentication will always fail for that user.
- :connection-limit
If role can log in, this specifies how many concurrent connections the role can make. -1 (the default) means no limit.
- :valid-until
The :valid-until clause sets a date and time after which the role's password is no longer valid. If this clause is omitted the password will be valid for all time.
- :role
Lists one or more existing roles which are automatically added as members of the new role. (This in effect makes the new role a “group”.)
- :in-role
Lists one or more existing roles to which the new role will be immediately added as a new member.
Here is an example of a :create-role form:
(query (:create-role 'user23 :options 'SUPERUSER 'NOINHERIT 'LOGIN :password "mypassword" :connection-limit 100 :role 'users))
sql-op :create-database (name)
Create a new database with the given name.
sql-op :drop-database (name)
Drops the named database. You may optionally pass :if-exists before the name to suppress the error message.
(query (:drop-database 'database-name)) (query (:drop-database :if-exists 'database-name))
sql-op :copy (table &rest args)
Move data between Postgres tables and filesystem files. Table name is required followed by one or more of the following keyword arguments. Documentation for the copy command provides a full reference. An example from the Greenplum tutorial:
(query (:copy 'faa.d_airlines :columns 'airlineid 'airline_desc :from "/home/gpadmin/gpdb-sandbox-tutorials/faa/L_AIRLINE_ID.csv" :on-segment t :binary t :oids t :header t :delimiter "," :null "NULL" :escape "my-escape-string" :newline "CR" :csv t :log-errors t :segment-reject-limit 100 'ROWS))


{% extends "blog/base.html" %} {% block content %}
This is a Cloud Computing Project.
{% endblock content %}


Hello, my name is Maalik McBurrows. I am a software developer who is very passionate about technology and learning as much as I can to improve my software engineering prowess. Along with my technical aptitude I have experience working in the service industry, where I further honed in on my communication and customer service abilities, all while juggling a full time college course load. My coding skills include programming languages including, but not limited to JavaScript, React.js, Python, Node.js, PostgreSQL, HTML, CSS, and Git.
Project that utilizes the Ticketmaster and Google Maps APIs in order to get geolocation of user and provide events/venues in the area. Uses HTML, CSS, and Javascript for the front end UI. To view GitHub click here
The Insta-Tracker app was designed to show a plethora of up to date information regarding the novel COVID-19 global pandemic. The app includes: the latest YouTube video updates from the CDC’s COVID-19 playlist, the latest tweets from the CDC’s Twitter account , several news articles regarding the pandemic, as well as U.S. totals for positive tests, total deaths, from each state/territory. here
This is a React based project that I built using the iTunes API. This interactive website allows the user to search any of their favorite artists and retrieve and play all of their albums. This project is still under construction but I have plans to change API call to the actual Apple Music database so users can play full songs and also get song and artist results instead of just albums. I also plan on adding a member feature where anyone can sign up and it allows them to leave reviews and likes on albums as well as follow their friends and see what they are listening to. here


--- layout: page heading: Contact ---
We customize potraits, paintings and any other artwork you have in mind.


{% extends "base.html" %} {% block title %}Thanks for the comment{% endblock %} {% block content %}
Thanks for contributing.


I was sold 6 hits of what was supposed to be LSD (white on white blotter). I went home and started drinking with some friends, and after about 7 drinks I decided I wanted to take the acid I bought. As a note, I am a VERY experienced tripper, having tripped on many RC's, LSD, Mushrooms, and Mescaline. I have also done LSD many times while drinking, and each time has been enjoyable. This time would be different.
12:00am - I dropped all 6 hits of the blotter.
1:00am - The alcohol seemed to be getting stronger (I have a high tolerance, and I had stopped drinking by midnight. This was the first sign that something wasn't right)
2:00am - I completely blacked out
8:00am - I came to experiencing intense visuals, a body load similar to, but stronger than 2c-x drugs
12:00pm - I was still peaking, the visuals were oddly colorful. They seemed to be part of another dimension, and did not directly interact with the real world.
4:00pm - I had come down enough to function, but there were weak visuals and a strong speedy sensation
10:00pm - Visuals were still present, the body load became miserable. Sleep was impossible.
12:00am - I couldn't believe it was still going.
1:00am - I took a few Ativan, and finally was able to get to sleep. I had strange dreams throughout the night, and woke up early.
The trip was entirely not fun, and lasted over 24 hours. I later learned from my friends that from 2:00am until I came to, I had become violent and agitated. This came as a surprise to me, since at first I thought I took Acid. After reading PiHKAL (and various reports on Erowid), I determined the substance in question was a DOx - more than likely DOB. This trip destroyed my love of psychedelic chemicals, and I can't help but wonder what could motivate someone to pass off a chemical like DOB as LSD.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


Teens Are Posting Pics Of The Fake Halloween Outfits They Used To Fool Their Strict Parents
by Michelle RennexIf you grew up with strict parents, you know the struggle of trying to get away with wearing the actually fun Halloween outfit you really want.
And Trisha, a college student from UCLA, is no stranger to this.
For Halloween this year Trisha decided that she wanted to go as a referee, with a bit of a twist. But before setting off for the night and wearing the outfit she had planned, she snapped a photo of the original costume and sent it to her dad.
She then uploaded her real costume, and the one her parents saw onto Twitter, where it went viral.
For Trisha’s actual outfit, she cut her shirt and switched to shorts, while her parents thought she wore the t-shirt and leggings combo she sent them prior.
For the record, her dad thought the look was “very nice 👍”.
After getting over 400,000 likes in a day, the tweet inspired other other teens with equally strict parents to share their photos too.
Some even did almost full outfit changes after taking a snap for mum and dad.
And others even went so far as to draw on fake shirts to help fool their unsuspecting parents.
While one Twitter user suggested Trisha make her account private in case her parents saw her tweet, she replied: “girl the damage has been done, I’ll see y’all in my next life.”
Ah, teens. They’re just like you and me.


Functions | |
| static void | CACHE_setMemRegionWritethrough (Uint8 mar, Bool arg) |
| static void | CACHE_getMemRegionWritethrough (Uint8 mar, Uint8 *wte) |
| static void | CACHE_enableCaching (Uint8 mar) |
| static void | CACHE_disableCaching (Uint8 mar) |
| static void | CACHE_getMemRegionInfo (Uint8 mar, Uint8 *pcx, Uint8 *pfx) |
| static void | CACHE_setMemRegionInfo (Uint8 mar, Uint8 pcx, Uint8 pfx) |
| static void | CACHE_setL1DSize (CACHE_L1Size newSize) |
| static CACHE_L1Size | CACHE_getL1DSize (void) |
| static void | CACHE_freezeL1D (void) |
| static void | CACHE_unfreezeL1D (void) |
| static Uint32 | CACHE_getPrevL1DMode (void) |
| static void | CACHE_invAllL1dWait (void) |
| static void | CACHE_invAllL1d (CACHE_Wait wait) |
| static void | CACHE_wbAllL1dWait (void) |
| static void | CACHE_wbAllL1d (CACHE_Wait wait) |
| static void | CACHE_wbInvAllL1dWait (void) |
| static void | CACHE_wbInvAllL1d (CACHE_Wait wait) |
| static void | CACHE_invL1dWait (void) |
| static void | CACHE_invL1d (const void *blockPtr, Uint32 byteCnt, CACHE_Wait wait) |
| static void | CACHE_wbL1dWait (void) |
| static void | CACHE_wbL1d (const void *blockPtr, Uint32 byteCnt, CACHE_Wait wait) |
| static void | CACHE_wbInvL1dWait (void) |
| static void | CACHE_wbInvL1d (const void *blockPtr, Uint32 byteCnt, CACHE_Wait wait) |
| static void | CACHE_setL1PSize (CACHE_L1Size newSize) |
| static CACHE_L1Size | CACHE_getL1PSize (void) |
| static void | CACHE_freezeL1P (void) |
| static void | CACHE_unfreezeL1P (void) |
| static Uint32 | CACHE_getPrevL1PMode (void) |
| static void | CACHE_invL1pWait (void) |
| static void | CACHE_invL1p (const void *blockPtr, Uint32 byteCnt, CACHE_Wait wait) |
| static void | CACHE_invAllL1pWait (void) |
| static void | CACHE_invAllL1p (CACHE_Wait wait) |
| static void | CACHE_setL2Size (CACHE_L2Size newSize) |
| static CACHE_L2Size | CACHE_getL2Size (void) |
| static void | CACHE_freezeL2 (void) |
| static void | CACHE_unfreezeL2 (void) |
| static void | CACHE_wbL2Wait (void) |
| static void | CACHE_wbL2 (const void *blockPtr, Uint32 byteCnt, CACHE_Wait wait) |
| static void | CACHE_invL2Wait (void) |
| static void | CACHE_invL2 (const void *blockPtr, Uint32 byteCnt, CACHE_Wait wait) |
| static void | CACHE_wbInvL2Wait (void) |
| static void | CACHE_wbInvL2 (const void *blockPtr, Uint32 byteCnt, CACHE_Wait wait) |
| static void | CACHE_wbAllL2Wait (void) |
| static void | CACHE_wbAllL2 (CACHE_Wait wait) |
| static void | CACHE_invAllL2Wait (void) |
| static void | CACHE_invAllL2 (CACHE_Wait wait) |
| static void | CACHE_wbInvAllL2Wait (void) |
| static void | CACHE_wbInvAllL2 (CACHE_Wait wait) |
|
inlinestatic |
============================================================================
CACHE_disableCaching
Description
This function disables caching for a specific memory region.
Arguments
mar Memory region for which cache is to be disabled.
Return Value
None
Pre Condition
None
Post Condition
Memory region is now not cacheable.
Writes
CGEM_MAR0_PC=0
Example
CACHE_disableCaching (20);
|
inlinestatic |
============================================================================
CACHE_enableCaching
Description
This function enables caching for a specific memory region.
Arguments
mar Memory region for which cache is to be enabled.
Return Value
None
Pre Condition
None
Post Condition
Memory region is now cacheable.
Writes
CGEM_MAR0_PC=1
Example
CACHE_enableCaching (20);
|
inlinestatic |
============================================================================
CACHE_freezeL1D
Description
This function is used to freeze the L1D cache.
Arguments
None
Return Value
None
Pre Condition
None
Post Condition
None
Writes
CGEM_L1DCC_OPER=1
Example
CACHE_freezeL1D();
|
inlinestatic |
============================================================================
CACHE_freezeL1P
Description
This function is used to freeze the L1P cache.
Arguments
None
Return Value
None
Pre Condition
None
Post Condition
None
Writes
CGEM_L1PCC_OPER=1
Example
CACHE_freezeL1P();
|
inlinestatic |
============================================================================
CACHE_freezeL2
Description
This function is used to freeze the L2 Cache
Arguments
None
Return Value
None
Pre Condition
None
Post Condition
The L2 Cache is frozen.
Example
CACHE_freezeL2();
|
inlinestatic |
============================================================================
CACHE_getL1DSize
Description
This function is used to get the L1 Data Cache Size.
Arguments
None
Return Value
None
Pre Condition
None
Post Condition
None
Reads
CGEM_L1DCFG_L1DMODE
Example
CACHE_L1Size cacheSize; cacheSize = CACHE_getL1DSize();
|
inlinestatic |
============================================================================
CACHE_getL1PSize
Description
This function is used to get the L1P Cache Size.
Arguments
None
Return Value
None
Pre Condition
None
Post Condition
None
Reads
CGEM_L1PCFG_L1PMODE
Example
CACHE_L1Size cacheSize; cacheSize = CACHE_getL1PSize();
|
inlinestatic |
============================================================================
CACHE_getL2Size
Description
This function is used to get the L2 cache size.
Arguments
None
Return Value
CACHE_L2Size
Pre Condition
None
Post Condition
None
Reads
CGEM_L2CFG_L2MODE
Example
CACHE_L2Size size; size = CACHE_getL2Size();
|
inlinestatic |
============================================================================
CACHE_getMemRegionInfo
Description
This function is used to get memory region information.
Arguments
mar Memory region for which the information is required. pcx Is address cacheable in external cache (MSMC) pfx Is address prefetchable
Return Value
None
Pre Condition
None
Post Condition
None
Reads
CGEM_MAR0_PCX, CGEM_MAR0_PFX
Example
Uint8 pcx; Uint8 pfx; // Get the memory region information for 20 CACHE_getMemRegionInfo (20, &pcx, &pfx);
|
inlinestatic |
============================================================================
CACHE_getMemRegionWritethrough
Description
This function gets write through mode for a specific memory region.
Arguments
mar Memory region for which WTE bit information to be read. wte Address of WTE value
Return Value
None
Pre Condition
None
Post Condition
WTE bit value reflecting the write through mode is returned.
Writes
None
Example
CACHE_getMemRegionWritethrough (20, &wte);
|
inlinestatic |
============================================================================
CACHE_getPrevL1DMode
Description
This function is used get the previous operating state of the L1D cache
Arguments
None
Return Value
None
Pre Condition
None
Post Condition
None
Reads
CGEM_L1DCC_POPER
Example
Uint32 prev; prev = CACHE_getPrevL1DMode();
|
inlinestatic |
============================================================================
CACHE_getPrevL1PMode
Description
This function is used get the previous operating state of the L1P cache
Arguments
None
Return Value
None
Pre Condition
None
Post Condition
None
Reads
CGEM_L1PCC_POPER
Example
Uint32 prev; prev = CACHE_getPrevL1PMode();
|
inlinestatic |
============================================================================
CACHE_invAllL1d
Description
This function is used to globally invalidate the L1D cache.
Arguments
wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
The L1D Cache is being invalidated.
Writes
CGEM_L1DINV_I=1
Example
CACHE_invAllL1d(CACHE_WAIT); // Invalidate the L1D cache
|
inlinestatic |
============================================================================
CACHE_invAllL1dWait
Description
This function is used to wait for the L1D global invalidate operation to complete. This API should be used only if the CACHE_invAllL1d was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_invAllL1d(wait=CACHE_NOWAIT) must be called.
Post Condition
None
Reads
CGEM_L1DINV_I=0
Example
CACHE_invAllL1d(CACHE_NOWAIT); // Invalidate the L1D cache ... CACHE_invAllL1dWait(); // Wait for the invalidate operation to complete.
|
inlinestatic |
============================================================================
CACHE_invAllL1p
Description
This function is used to invalidate the entire L1P Cache
Arguments
wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
The entire L1P cache is being invalidated.
Writes
CGEM_L1PINV_I=1
Example
CACHE_invAllL1p(CACHE_WAIT);
|
inlinestatic |
============================================================================
CACHE_invAllL1pWait
Description
This function is used to wait for the L1P invalidate operation to complete. This API should be used only if the CACHE_invAllL1p was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_invAllL1p(wait=CACHE_NOWAIT) must be called.
Post Condition
The L1P Cache is invalidated.
Reads
CGEM_L1PINV_I=0
Example
CACHE_invAllL1p(CACHE_NOWAIT); ... CACHE_invAllL1pWait(); // Wait for the Invalidate operation to complete.
|
inlinestatic |
============================================================================
CACHE_invAllL2
Description
This function is used to invalidate all the contents of the L2 Cache.
Arguments
wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
The contents of the L2 Cache are being invalidated.
Writes
CGEM_L2INV_I=1
Example
// Invalidate the contents of the L2 Cache. CACHE_invAllL2(CACHE_WAIT);
|
inlinestatic |
============================================================================
CACHE_invAllL2Wait
Description
This function is used to wait for the L2 Invalidate operation to complete. This API should be used only if the CACHE_invAllL2 was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_invAllL2(wait=CACHE_NOWAIT) must be called.
Post Condition
The contents of the L2 Cache have been invalidated
Reads
CGEM_L2INV_I=0
Example
// Invalidate the contents of the L2 Cache. CACHE_invAllL2(CACHE_NOWAIT); // Wait for the operation to complete. CACHE_invAllL2Wait();
|
inlinestatic |
============================================================================
CACHE_invL1d
Description
This function is used to invalidate a block in the L1D Cache. Although the block size can be specified in the number of bytes, the cache controller operates on whole cache lines. To prevent unintended behavior "blockPtr" should be aligned on the cache line size and "byteCnt" should be a multiple of the cache line size.
Arguments
blockPtr Address of the block which is to be invalidated byteCnt Size of the block to be invalidated. wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
The contents of the blockPtr are being invalidated
Writes
CGEM_L1DIBAR_ADDR,CGEM_L1DIWC_WC
Example
Uint8* ptr_buffer; // Invalidate 128 bytes of the buffer. CACHE_invL1d((void *)ptr_buffer, 128, CACHE_WAIT);
|
inlinestatic |
============================================================================
CACHE_invL1dWait
Description
This function is used to wait for the L1D invalidate block operation to complete. This API should be used only if the CACHE_invL1d was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_invL1d(wait=CACHE_NOWAIT) must be called.
Post Condition
The L1D Block Cache is invalidated.
Reads
CGEM_L1DIWC_WC=0
Example
CACHE_invL1d((void *)ptr_buffer, 128, CACHE_NOWAIT); ... CACHE_invL1dWait(); // Wait for the Invalidate/Writeback operation to complete.
|
inlinestatic |
============================================================================
CACHE_invL1p
Description
This function is used to invalidate the L1P Cache pointed by the block address. Although the block size can be specified in the number of bytes, the cache controller operates on whole cache lines. To prevent unintended behavior "blockPtr" should be aligned on the cache line size and "byteCnt" should be a multiple of the cache line size.
Arguments
blockPtr Address of the block which is to be invalidated byteCnt Size of the block to be invalidated. wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
The contents of the blockPtr are being invalidated
Writes
CGEM_L1PIBAR_ADDR,CGEM_L1PIWC_WC
Example
// Invalidate the 128 bytes of the function 'foo' CACHE_invL1p((void *)&foo, 128, CACHE_WAIT);
|
inlinestatic |
============================================================================
CACHE_invL1pWait
Description
This function is used to wait for the L1D invalidate block operation to complete. This API should be used only if the CACHE_invL1p was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_invL1p(wait=CACHE_NOWAIT) must be called.
Post Condition
The L1D Block Cache is invalidated.
Reads
CGEM_L1PIWC_WC=0
Example
CACHE_invL1p((void *)&foo, 128, CACHE_NOWAIT); ... CACHE_invL1pWait(); // Wait for the Invalidate operation to complete.
|
inlinestatic |
============================================================================
CACHE_invL2
Description
This function is used to invalidate the contents of the L2 Cache. Although the block size can be specified in the number of bytes, the cache controller operates on whole cache lines. To prevent unintended behavior "blockPtr" should be aligned on the cache line size and "byteCnt" should be a multiple of the cache line size.
Arguments
blockPtr Address of the block which is to be invalidated byteCnt Size of the block to be invalidated. wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
The contents of the L2 Cache are being invalidated.
Writes
CGEM_L2IBAR_ADDR,CGEM_L2IWC_WC
Example
Uint8* ptr_buffer; // Invalidate the contents of the buffer. CACHE_invL2(ptr_buffer, 100, CACHE_WAIT);
|
inlinestatic |
============================================================================
CACHE_invL2Wait
Description
This function is used to wait for the L2 invalidate block operation to complete. This API should be used only if the CACHE_invL2 was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_invL2(wait=CACHE_NOWAIT) must be called.
Post Condition
Invalidate the contents of the L2 Cache.
Reads
CGEM_L2IWC_WC=0
Example
CACHE_invL2((void *)ptr_buffer, 128, CACHE_NOWAIT); ... CACHE_invL2Wait(); // Wait for the Invalidate operation to complete.
|
inlinestatic |
============================================================================
CACHE_setL1DSize
Description
This function is used to set the L1 Data Cache Size.
Arguments
newSize Cache Size to be configured.
Return Value
None
Pre Condition
None
Post Condition
None
Writes
CGEM_L1DCFG_L1DMODE
Example
CACHE_setL1DSize(1); // Configure 4K Cache Size
|
inlinestatic |
============================================================================
CACHE_setL1PSize
Description
This function is used to set the L1P Cache Size.
Arguments
newSize Cache Size to be configured.
Return Value
None
Pre Condition
None
Post Condition
None
Writes
CGEM_L1PCFG_L1PMODE
Example
CACHE_setL1PSize(1); // Configure 4K Cache Size
|
inlinestatic |
============================================================================
CACHE_setL2Size
Description
This function is used to set the new size of the L2 Cache.
Arguments
newSize New Size of the L2 Cache to be set.
Return Value
None
Pre Condition
None
Post Condition
The L2 Cache is configured to use the new size.
Writes
CGEM_L2CFG_L2MODE
Example
CACHE_setL2Size(CACHE_32KCACHE); // Use 32K L2 Cache.
|
inlinestatic |
============================================================================
CACHE_setMemRegionInfo
Description
This function is used to set memory region information.
Arguments
mar Memory region for which the information is required. pcx Is address cacheable in external cache (MSMC) pfx Is address prefetchable
Return Value
None
Pre Condition
None
Post Condition
None
Writes
CGEM_MAR0_PCX, CGEM_MAR0_PFX
Example
Uint8 pcx; Uint8 pfx; // Get the memory region information for 20 CACHE_getMemRegionInfo (20, &pcx, &pfx); ... // Ensure Memory Region 20 is not prefetchable. CACHE_setMemRegionInfo(20, pcx, 0);
|
inlinestatic |
============================================================================
CACHE_setMemRegionWritethrough
Description
This function sets write through mode for a specific memory region.
Arguments
mar Memory region for which cache is to be set to writethrough mode. arg TRUE to set to write through mode, otherwise to wribeback mode.
Return Value
None
Pre Condition
None
Post Condition
Memory region is now set to writethrough mode.
Writes
CGEM_MAR0_WTE=1, when arg == TRUE, zero otherwise
Example
CACHE_setMemRegionWritethrough (20, TRUE);
|
inlinestatic |
============================================================================
CACHE_unfreezeL1D
Description
This function is used to unfreeze the L1D cache.
Arguments
None
Return Value
None
Pre Condition
None
Post Condition
None
Writes
CGEM_L1DCC_OPER=0
Example
CACHE_unfreezeL1D();
|
inlinestatic |
============================================================================
CACHE_unfreezeL1P
Description
This function is used to unfreeze the L1D cache.
Arguments
None
Return Value
None
Pre Condition
None
Post Condition
None
Writes
CGEM_L1PCC_OPER=0
Example
CACHE_unfreezeL1D();
|
inlinestatic |
============================================================================
CACHE_unfreezeL2
Description
This function is used to unfreeze the L2 Cache
Arguments
None
Return Value
None
Pre Condition
None
Post Condition
The L2 Cache is unfrozen
Example
CACHE_unfreezeL2();
|
inlinestatic |
============================================================================
CACHE_wbAllL1d
Description
This function is used to writeback the dirty lines of the L1D Cache
Arguments
wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
The dirty lines of the L1D Cache are being written back
Writes
CGEM_L1DWB_C=1
Example
CACHE_wbAllL1d(CACHE_WAIT); // Writeback the Dirty Lines of the L1D cache
|
inlinestatic |
============================================================================
CACHE_wbAllL1dWait
Description
This function is used to wait for the L1D writeback operation to complete. This API should be used only if the CACHE_wbAllL1d was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_wbAllL1d(wait=CACHE_NOWAIT) must be called.
Post Condition
The L1D Dirty lines are written back
Reads
CGEM_L1DWB_C=0
Example
CACHE_wbAllL1d(CACHE_NOWAIT); // Writeback the L1D cache ... CACHE_wbAllL1dWait(); // Wait for the writeback operation to complete.
|
inlinestatic |
============================================================================
CACHE_wbAllL2
Description
This function is used to write back all the contents of the L2 Cache.
Arguments
wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
The contents of the L2 Cache are being written back.
Writes
CGEM_L2WB_C=1
Example
// Writeback the contents of the L2 Cache. CACHE_wbAllL2(CACHE_WAIT);
|
inlinestatic |
============================================================================
CACHE_wbAllL2Wait
Description
This function is used to wait for the L2 Writeback & invalidate operation to complete. This API should be used only if the CACHE_wbAllL2 was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_wbAllL2(wait=CACHE_NOWAIT) must be called.
Post Condition
The contents of the L2 Cache have been written back
Reads
CGEM_L2WB_C=0
Example
// Writeback the contents of the L2 Cache. CACHE_wbAllL2(CACHE_NOWAIT); // Wait for the operation to complete. CACHE_wbAllL2Wait();
|
inlinestatic |
============================================================================
CACHE_wbInvAllL1d
Description
This function is used to invalidate and writeback the dirty lines of the L1D Cache
Arguments
wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
Invalidates and Writebacks the dirty lines of the L1D Cache
Writes
CGEM_L1DWBINV_C=1
Example
CACHE_wbInvAllL1d(CACHE_WAIT);
|
inlinestatic |
============================================================================
CACHE_wbInvAllL1dWait
Description
This function is used to wait for the L1D writeback invalidate operation to complete. This API should be used only if the CACHE_wbInvAllL1d was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_wbInvAllL1d(wait=CACHE_NOWAIT) must be called.
Post Condition
The L1D Dirty lines are written back
Reads
CGEM_L1DWBINV_C=0
Example
CACHE_wbInvAllL1d(CACHE_NOWAIT); // Invalidate/Writeback the L1D cache ... CACHE_wbInvAllL1dWait(); // Wait for the Invalidate/Writeback operation to complete.
|
inlinestatic |
============================================================================
CACHE_wbInvAllL2
Description
This function is used to writeback and invalidate all the contents of the L2 Cache.
Arguments
wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
The contents of the L2 Cache are being written back & invalidated.
Writes
CGEM_L2WBINV_C=1
Example
// Invalidate the contents of the L2 Cache. CACHE_wbInvAllL2(CACHE_WAIT);
|
inlinestatic |
============================================================================
CACHE_wbInvAllL2Wait
Description
This function is used to wait for the L2 Writeback and Invalidate operation to complete. This API should be used only if the CACHE_wbInvAllL2 was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_wbInvAllL2(wait=CACHE_NOWAIT) must be called.
Post Condition
The contents of the L2 Cache have been invalidated and written back
Reads
CGEM_L2WBINV_C=0
Example
// Writeback & Invalidate the contents of the L2 Cache. CACHE_wbInvAllL2(CACHE_NOWAIT); // Wait for the operation to complete. CACHE_wbInvAllL2Wait();
|
inlinestatic |
============================================================================
CACHE_wbInvL1d
Description
This function is used to invalidate and writeback the dirty lines of the block address. Although the block size can be specified in the number of bytes, the cache controller operates on whole cache lines. To prevent unintended behavior "blockPtr" should be aligned on the cache line size and "byteCnt" should be a multiple of the cache line size.
Arguments
blockPtr Address of the block which is to be invalidated/written back byteCnt Size of the block to be invalidated/written back. wait Indicates if the call should block or not.
 CACHE_wbInvL1d((void *)ptr_buffer, 128, CACHE_WAIT);
|
inlinestatic |
============================================================================
CACHE_wbInvL1dWait
Description
This function is used to wait for the L1D invalidate/writeback block operation to complete. This API should be used only if the CACHE_wbInvL1d was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_wbInvL1d(wait=CACHE_NOWAIT) must be called.
Post Condition
The dirty lines of the L1D Block Cache have been written back and the cache contents pointed to by the block address are also invalidated.
Reads
CGEM_L1DWIWC_WC=0
Example
CACHE_wbInvL1d((void *)ptr_buffer, 128, CACHE_NOWAIT); ... CACHE_wbInvL1dWait(); // Wait for the operation to complete.
|
inlinestatic |
============================================================================
CACHE_wbInvL2
Description
This function is used to write back and invalidate the contents of the L2 Cache. Although the block size can be specified in the number of bytes, the cache controller operates on whole cache lines. To prevent unintended behavior "blockPtr" should be aligned on the cache line size and "byteCnt" should be a multiple of the cache line size.
Arguments
blockPtr Address of the block which is to be written back & invalidated byteCnt Size of the block to be written back & invalidated. wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
The contents of the L2 Cache are being written back & invalidated.
Writes
CGEM_L2WIBAR_ADDR,CGEM_L2WIWC_WC
Example
Uint8* ptr_buffer; // Invalidate the contents of the buffer. CACHE_wbInvL2(ptr_buffer, 100, CACHE_WAIT);
|
inlinestatic |
============================================================================
CACHE_wbInvL2Wait
Description
This function is used to wait for the L2 Writeback & invalidate block operation to complete. This API should be used only if the CACHE_wbInvL2 was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_wbInvL2(wait=CACHE_NOWAIT) must be called.
Post Condition
Invalidate the contents of the L2 Cache.
Reads
CGEM_L2WIWC_WC=0
Example
CACHE_wbInvL2((void *)ptr_buffer, 128, CACHE_NOWAIT); ... CACHE_wbInvL2Wait(); // Wait for the Writeback-Invalidate operation to complete.
|
inlinestatic |
============================================================================
CACHE_wbL1d
Description
This function is used to writeback the dirty lines of the block address. Although the block size can be specified in the number of bytes, the cache controller operates on whole cache lines. To prevent unintended behavior "blockPtr" should be aligned on the cache line size and "byteCnt" should be a multiple of the cache line size.
Arguments
blockPtr Address of the block which is to be written back byteCnt Size of the block to be written back. wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
The contents of the blockPtr are being written back
Writes
CGEM_L1DWBAR_ADDR,CGEM_L1DWWC_WC
Example
Uint8* ptr_buffer; // Writeback 128 bytes of the buffer. CACHE_wbL1d((void *)ptr_buffer, 128, CACHE_WAIT);
|
inlinestatic |
============================================================================
CACHE_wbL1dWait
Description
This function is used to wait for the L1D writeback block operation to complete. This API should be used only if the CACHE_wbL1d was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_wbL1d(wait=CACHE_NOWAIT) must be called.

Reads
CGEM_L1DWWC_WC=0
Example
CACHE_wbL1d((void *)ptr_buffer, 128, CACHE_NOWAIT); ... CACHE_wbL1dWait(); // Wait for the writeback operation to complete.
|
inlinestatic |
============================================================================
CACHE_wbL2
Description
This function is used to writeback the contents of the L2 Cache. Although the block size can be specified in the number of bytes, the cache controller operates on whole cache lines. To prevent unintended behavior "blockPtr" should be aligned on the cache line size and "byteCnt" should be a multiple of the cache line size.
Arguments
blockPtr Address of the block which is to be written back byteCnt Size of the block to be written block. wait Indicates if the call should block or not.
Return Value
None
Pre Condition
None
Post Condition
The dirty lines of the L2 Cache are being written back.
Writes
CGEM_L2WBAR_ADDR,CGEM_L2WWC_WC
Example
Uint8* ptr_buffer; // Writeback the contents of the buffer. CACHE_wbL2(ptr_buffer, 100, CACHE_WAIT);
|
inlinestatic |
============================================================================
CACHE_wbL2Wait
Description
This function is used to wait for the L2 writeback block operation to complete. This API should be used only if the CACHE_wbL2 was called with the CACHE_NOWAIT argument.
Arguments
None
Return Value
None
Pre Condition
CACHE_wbL2(wait=CACHE_NOWAIT) must be called.

Reads
CGEM_L2WWC_WC=0
Example
CACHE_wbL2((void *)ptr_buffer, 128, CACHE_NOWAIT); ... CACHE_wbL2Wait(); // Wait for the writeback operation to complete.


{% extends "base.html" %} {% block page_title %}Downloads{% endblock %} {% block class %}downloads{% endblock %} {% block content %}
For your convenience, here you can find commonly requested documents for download. All downloads are in PDF format and require Adobe Reader or equivalent.
Ohio HD Video @The Backlot 3465 Noe Bixby Rd Columbus, Ohio 43232
Pickup / Drop-off Gear Open Weekdays 9am - 5pm
Phone:<PHONE_NUMBER> Fax:<PHONE_NUMBER> Email<EMAIL_ADDRESS>Located 15 minutes South East of Downtown Columbus. Download directions if you need help finding us.


--- layout: post title: "Software design isomorphisms" description: "When programming, you can often express the same concept in multiple ways. If you can losslessly translate between two alternatives, it's an isomorphism. An introduction for object-oriented programmers." date: 2018-01-08 8:35 UTC tags: [Software Design] image: "/content/binary/isomorphism.png" image_alt: "Isomorphism diagram." --- {% include JB/setup %}
{{ page.description }}
This article series is part of an even larger series of articles about the relationship between design patterns and category theory.
There's a school of functional programming that looks to category theory for inspiration, verification, abstraction, and cross-pollination of ideas.  There are often good reasons for using abstract naming. In any case, one term from category theory that occasionally makes the rounds is isomorphism.
Don't let the terminology daunt you. An isomorphism is an easy enough concept to grasp. In essence, two things are isomorphic if you can translate losslessly back and forth between them. It's a formalisation of equivalence.
 Just consider this C# example from my Humane Code video:
public bool IsSatisfiedBy(Customer candidate) { bool retVal; if (candidate.TotalPurchases >= 10000) retVal = true; else retVal = false; return retVal; }
which is equivalent to this:
public bool IsSatisfiedBy(Customer candidate) { return candidate.TotalPurchases >= 10000; }
An outside observer can't tell the difference between these two implementations, because they have exactly the same externally visible behaviour. You can always refactor from one implementation to the other without loss of information. Thus, we could claim that they're isomorphic.
If you're an object-oriented programmer, then you already know the word polymorphism, which sounds similar to isomorphism. Perhaps you've also heard the word xenomorph. It's all Greek. Morph means form or shape, and while poly means many, iso means equal. So isomorphism means 'being of equal shape'.
This is most likely the explanation for the term Isomorphic JavaScript. The people who came up with that term knew (enough) Greek, but apparently not mathematics. In mathematics, and particularly category theory, an isomorphism is a translation with an inverse. That's still not a formal definition, but just my attempt at presenting it without too much jargon.
Category theory uses the word object to describe a member of a category. I'm going to use that terminology here as well, but you should be aware that object doesn't imply object-oriented programming. It just means 'thing', 'item', 'element', 'entity', etcetera.
In category theory, a morphism is a mapping or translation of an object to another object. If, for all objects, there's an inverse morphism that leads back to the origin, then it's an isomorphism.
In this illustration, the blue arrows going from left to right indicate a single morphism. It's a mapping of objects on the blue left side to objects on the green right side. The green arrows going from right to left is another morphism. In this case, the green right-to-left morphism is an inverse of the blue left-to-right morphism, because by applying both morphisms, you end where you started. It doesn't matter if you start at the blue left side or the green right side.
Another way to view this is to say that a lossless translation exists. When a translation is lossless, it means that you don't lose information by performing the translation. Since all information is still present after a translation, you can go back to the original representation.
When programming, you can often solve the same problem in different ways. Sometimes, the alternatives are isomorphic: you can go back and forth between two alternatives without loss of information.
Martin Fowler's book Refactoring contains several examples. For instance, you can apply Extract Method followed by Inline Method and be back where you started.
There are many other isomorphisms in programming. Some are morphisms in the same language, as is the case with the above C# example. This is also the case with the isomorphisms in Refactoring, because a refactoring, by definition, is a change applied to a particular code base, be it C#, Java, Ruby, or Python.
Other programming isomorphisms go between languages, where a concept can be modelled in one way in, say, C++, but in another way in Clojure. The present blog, for instance, contains several examples of translating between C# and F#, and between F# and Haskell.
Being aware of software design isomorphisms can make you a better programmer. It'll enable you to select the best alternative for solving a particular problem. Identifying programming isomorphisms is also important because it'll enable us to formally think about code structure by reducing many alternative representations to a canonical representation. For these reasons, this article presents a catalogue of software design isomorphisms:
Many more software design isomorphisms exist, so if you revisit this article in the future, I may have added more items to this catalogue. In no way should you consider this catalogue exhaustive.
An isomorphism is a mapping for which an inverse mapping also exists. It's a way to describe equivalence.
In programming, you often have the choice to implement a particular feature in more than one way. These alternatives may be equivalent, in which case they're isomorphic. That's one of the reasons that many code bases come with a style guide.
Understanding how code is isomorphic to other code enables us to reduce many alternatives to a canonical representation. This makes analysis easier, because we can narrow our analysis to the canonical form, and generalise from there.
Next: Unit isomorphisms.
Comments
Sergey, thank you for writing. Good point, you're right that viewed as a general-purpose translation, Inline Method is indeed lossy. When you look at the purpose of refactoring code, the motivation is mostly (if not always) to make the code better in some way. Particularly when the purpose is make the code more readable, a refactoring introduces clarity. Thus, going the opposite way would remove that clarity, so I think it's fair to argue that such a change would be lossy.
It's perfectly reasonable to view a refactoring like Inline Method as a general-purpose algorithm, in which case you're right that it's lossy. I don't dispute that.
My agenda with this article series, however, is different. I'm not trying to make multiple angels dance on a pinhead; it's not my intent to try to redefine the word refactoring. The purpose with this series of articles is to describe how the same behaviour can be implemented in many different ways. The book Refactoring is one source of such equivalent representations.
One quality of morphisms is that there can be several translations between two objects. One such translation could be the general-purpose refactoring that you so rightly point out is lossy. Another translation could be one that 'remembers' the name of the original method.
Take, as an example, the isomorphism described under the heading Roster isomorphism in my article Tuple monoids. When you consider the method
ToTriple
, you could, indeed, argue that it's lossy, because it 'forgets' that the label associated with the first integer is Girls, that the label associated with the second integer is Boys, and so on. The reverse translation, however, 'remembers' that information, as you can see in the implementation ofFromTriple
.This isn't necessarily a 'safe' translation. You could easily write a method like this:
This compiles, but it translates triples created by
ToTriple
the wrong way.On the other hand, the pair of translations that I do show in the article is an isomorphism. The point is that an isomorphism exists; not that it's the only possible set of morphisms.
The same argument can be applied to specific pairs of Extract Method and Inline Method. As a general-purpose algorithm, I still agree that Inline Method is lossy. That doesn't preclude that specific pairs of translations exist. For instance, in an article, I discuss how some people refactor Guard Clauses like this:
to something like this:
Again, an isomorphism exists: a translation from a Null Guard to
Guard.AgainstNull
, and another fromGuard.AgainstNull
to a Null Guard. Those are specific incarnations of Extract Method and Inline Method.This may not be particularly useful as a refactoring, I admit, but that's also not the agenda of these articles. The programme is to show how particular software behaviour can be expressed in various different ways that are equivalent to each other.


Natural reference |
WaveNet vocoder |
GELP (proposed) |
Griffin & Lim |
|
| Sample #1 | ||||
| Sample #2 | ||||
| Sample #3 | ||||
| Sample #4 | ||||
| Sample #5 | ||||
| Sample #6 | ||||
| Sample #7 | ||||
| Sample #8 | ||||
| Sample #9 | ||||
| Sample #10 | ||||
| Sample #11 | ||||
| Sample #12 | ||||
| Sample #13 | ||||
| Sample #14 | ||||
| Sample #15 | ||||
| Sample #16 | ||||
| Sample #17 | ||||
| Sample #18 | ||||
| Sample #19 | ||||
| Sample #20 |


--- title: "Email Camera" date: 2017-08-29 16:03:47 +0200 favorite: true ---
This was presented on Tuesday 29 August at Litmus Live London as part of the #EmailHacks session hosted by Kevin Mandeville. You can find my slides here and view the email camera demo here. Here’s a transcript of my lightning talk.
I really like video games. I am a big fan of Nintendo and especially of the Game Boy. I love the Game Boy. It was my first console when I was a child. And now I love to collect them.
In 1998, Nintendo released the Game Boy Camera. It was a cartridge mounted with a digital camera. It could take pictures in four levels of grey with a resolution of 128 × 112 pixels. And it came complete with games, filters, and was compatible with the Game Boy Printer. The Game Boy Camera turned any Game Boy into the ultimate selfie machine.
Earlier this year, I was on the #emailgeeks Slack. And at some point, Kevin Mandeville mentioned the Game Boy Camera. And Jacques Corby-Tuech replied something along the lines: “Game Boy Camera in email”.
This hit me immediately. I had to do this. If someone should come up with a Game Boy camera inspired email, that had to be me. Plus, I already had the feeling that using the camera within an email should be something possible ever since I saw this demo on CodePen.
It’s a dynamic image colorizing demo that uses the system color picker and lets you change the color of a car in a picture. And it doesn’t use any JavaScript. This is just raw HTML and CSS. And it’s possible thanks to the following element.
<input type="color" />
What’s great about color input types in HTML is that it uses your system color picker. And browsers usually give you a small preview of the color chosen.
Using a little bit of CSS and proprietary pseudo selectors like ::-webkit-color-swatch
and ::-webkit-color-swatch-wrapper
, we can remove borders and paddings around the <input>
. Then using a bit more styles, we can size this input full screen. And then we can place the image below it. And using the CSS mix-blend-mode:hue;
property, we can achieve the desired effect.
What has any of this to do with emails and the Game Boy Camera?
Well, turns out we can achieve something quite similar using the following element.
<input type="file" />
A file input lets you upload files on the Web. And there are two things especially great about it:
So again, using CSS and proprietary selectors like ::-webkit-file-upload-button
, we can hide the default “Choose file” button, crop the input to show only the image, and use a CSS transform to make it much bigger.
Later that day, on Slack, I posted the following video.
Here’s the whole demo on CodePen. It works great on Apple Mail in iOS. Try it for yourself and have fun!


save
her
from
cancer
Sign in
Nearest Centers
Self-Diagnosis
Survivor Stories
Articles
Types of Cancer
Loading


Minimalist Windows with High Rigidity Steel Profiles: Transparency and Subtle Design
- by Materials
- about 13 hours
After centuries of using wood for the development of window and door carpentry, the Rationalism of the 20th century began to adopt a new material for these purposes: steel. Driven by industrial production, and promoted by architects such as Adolf Loos, Mies van der Rohe, and Le Corbusier, steel was evolving to generate increasingly thin and resistant frames. However, efficient and low-cost materials, such as aluminum and PVC, gradually began to replace its widespread use, increasing the size of the frames and losing steel's "clean" aesthetic when applied to a growing architecture of large glass paneled facades.
At present, new technologies have refined their production processes, developing minimal profiles of high rigidity and precision, which take full advantage of the transparency of the glass and deliver new comfort and safety features. We talked with Jansen's experts to deepen our understanding of their application in contemporary architecture.
Of Swiss origin, the company Jansen was created in 1923, the same decade when steel was first intensively incorporated into different architectural elements. Since those years, the company has been dedicated to the research and development of steel systems that today align with new technologies and architectural needs, forming a catalog of more than 3,000 different profiles, available in galvanized, stainless, and corten steel.
The unique characteristics of steel provide useful solutions for particular conditions. For example, they are useful for high traffic doors (due to the need for resistance when constantly opening and closing), for security doors and windows (due to their resistance to bullets, impacts, and fires), and for monumental facades (which must withstand the weight of large panes of glass and be tightly closed for thermal and acoustic insulation).
In relation to passive fire protection, there are fire-resistant steel profiles that meet the standards of F30, F60, F90 and F120 in fixed elements, and F30, F60, and F90 in doors. These profiles, together with the appropriate glass, prevent the spread of fire, smoke, and heat, protecting evacuation routes and the integrity of the buildings.
Compared to aluminum, steel is 3 times more rigid. Therefore, to achieve its strength, aluminum profiles must be 3 times more "large". In the case of monumental glass, aluminum must be reinforced to resist its weight, delivering a coarser aesthetic and losing many times over the benefits and performance expected from large windows.
One of the great attributes of steel is its ability to be welded, thus reducing its buckling lengths by dispensing with articulated joints. Welding also allows the addition of elements, cleanly and without the need for screws, expanding design possibilities and permitting structures with angles and curvatures.
The smaller Jansen profiles have a 15 mm front and are recommended for the construction of partitions or very thin windows. In contrast, the largest profiles reach a section of up to 60x280 mm and up to 10 meters long, making them useful for the construction of curtain walls without the need for intermediate supports.
The material is supplied in electro-galvanized bars inside and outside, ready to be processed in the most diverse shapes and sizes, and can be finished in any texture and color, depending on the needs of the architects and the client. Steel is a sustainable material that can be recycled many times without losing its attributes and requires less energy for its production.
According to its particular dimensions and properties, each steel profile has been designed to work together with its glass, delivering an integrated solution for doors, windows, and complete facades.
Look below for a series of projects that have used windows with minimal profiles to generate a clean architecture and well-lit interior spaces.
‘Kanaal’ in Wijnegem / Stéphane Beel Architects
Futurium Berlín / Richter Musikowski
Bauhaus Dessau Museum / Addenda Architects
Eperon d’Or, National Museum for Shoes & Brooms / Compagnie O Architects + Sabine Okkerse + Geert Pauwels
The Runkelsteiner / JMA
PCA-STREAM's Cluster / PCA-STREAM
Puma Energy Paraguay Headquarters / Ruiz Pardo – Nebreda
Joan Maragall Library / BCQ Arquitectura
Social Housing in Paris / Bigoni Mortemard
Zwarte Silo / Wenink Holtkamp Architecten
Escuela Tecnica Superior De Ingenieria (ETSE) / Francisco Candel + Luis Carratalá
New Hanfbach School Möglingen / mvm+starke architekten
LocHal Library / CIVIC architects + Braaksma & Roos architectenbureau + Inside Outside + Mecanoo
Town House in Antwerp / Sculp[IT]
- How to Choose the Right Glass for Your Projects


--- title: "x61.fr - Former Hackspace" caption: "/img/caption-x61.jpg" date: 2013-09-08 ---
Curious about what I'm hacking on at the moment? x61.fr is the place where
I used to experiment and write stuff.
Just because I can, this site used to run on NodeJS on a dedicated Amazon
instance. The code is still opensourced on my GitHub. Feel free to check it
out!


| ����� | ˵�� |
|---|---|
| org.jnetpcap.packet |
Packet decoding framework.
|
| org.jnetpcap.protocol.network |
Network protocol suite.
|
| org.jnetpcap.protocol.tcpip |
Tcp/Ip protocol suite.
|
| ���˵�� |
|---|
| Ip4
IP version 4.
|
| ���˵�� |
|---|
| Arp.HardwareType
Definitions for ARP supported hardware types.
|
| Arp.OpCode
Definitions for all the possible ARP operations as specified by the
operation field.
|
| Arp.ProtocolType
Definitions for supported protocol types.
|
| Icmp.Echo
ICMP Echo header (ping) baseclass definition.
|
| Icmp.IcmpCode
A table of Icmp sub-codes per Icmp type.
|
| Icmp.IcmpType
A table of IcmpTypes and their names.
|
| Icmp.Reserved
Base class for various ICMP Headers that contain a reserved field.
|
| Ip4
IP version 4.
|
| Ip4.Flag
Enum table for Ip4.flags field.
|
| Ip4.Ip4Type
A table of IpTypes and their names.
|
| Ip4.IpOption
Baseclass for all Ip option headers.
|
| Ip4.IpOption.CodeClass
The Enum CodeClass.
|
| Ip4.IpOption.OptionCode
A table of IpOption types and their names.
|
| Ip4.RouterAlert.Action
The Enum Action.
|
| Ip4.Routing
Ip4 optional Routing header.
|
| Ip4.Security.SecurityType
A table of security algorithm types.
|
| Ip4.Timestamp.Entry
Ip4 optional Timestamp header - a timestamp entry.
|
| Ip4.Timestamp.Flag
A table of Ip4 Timestamp header flags.
|
| Rip
Routing Information Protocol (RIP).
|
| Rip.Command
Valid values for RIP OpCode field.
|
| Rip1
Routing Information Protocol version 1 (RIP).
|
| Rip1.EntryV1
Rip1 routing table entry definition.
|
| Rip2.EntryV2
Rip2 routing table entry definition.
|
| ���˵�� |
|---|
| Ip4
IP version 4.
|
| Ip6
IP version 6 header definition.
|


--- layout: post title: advertsing comp date: '2017-10-24T11:30:11+02:00' categories: - Storyboards picture_url: https://film-Storyboards.tumblr.com/post/166749358426/advertsing-comp ---