My geode client is working to persist and retrieve the data in the specific region.
ClientRegionFactoryBean<Integer, Book> region =
new ClientRegionFactoryBean<>();
region.setName("Book");
region.setPool(gemfirePool);
region.setCache(cache.getObject());
region.setShortcut(ClientRegionShortcut.PROXY);
however, if i am trying to use the region to query for another region, it doesn't allow me to do that:
org.apache.geode.cache.query.QueryInvalidException: Should not execute region.query with a different region in the from clause: Book was not present in:select * from /Staff
any idea ?
You should obtain the QueryService from the ClientCache
i.e clientCache.getQueryService(); rather than region.query();
Related
I am trying to query Kafka State Store using range query.
My key format is satrtTimeInMillis|endTimeInMillis|someUniqueIdInNumber and using String to store records.
I want to execute range query like
store.range("fromSomeStartTimeInMillis","toCurrentTimeInMillis")
OR
store.range("fromSomeEndTimeInMIllis","toCurrentTimeInMillis")
My expectation is, if I execute query based on startTime, it should only return all records between from,to startTime, same likewise should hold for endTime too.
e.g
<1|2|9>, <2|1|8>,<3|2|7>,<100|2|4>,<100|5|11>
(say stored keys)
Query : i) store.range("1|","3|") --startTime-- It should return <1|2|9>, <2|1|8>,<3|2|7>
ii) store.range("|1","2") --endTime-- It should return <1|2|9>, <2|1|8>,<3|2|7>,<100|2|4>
I have been trying like this but results are not expected, also tried with Custom Serde Class to store records, but not any success.
Kindly suggest String Query Format for range query-- from and to for this kind of situation or even Custom Key Class with from and to fields.
Or is there any other way to handle this type of situation where I want to divide work across nodes, but there is no token service available to distribute load. Kafka seems only way to distribute load by partitioning data.
I would like to get some statistics about the roads, their deployed traffic lights, and the lampposts. Is there any way to get these statistics immediately for Shenzhen (China) city?
Secondly: how can I export the road network of a specific city (i.e., Shenzhen) including traffic_signals and street_lamps?
I have tried this code using Overpass API:
[out:csv(::id,::lat,::lon)][timeout:900];
// gather results
(
node["highway"="street_lamp"](22.6242,113.6371,23.0628,114.5462);
);
// print results
out body;
The query doesn't retrieve any results for Shenzhen's(China) coordinates(22.6242,113.6371,23.0628,114.5462).However, when applying on coordinates of London(51.3941,-0.2774,51.56,0.0879), it works and retrieves.
Moreover, when I do simple query like querying PoI:
[out:json][timeout:10];
// gather results
(
node["leisure"](around: 200,22.5,113.9936701,22.6740047,113.9935278);
);
out body;
It also works although in Shenzhen(China). Any way to retrieve nodes tagged with 'street_lamp' and 'traffic_sign' in Chinese cities (i.e., Shenzhen)?
To query within boundaries, use the id of the city boundary's relation, then use map_to_area and then query with the the (area) filter:
rel(3464353);
map_to_area;
node(area)["highway"="street_lamp"];
out;
In ArangoDB I have documents in a trip collection which is related to documents in a driver collection via edges in a tripToDriver collection, and the trip documents are also related to documents in a departure collection via edges in a departureToTrip collection.
To fetch trips where their driver has a given idNumber and their associated departure has a startTime after a supplied date/time, I've successfully written the following AQL:
FOR doc IN trip
LET drivers = (FOR v IN 1..1 OUTBOUND doc tripToDriver RETURN v)
LET departures = (FOR v in 1..1 INBOUND doc departureToTrip RETURN v
FILTER drivers[0].idNumber == '999999-9999' AND departures[0].startTime >= '2018-07-30'
RETURN doc
But I wonder if there is a more concise / elegant way to achieve the same results?
A related question, since I'm using Spring Data ArangoDB: Is it possible to achieve this result with derived queries?
For a single relation I was able to create a query like:
Iterable<Trip> findTripsByDriversIdNumber( String driverId ); but haven't had luck incorporating the departure relation into this signature (maybe because it's inbound?).
First of all your query only works if you have only one connected driver/departure for every trip. You're fetching all linked drivers but only check the first found one.
If this is your model it is totally ok, but I would recommend to do the idNumber/startTime check within the sub queries. Then, because we only need to know that at least one driver/departure fits our filter condition, we add a LIMIT 1 to the sub query and return only a true. This is enough we need for our FITLER in our main query.
FOR doc IN trip
FILTER (FOR v IN 1..1 OUTBOUND doc tripToDriver FILTER v.idNumber == #idNumber LIMIT 1 RETURN true)[0]
FILTER (FOR v IN 1..1 INBOUND doc departureToTrip FILTER v.startTime >= #startTime LIMIT 1 RETURN true)[0]
RETURN doc
I tested to solve your case with a derived query. It would work, if there wasn't a bug in the current arangodb-spring-data release. The bug is already fixed but not yet released. You can already test it using a snapshot version of arangodb-spring-data (1.3.1-SNAPSHOT or 2.3.1-SNAPSHOT depending on your Spring Data version, see supported versions).
The following derived query method worked for me with the snapshot version.
Iterable<Trip> findByDriversIdNumberAndDeparturesStartTimeGreaterThanEqual(String idNumber, LocalDate startTime);
To make the dervied query work you need the following annotated fields in your class Trip
#Relations(edges = TripToDriver.class, direction = Direction.OUTBOUND, maxDepth = 1)
private Collection<Driver> drivers;
#Relations(edges = DepartureToTrip.class, direction = Direction.INBOUND, maxDepth = 1)
private Collection<Departure> departures;
I also created an working example project on github.
I have a graph which save topology of cloud infrastructure of a firm.It consists of Vertex called Object (Machines) and Edge called link (to denote how machines are linked to each other these links keep changing according as one machine can connect to different machines depending on need).
create class Object extends V
create class link extends E
Object vertices denotes Machine have properties to store config of the machine.
create property Object.ram long
create property Object.mem long
create property Object.cpu_core long
"link" edges links machine together to form a topology.It is a outbound edge from one machine to other. It has two time based property startTime which denotes the when this edge was created between two machines and endTime which initially is infinity and is update if we need to close this edge denoting that two machine and now no more linked.
create property link.startTime long
create property link.endTime long
create property link.l_id string
I want traverse from a Object(vertex) to all its connected Objects imposing a condition on link(edge) property while traversing that for a time say t, should be startTime <= t <= endTime.
For example Topology (Please click the link )
I want to traverse down from node rid #21:0 to all the edges using link edges whose startTime > 1488965393 and endTime < 1498965393. I am quite new to OrientDB and not able to figure out possible SQL command for the same.
Pseudo query (looking for something similar if possible):
SELECT * FROM (TRAVERSE out('link') FROM #21:0 while startTime > 1488965393 and endTime < 1498965393)
I was able to form a query that produced the desired output
SELECT id FORM (TRAVERSE out() FROM #21:0 WHILE (creationTime<= 1488965393 AND endTime >= 1488965393 AND #class='link')) WHERE #class= 'Object'
i have a question and i m trying to find a code example to implement in my project. Here is the question, i want in powerbuilder to create a datastore from simple sql select and then to fetch one by one the value stored in the ds. I want this cause at the moment i m using CURSOR which is very slow and has transaction size problems, then i tried ROW_NUMBER which also is very slow. I m using on my application both oracle and sql. (with a lot of data), please if u can provide me an pb example it would be very helpful. thank you guys.
Here is an example:
datastore lds_data
lds_data = CREATE datastore
lds_data.DataObject = "your datawindow"
lds_data.SetTransObject (SQLCA)
lds_data.Retrieve() // Put your parms in the parenthesis
...
DESTROY lds_data // Optionnal -
And if you want to dynamically build the Datastore from the SQL statement, replace the 3rd line by (ls_err being defined as string variable and will contain possible return error) :
lds_data.create(sqlca.SyntaxFromSQL('select col, you, want from your_table', 'Style(Type=Form)', ls_err))