bug-recutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-recutils] A new field type?


From: OLLIER Jean-François
Subject: [bug-recutils] A new field type?
Date: Sat, 5 Feb 2011 00:02:01 +0100
User-agent: Mutt/1.4.2.2i

Hi Jose,

I suggest that any record name inside a recfile might be a valid field type for 
other records fields.
The allowed values for such fields might only be keys of records of the 
specified name.
This method results in some kind of relational Data Base.
Bellow is an example of this method, with the expected benefits.

For my demonstration, I will build a Database using the currently available 
field types, then the same DB with the implementation of the proposed solution.

The DB has two tables (2 records types) and the second one contains references 
to the keys of the first one.
   
# ---------------------- Current Methodology 
------------------------------------------------
# The first table with 2 records
#
%rec: Asset
%key: tag
%type: tag regexp /^[0-9]{8}$/
%type: description enum car building pencil
%type: vendor size 25
%type: purchasePrice real
%type: purchaseDate date

tag: 01234567
description: car
vendor: Henry Ford

tag: 76543210
description: car
vendor: Nissan

# The second table also has 2 records, which refer to records of the first table
#
%rec: Maintenance
%type: equipment regexp /^[0-9]{8}$/
%type: failureMode line
%type: failureDate date
%type: failuresNumber int
%type: immobilisationTime int
%type: maintainerName regexp /^[A-Z][a-z]*([- ][A-Z][a-z]*)*$/

equipment: 01234567
failureMode: oil leakage
failureDate: 02/01/2011
failuresNumber: 888888
immobilisationTime: 31
maintainerName: Henry Ford Junior

equipment: 76543210
failureMode: pinched tire
failureDate: 03/02/2011
failuresNumber: 10
immobilisationTime: 1 
maintainerName: Stonefire

#Suppose that I want to extract all the vendors that sold me unreliable 
equipments.
#I may write this selection pipe:

> recsel -t Maintenance -e "failuresNumber > 20" -P equipment db.rec | xargs 
> -i% recsel -t Asset -e "tag=%" -P vendor db.rec

# note that there are as many recsel processes launched as equipments returned, 
+ the leading recsel, + xargs.

# ----------------------- Proposed Methodology 
-----------------------------------------------
# The first table is strictly the same as for the previous case
#
%rec: Asset
%key: tag
%type: tag regexp /^[0-9]{8}$/
%type: description enum car building pencil
%type: vendor size 25
%type: purchasePrice real
%type: purchaseDate date

tag: 01234567
description: car
vendor: Henry Ford

tag: 76543210
description: car
vendor: Nissan

# The second table differs from the previous case only for the type of the 
'equipment' field
#
%rec: Maintenance
%type: equipment Asset
%type: failureMode line
%type: failureDate date
%type: failuresNumber int
%type: immobilisationTime int
%type: maintainerName regexp /^[A-Z][a-z]*([- ][A-Z][a-z]*)*$/

equipment: 01234567
failureMode: oil leakage
failureDate: 02/01/2011
failuresNumber: 888888
immobilisationTime: 31
maintainerName: Henry Ford Junior

equipment: 76543210
failureMode: pinched tire
failureDate: 03/02/2011
failuresNumber: 10
immobilisationTime: 1 
maintainerName: Stonefire

#Now Suppose I want to extract all the vendors that sold me unreliable 
equipments.
#I expect to have the result with this command:

> recsel -t maintenance -e "failuresNumber > 100" -P equipment:vendor db.rec

# ----------------------- Conclusion 
---------------------------------------------------------
If this methodology can work, the benefits would be:

- Only 1 process launched, instead of potentially many, with the performance 
gain to match
- An easier to write command line.
- The possibility to chain several types of records in the same way, with 
SINGLE PROCESS commands to extract related values between them. 

-- 
Jean-François OLLIER
mailto:address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]