@@ -53,51 +53,40 @@ public TripleWriteCache(MarkLogicClient client, long cacheSize) {
53
53
54
54
protected synchronized void flush () throws RepositoryException , MalformedQueryException , UpdateExecutionException , IOException {
55
55
if (cache .isEmpty ()) { return ; }
56
- StringBuffer entireQuery = new StringBuffer ();
56
+ StringBuilder entireQuery = new StringBuilder ();
57
57
SPARQLQueryBindingSet bindingSet = new SPARQLQueryBindingSet ();
58
58
59
59
for (Namespace ns :cache .getNamespaces ()){
60
- entireQuery .append ("PREFIX " + ns .getPrefix ()+ ": <" + ns .getName ()+ ">. " );
60
+ entireQuery .append ("PREFIX " ). append ( ns .getPrefix ()). append ( ": <" ). append ( ns .getName ()). append ( ">. " );
61
61
}
62
62
entireQuery .append ("INSERT DATA { " );
63
63
64
- Set <Resource > distinctCtx = new HashSet <Resource >();
65
- for (Resource context :cache .contexts ()) {
66
- distinctCtx .add (context );
67
- }
64
+ Set <Resource > distinctCtx = new HashSet <>();
65
+ distinctCtx .addAll (cache .contexts ());
68
66
69
67
for (Resource ctx : distinctCtx ) {
70
68
if (ctx != null ) {
71
- entireQuery .append (" GRAPH <" + ctx + "> { " );
69
+ entireQuery .append (" GRAPH <" ). append ( ctx ). append ( "> { " );
72
70
}
73
71
for (Statement stmt : cache .filter (null , null , null , ctx )) {
74
- if (stmt .getSubject () instanceof org .eclipse .rdf4j .model .BNode ) {
75
- entireQuery .append ("<http://marklogic.com/semantics/blank/" + stmt .getSubject ().stringValue () + "> " );
76
- }else {
77
- entireQuery .append ("<" + stmt .getSubject ().stringValue () + "> " );
78
- }
79
- if (stmt .getPredicate () instanceof org .eclipse .rdf4j .model .BNode ) {
80
- entireQuery .append ("<http://marklogic.com/semantics/blank/" + stmt .getPredicate ().stringValue () + "> " );
81
- }else {
82
- entireQuery .append ("<" + stmt .getPredicate ().stringValue () + "> " );
83
- }
72
+
73
+ entireQuery .append ("<" ).append (stmt .getSubject ().stringValue ()).append ("> " );
74
+
75
+ entireQuery .append ("<" ).append (stmt .getPredicate ().stringValue ()).append ("> " );
76
+
84
77
Value object =stmt .getObject ();
85
78
if (object instanceof Literal ) {
86
79
Literal lit = (Literal ) object ;
87
80
entireQuery .append ("\" " );
88
81
entireQuery .append (SPARQLUtil .encodeString (lit .getLabel ()));
89
82
entireQuery .append ("\" " );
90
83
if (null == lit .getLanguage ().orElse (null )) {
91
- entireQuery .append ("^^<" + lit .getDatatype ().stringValue () + ">" );
84
+ entireQuery .append ("^^<" ). append ( lit .getDatatype ().stringValue ()). append ( ">" );
92
85
}else {
93
- entireQuery .append ("@" + lit .getLanguage ().orElse (null ));
86
+ entireQuery .append ("@" ). append ( lit .getLanguage ().orElse (null ));
94
87
}
95
88
} else {
96
- if (stmt .getObject () instanceof org .eclipse .rdf4j .model .BNode ) {
97
- entireQuery .append ("<http://marklogic.com/semantics/blank/" + stmt .getObject ().stringValue () + "> " );
98
- }else {
99
- entireQuery .append ("<" + object .stringValue () + "> " );
100
- }
89
+ entireQuery .append ("<" ).append (object .stringValue ()).append ("> " );
101
90
}
102
91
entireQuery .append ("." );
103
92
}
0 commit comments