Its's been a while since I've written ASN.1 so..
Our data model is comprised of several table definitions within a table. This is not workable in SNMP, so we need to flatten the definitions. The easiest way to do this would be to have the embedded table indexed by the same OID as the parent table. Thus
someTableEntry ::= SEQUENCE {
someTableIndex
Integer32,
someTableDomain
Integer32,
someTableFooTable
SEQUENCE OF SomeTableFooTable
}
becomes
someTableEntry ::= SEQUENCE {
someTableIndex
Integer32,
someTableDomain
Integer32,
}
someTableFooTable ::= SEQUENCE {
someTableIndex
Integer32,
....
}
The good thing is that in our application there will NEVER be any kind of SET, GET or GET NEXT so no need for SNMP walk (there are some very good reasons for this that supersede the need for network management elegance. All attributes will be reported via traps only. I think this is a valid SNMP MIB definitions but wanted to get some feedback.
Thanks in advance.
It sounds like you're on the right track. In order to define a table as a child of another table, you simply index it by the parent's index plus the child's index (e.g., 0.1.8.23.7.2.42 where 2 is the parent index and 42 is the child index).
For example, you could define a parent like:
parentTable OBJECT-TYPE
SYNTAX SEQUENCE OF parentEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION "Parent table"
::= { example 1 }
parentEntry OBJECT-TYPE
SYNTAX ParentEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION "Entry in Parent table"
INDEX { parentIndex }
::= { parentTable 1 }
ParentEntry ::= SEQUENCE {
parentIndex Unsigned32,
-- other columns in the table
}
-- define the columns in the parent table
With a child table defined as:
childTable OBJECT-TYPE
SYNTAX SEQUENCE OF childEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION "Child table"
::= { example 2 }
childEntry OBJECT-TYPE
SYNTAX ChildEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION "Entry in Child table"
INDEX { parentIndex,
childIndex }
::= { childTable 1 }
ChildEntry ::= SEQUENCE {
childIndex Unsigned32,
-- other columns in the table
}
-- define the columns in the child table
Note that it's not necessary to list parentIndex in the ChildEntry sequence since it's already be declared elsewhere in the MIB.
This method works well and it even responds to snmp walks without issue.
Once you have a MIB that you think accurately defines the structure you want, you can validate it using smilint if you are on a linux machine or have cygwin installed or you can validate it online.
Update
This pattern will work for deeper nesting as well.
A grandchild table could be defined as:
grandChildTable OBJECT-TYPE
SYNTAX SEQUENCE OF grandChildEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION "Grandchild table"
::= { example 3 }
grandChildEntry OBJECT-TYPE
SYNTAX GrandChildEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION "Entry in Grandchild table"
INDEX { parentIndex,
childIndex,
grandChildIndex }
::= { grandChildTable 1 }
grandChildEntry ::= SEQUENCE {
grandChildIndex Unsigned32,
-- other columns in the table
}
-- define the columns in the grandChild table
The only limit on nesting depth is the maximum OID length (which, I believe, is 127): A column's base OID length plus the number of indices for the table must be less than the maximum OID length.
One other item to note is that at each level there can be multiple siblings.
A second child could be defined as:
secondchildTable OBJECT-TYPE
SYNTAX SEQUENCE OF secondchildEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION "Second child table"
::= { example 4 }
secondchildEntry OBJECT-TYPE
SYNTAX SecondchildEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION "Entry in Second child table"
INDEX { parentIndex,
secondchildIndex }
::= { secondchildTable 1 }
SecondchildEntry ::= SEQUENCE {
secondchildIndex Unsigned32,
-- other columns in the table
}
-- define the columns in the second child table
Related
I'm trying to query a dynamodb table using the partition key and a sort key. The sort key is a unix date, so I want to request x partition key between these 2 dates on the sort. I am currently able to achieve this with a table scan, but I have to move this to a query for the speed benefit. I am unable to find any decent examples online of people using a partition key and sort key to query their table.
I have carefully read through this https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/#DynamoDB.Query and understand that my params must go within the KeyConditionExpression.
I have read through https://github.com/aws/aws-sdk-go/blob/master/service/dynamodb/expression/examples_test.go and understand it on the whole. But I just can't find the syntax for KeyConditionExpression
I'd have thought it was something like this:
keyCond := expression.Key("accountId").
Equal(expression.Value(accountId)).
And(expression.Key("sortKey").
Between(expression.Value(fromDateDec), expression.Value(toDateDec)))
But this throws:
ValidationException: Invalid KeyConditionExpression: Incorrect operand type for operator or function; operator or function: BETWEEN, operand type: NULL
First you need KeyAnd to combine Hash Key and sort key condition.
// keyCondition represents the key condition where the partition key
// "TeamName" is equal to value "Wildcats" and sort key "Number" is equal
// to value 1
keyCondition := expression.KeyAnd(expression.Key("TeamName").Equal(expression.Value("Wildcats")), expression.Key("Number").Equal(expression.Value(1)))
Now instead equal condition you can replace with your between condition as follows
// keyCondition represents the boolean key condition of whether the value
// of the key "foo" is between values 5 and 10
keyCondition := expression.KeyBetween(expression.Key("foo"), expression.Value(5), expression.Value(10))
i am a beginner to pig and i have started with the word count program.
In the following word count program, i see group keyword being used in 3rd and 4th lines. Is the usage of the keyword 'group' same or different at both the places as i am a bit confused as the group in the 4th line of the program is throwing error when given in Caps?
lines = LOAD '/user/root/pig/pig_demo.txt' AS (line:chararray);
words = FOREACH lines GENERATE FLATTEN(TOKENIZE(line)) as word;
grouped = GROUP words BY word;
wordcount = FOREACH grouped GENERATE group, COUNT(words);
DUMP wordcount;
They both are different.The former i.e. "GROUP" is an operator where as the latter i.e. "group" is a keyword referring to the GROUP Key.
Below is the explanation from here.
The GROUP operator groups together tuples that have the same group key (key field). The key field will be a tuple if the group key has more than one field, otherwise it will be the same type as that of the group key. The result of a GROUP operation is a relation that includes one tuple per group. This tuple contains two fields:
The first field is named "group" (do not confuse this with the GROUP operator) and is the same type as the group key.
The second field takes the name of the original relation and is type bag.
The names of both fields are generated by the system as shown in the example below.
Note that the GROUP (and thus COGROUP) and JOIN operators perform similar functions. GROUP creates a nested set of output tuples while JOIN creates a flat set of output tuples.
Today I read one article about the hive tuning. One paragraph is as follows:
Scene: user_id in the user table the field user_id INT, log table field both of type string type int. When two tables in accordance with the user_id Join operation, the default Hash operation will be allocated int id, this will cause all records of the string type id assigned to a reducer.
Solution: numeric type is converted to a string type
select * from users a
left outer join logs b
on a.usr_id = cast (b. user_id as string)
Can anybody give me some more explanation about the above opinion, I really cannot understand the words the author describe. Why "this will cause all records of the string type id assigned to a reducer." happened? Thanks in advance!
For starters you did not copy and paste / transcribe the original properly. Here is the more likely wording:
this will cause all records of the string type id assigned to a
single reducer.
The reason that would happen is that the conversion of string to int without the cast is probably turning it to 0. Therefore the hashing will put all of the id's into the same partition for the 0 values.
I am using blaze for querying data from csv and json. I just need to query a record where id is equal to the specified id? Is it possible.
city = city[city.ID = 1]
While trying to execute the above code it shows
SyntaxError: invalid syntax
That works, but in your case you'd need to have a field named ID, it's not a magical field. The following works, but only because there's a column explicitly named id in accounts.csv:
from blaze import Data
from blaze.utils import example
accounts = Data(example('accounts.csv')
accounts[accounts.id == 2]
# id name balance
# 1 2 Bob 200
I have a database table that holds parent and child records much like a Categories table. The ParentID field of this table holds the ID of that record's parent record...
My table columns are: SectionID, Title, Number, ParentID, Active
I only plan to allow my parent to child relationship go two levels deep. So I have a section and a sub section and that it.
I need to output this data into my MVC view page in an outline fashion like so...
Section 1
Sub-Section 1 of 1
Sub-Section 2 of 1
Sub-Section 3 of 1
Section 2
Sub-Section 1 of 2
Sub-Section 2 of 2
Sub-Section 3 of 2
Section 3
I am using Entity Framework 4.0 and MVC 2.0 and have never tried something like this with LINQ. I have a FK set up on the section table mapping the ParentID back to the SectionID hoping EF would create a complex "Section" type with the Sub-Sections as a property of type list of Sections but maybe I did not set things up correctly.
So I am guessing I can still get the end result using a LINQ query. Can someone point me to some sample code that could provide a solution or possibly a hint in the right direction?
Update:
I was able to straighten out my EDMX so that I can get the sub-sections for each section as a property of type list, but now I realize I need to sort the related entities.
var sections = from section in dataContext.Sections
where section.Active == true && section.ParentID == 0
orderby section.Number
select new Section
{
SectionID = section.SectionID,
Title = section.Title,
Number = section.Number,
ParentID = section.ParentID,
Timestamp = section.Timestamp,
Active = section.Active,
Children = section.Children.OrderBy(c => c.Number)
};
produces the following error.
Cannot implicitly convert type 'System.Linq.IOrderedEnumerable' to 'System.Data.Objects.DataClasses.EntityCollection'
Your model has two navigation properties Sections1 and Section1. Rename the first one to Children and the second one to Parent.
Depending on whether you have a root Section or perhaps have each top-level section parented to itself (or instead make parent nullable?), your query might look something like:-
// assume top sections are ones where parent == self
var topSections = context.Sections.Where(section => section.ParentId == SectionId);
// now put them in order (might have multiple orderings depending on input, pick one)
topSections = topSections.OrderBy(section => section.Title);
// now get the children in order using an anonymous type for the projection
var result = topSections.Select(section => new {top = section, children = section.Children.OrderBy(child => child.Title)});
For some linq examples:
http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx
This covers pretty much all of the linq operations, have a look in particular at GroupBy. The key is to understand the input and output of each piece in order to orchestrate several in series and there is no shortcut but to learn what they do so you know what's at hand. Linq expressions are just combinations of these operations with some syntactic sugar.