Jackrabbit oak : Not able to set VersionGCOptions - jcr

I am using JackRabbit Oak(1.22.3) implementation for deleting nodes using Version garbage collection.
I am setting below custom values for garbage collection.
VersionGCOptions versionGCOptions = new VersionGCOptions();
versionGCOptions.withOverflowToDiskThreshold(900000);
versionGCOptions.withCollectLimit(900000L);
versionGCOptions.withMaxIterations(10);
documentNodeStore.getVersionGarbageCollector().setOptions(versionGCOptions);
But when I am trying to get above values, I am getting default values not custom values:
System.out.println("collectLimit : "+versionGarbageCollector.getOptions().collectLimit);
System.out.println("maxIterations : "+versionGarbageCollector.getOptions().maxIterations);
**output:-**
collectLimit : 100000
maxIterations : 0
I am not getting why this is happening, please help me here to resolve this.

The "with...()" methods return a new VersionGCOptions object (they do not modify the existing one).
Thus you need to do something like:
versionGCOptions = versionGCOptions.withOverflowToDiskThreshold(900000);

Related

fn.subsequence work different in optic API

In my program I need to join 2 and more collections by some json properties.
When I run only subsequence method it return array of json objects but when I use it in op.fromLiterals in my optic plan it returns a list of document uris.
I can't use the method op.fromSearch because I can't upgrade to a later MarkLogic version.
I need something like this to work:
var items = fn.subsequence(search).toArray();
op.fromLiterals(items)
.joinInner(article, op.on('fragmentId', 'viewDocId'))
.result()
But now items is a list of document locations (document_1.json) and this code gives me an error:
XDMP-ARGTYPE:
xdmp.documentGet(cts.doc("/Documents/document_1.json"))
Solution: I push properties to results in this way: results.push({id: doc.toObject()["document_id"]}); and its work fine.

Terraform: How Do I Setup a Resource Based on Configuration

So here is what I want as a module in Pseudo Code:
IF UseCustom, Create AWS Launch Config With One Custom EBS Device and One Generic EBS Device
ELSE Create AWS Launch Config With One Generic EBS Device
I am aware that I can use the 'count' function within a resource to decide whether it is created or not... So I currently have:
resource aws_launch_configuration "basic_launch_config" {
count = var.boolean ? 0 : 1
blah
}
resource aws_launch_configuration "custom_launch_config" {
count = var.boolean ? 1 : 0
blah
blah
}
Which is great, now it creates the right Launch configuration based on my 'boolean' variable... But in order to then create the AutoScalingGroup using that Launch Configuration, I need the Launch Configuration Name. I know what you're thinking, just output it and grab it, you moron! Well of course I'm outputting it:
output "name" {
description = "The Name of the Default Launch Configuration"
value = aws_launch_configuration.basic_launch_config.*.name
}
output "name" {
description = "The Name of the Custom Launch Configuration"
value = aws_launch_configuration.custom_launch_config.*.name
}
But how the heck do I know from the higher area that I'm calling the module that creates the Launch Configuration and Then the Auto Scaling Group which output to use for passing into the ASG???
Is there a different way to grab the value I want that I'm overlooking? I'm new to Terraform and the whole no real conditional thing is really throwing me for a loop.
Terraform: How to conditionally assign an EBS volume to an ECS Cluster
This seemed to be the cleanest way I could find, using a ternary operator:
output "name {
description = "The Name of the Launch Configuration"
value = "${(var.booleanVar) == 0 ? aws_launch_configuration.default_launch_config.*.name : aws_launch_configuration.custom_launch_config.*.name}
}
Let me know if there is a better way!
You can use the same variable you used to decide which resource to enable to select the appropriate result:
output "name" {
value = var.boolean ? aws_launch_configuration.custom_launch_config[0].name : aws_launch_configuration.basic_launch_config[0].name
}
Another option, which is a little more terse but arguably also a little less clear to a future reader, is to exploit the fact that you will always have one list of zero elements and one list with one elements, like this:
output "name" {
value = concat(
aws_launch_configuration.basic_launch_config[*].name,
aws_launch_configuration.custom_launch_config[*].name,
)[0]
}
Concatenating these two lists will always produce a single-item list due to how the count expressions are written, and so we can use [0] to take that single item and return it.

