Get level member or value in mondrian - mondrian

I'm trying to get a Level member or value in Mondrian through Java code. Is there any way to do this?
I can take schema, hierarchy, dimension, and level through the getter Mondrian has, but unfortunately I can't find a way to access the value/member for each level.
For example in FoodMart schema,
Dimension: Store
Level: Store City
value/member: CA/WA/NY/ etc.
Thanks!

What you are looking for is the .Members method on Level elements. The Database Journal has a very good series of articles on MDX where all these things are explained simply and geared towards new comers to MDX.
Using Java & Mondrian, this is done through the olap4j API. You can use:
org.olap4j.metadata.Level.getMembers()
For more details on olap4j, you can consult the API online. If you need help getting started using olap4j, you should go through the introductory guide.

Related

Tool or code to take a graphQL schema + set of operations and produce a schema subset?

Let's say I've got the following:
A giant GraphQL schema for some service (in .graphql or introspection json format)
A set of operations that my code wants to perform against that query.
I'd really like to generate a "subset schema": just the pieces (types/enums/etc) of that big schema that my service actually uses. Is there a tool or a piece of code that can do this today easily?
The reason I want this is that we want to mock graphql services to write isolated tests of particular microservices, and we want to mock out just the bits we actually use, and keep track of any changes in our schema usage over time.
I never found a solution to this, so eventually I wrote one!
https://github.com/xometry/graphql-code-generator-subset-plugin - this tool is a plugin to the graphql-code-generator tool which will product a schema subset.

Connection is based on `array`,is this a design style guide for design a relay server?

In connection/arrayconnection.js, It seems all the function is tend to work with array.
For example: offsetToCursor is the only way to generate Cursor. Does this mean its a design pattern i must follow, or imply that i should generate Cursor by myself when using something other than array.If im planning to use Mongodb,should i make the database interface like an static array ?
BTW:
As a newbie to web develop, im a bit confused how to implement a qualified relay server.
Are there some guide for design a graphql-relay server, should i follow all the way in graphql-relay-js, which Database Facebook used with relay-server ? mysql or ?
Im not sure ask this here is appropriate or not,but the topic for graphql-relay-js is rarely on the web.
Thanks a lot, forgive my impolite.
var PREFIX = 'arrayconnection:';
/**
* Creates the cursor string from an offset.
*/
export function offsetToCursor(offset: number): ConnectionCursor {
return base64(PREFIX + offset);
}
Additional question:
Maybe i get some idea from developers.facebook.com/docs/graph-api.
Seems should do an array style cache for pagination lookup( not sure about this).
But graph-api looks a bit different from graphql-relay-js (is graph-api still some part of old restful style?),
What is the relationship between graph-api and graphql-relay-js ? Is graphql-relay-js a common design guide for design a graphql server in facebook?
Thanks a lot! please give me some hints
Connection is a design pattern that your schema may implement if you want Relay to perform efficient pagination. How it gets implemented on the backend is an implementation detail. It may be backed by something array-like, or it may not (think about something like the infinite scrolling news feed on Facebook, which is ranked by a terribly sophisticated backend service: this is clearly not backed by an array). We provide the arrayconnection.js module as a way of demonstrating how this can be done if your data source has that array-like nature. If it does not, or cannot be efficiently converted to it, you are better off implementing something from scratch.
Cursors are opaque identifiers. You could use an array index or some kind of primary key if you are using an array source or a typical database backend (like MySQL), but again the details are implementation-specific and should be chosen to suit your back end. The only requirement is that the cursor should encode whatever information you need on the server to be able to return the next page of results after (or before) that point.
graphql-relay-js is just a collection of modules that provide some helpers for building Relay-compatible GraphQL schemas in JavaScript. The schema provides a uniform interface to your data, but the actual underlying storage can be anything you want to plug into it (a MySQL database, an object in memory, some REST service). For simple examples, look in the examples directory in the Relay repo. As an illustration of how you can put a schema in front of something that is not a traditional database, this is an example of a schema that reads its data out of a Git repo, with the help of indices in Redis and cached data in memcached.
Stay away from developers.facebook.com/docs/graph-api; despite the "graph" in the name this is an entirely different thing and has nothing to do with the GraphQL hierarchical query language that Relay uses.