Can't retrieve db Model getId() anymore in activejdbc 1.4.12

I was using activejdbc 1.4.9 and the following sample code was running just fine
Client client = new Client();
client.save();
Assert.assertNotNull(client.getId());
Since I upgraded to 1.4.12, client.getId() is always returning null when save is inserting a new record. i.e. id is not getting refreshed.
Did anyone notice this as well? Do I have to do anything different using this version to get the newly created id?
I cannot confirm this with the version 1.4.12. For instance, I wrote this example: https://github.com/javalite/simple-example/blob/new_id. Check out code in the Main.java. As you can see, the code is identical to yours, but on line 21, it prints out a real value of the new ID.
If you can put together a simple example that replicates your issue, I will take a look.
EDIT:
Now that you provided more info in comments below, the problem is with you setting the ID to empty string: "". Because the ID is not null anymore, the method save() uses update rather than insert. The update then uses the value of ID to update an "existing" record, and, as a result does not do anything. Messing with ID value is possible but not advised. Please see this for more information: http://javalite.io/surrogate_primary_keys

Lucene indexes in Neo4j don't work as expected

I think that the title is a little bit vague, so I'm going to explain precisely my problem.
I am creating some nodes in Neo4j and then index them like this :
Index<Node> myindex = graphDb.index().forNodes(
"myindex",
MapUtil.stringMap(IndexManager.PROVIDER, "lucene", "type",
"fulltext"));
Node n = graphDb.createNode(); //create the node
node.setProperty("firstname", "firstname"); //add properties
node.setProperty("familyname", "familyname");
myindex.add(node, "familyname", "familyname"); //index it
But when I need to update Node "n" 's properties (for instance change "familyname" to "fname"), this node can't be found anymore through an index based search!
So before updating the property, this cypher query
start n= node:myindex(familyname:"familyname") return n
was returning the Node, whereas after update, I am expecting :
start n= node:myindex(familyname:"fname") return n
to return the same node with the new property, but it doesn't work ! While the first query is always working, like if the index is bound to the property "familyname"
Any thoughts about this ?
Thanks
So as tstorms suggested, the solution is to remove the index after updating the property :
n.setProperty("familyname","fname");
myindex.remove(n);
then add it with the new property :
myindex.add(n, "familyname","fname");

D3 Graph Example Using In Memory Object

This seems like it should be simple, but I have spent literally hours without any success.
Take the D3 graph example at http://bl.ocks.org/mbostock/950642. The example uses a local file called graph.json. I have set up a Rails app to serve a similar graph, however I don't want to write a file of the JSON. Rather, I generate the nodes and links into an object such as:
{"nodes":[{"node_type":"Person","name":"Damien","id":"damien_person"}, {"node_type":"Person","name":"Grant","id":"grant_person"}}],
"links":[{"source":"damien_person","target":"grant_person","label":"Friends"}}
Now when I render the D3, I need to update the call d3.json("graph.json", function(json) {...}); to reference my in-memory object rather than the local file (or url). However, everything I've tried breaks my html/javascript. For example I tried setting the var dataset = <%= raw(#myInMemoryObject) %>;, and that works for assignment (I did an alert on the dataset), however I can't get the D3 code to use it.
How can I replace the d3.json call in order to use my in-memory object?
Thank you,
Damien
Your idea of using, for example, var dataset = <%= raw(#myInMemoryObject) %>; is the right way to go but you need to prep your object to be in the right format.
The nodes specified in the links need to either be numeric references to nodes in the nodes array eg. 0 for first, 1 for second
var json ={
"nodes":[{"name":"Damien","id":"a"}, {"name":"Bob","id":"b"}],
"links":[{"source":0, "target":1,"value":1}]
}
or links to the actual objects which make the nodes themselves:
var a = {"name":"Damien","id":"a"};
var b = {"name":"Bob","id":"b"}
var json ={
"nodes":[a,b],
"links":[{"source":a,"target":b,"value":1}]
};
Relevant discussion is here: https://groups.google.com/forum/?fromgroups=#!topic/d3-js/LWuhBeEipz4
Example here: http://jsfiddle.net/5A9eV/1/