I need to create a dynamic query using StreamInsight 2.1 and reactive extensions

I am looking for information about how to create dynamic queries using the newer StreamInsight 2.1 reactive extensions model. Specifically, I would like to use the CreatQuery() method or something similar (within IQueryable) with IQStreamable. Within the workflow I am creating, this new query would be inserted into StreamInsight as a standing query. I have done quite a bit of research but have not found a solution. Also, most of the documentation appears to reference what is now a "legacy" adapter model. Any help would be appreciated.
What do you mean by "Dynamic Query"? Something similar to Dynamic Query Composition, where you could use the output of one query as a stream input into another query? If that's the case, you can use Subjects for this. Subjects allow you to have multiple publishers/subscribers for a stream and also provide the ability to attach/detach publishers and subscribers at runtime.
As far as I remember StreamInsights does not support that concept, the only way to archive that would be to use dynamic compilation to publish to StreamInsights query instance compiled based on dynamically generated code. That is quite possible.

Achieve Multi-tenancy with GATE

I am using GATE in one of my applications and I have few queries related to Multi-tenancy. My requirements are as given below.
I have the keywords set, specific for each user and depending on
which user is signed in, I need to initialise gazetteer with the
applicable set of keywords.
At a given time there could be multiple users logging into my
application and I want to make sure that the multi-tenancy
approach will not be inefficient.
I don't want to store the keywords for each user in the .lst
file(s) but store it on a DB (mongo) and inject only at the
runtime.
I searched the web for few samples and though I found some thoughts on working with Processing Resource, I have no idea how the performance will be affected.
Your help is much appreciated.
Thanks in advance,
Sajith
That's an interesting use-case for a GATE gazetteer.
One thing I believe you should definitely do is add the user ID as a feature when you're creating the document. This way you'll be able to make your MongoDB query in a processing resource later on.
When you're processing the document, you have several options:
Create a custom PR which calls MongoDB and replicates the DefaultGazetteer code but with overwritten "init" method (or inherit or wrap it, haven't looked into much detail if that's possible). Instead of the default init method you should provide your list of keywords, then set the needed fields and call execute().
If you don't have too many keywords, create a custom PR (or groovy scripting PR) which calls MongoDB and does some simple regex search like the one in this thread.
They also suggest the stringsearch library in the comments. Then just use start and end indices to create Lookup annotations on your own.
You said you don't want that but still, several million words can be handled by both the default and the Hash gazetteer. Although, you should be careful as gate documents could be very memory-intensive if you have too many annotations - in your case Lookups for all user keywords.
Hope this helps.

Virtualizing Data in Windows Phone 7: An example

In Windows Phone a ListBox support the virtualization of the data, that means it can only load the data needed and not everything. Peter Torr explains the interface you need to implement.
The short version is that you have to create both a method that return the position of an element and another one that return the element in a specific position. The problem is that the example of Peter Torr is rather dumb, he just return an object with the index as a name.
My question is: how do you actually implement this ?
My idea is to create one file that contains a list of an (integer) index and an (integer) id and a file for every object that contains the actual data. It doesn't seem a really elegant idea, but I can't think of anything better, can you ?
UPDATE
It seems that my question is inaccurate. When I say that the example of Peter Torr is "rather dumb" I am not saying that he has done anything wrong; his objective was simply to explain what interface you need to implement. The practical implementation will depend on the specific data.
What I am asking is what choices do I have to implement this ? Should I simply put the data on a web service and query it every time (with a local cache, of course), build a database, create a file the store the indexes and one for the data ? Is there a solution good enough in every case ? What are the downsides and upsides of every choice ?
The article you linked to includes a link to a downloadable project which demonstrates how to implement this.
What more are you after? The general idea is that the ListBox will call into your IList when it needs data. it will ask for an item at a specific index and you pass back an object. it then, presumably, calls ToString() on that object and displays the result in the list.
What that actual object is and where you pull it from is completely up to you. You might be using a really large array in memory. You might be pulling from IsolatedStorage or a web service. You could certainly use it to pull file info, but I don't suspect anyone has a ready-built IList implementation so that's the part that you will have to implement based on your specific project.

Resources