Skip to content

Commit a5ffa67

Browse files
committed
Extend memory allocation for Arrow child allocators
1 parent 70b4107 commit a5ffa67

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.ebremer</groupId>
55
<artifactId>BeakGraph</artifactId>
6-
<version>0.3.0</version>
6+
<version>0.3.1</version>
77
<packaging>jar</packaging>
88
<build>
99
<plugins>

src/main/java/com/ebremer/beakgraph/rdf/BeakWriter.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ public void Add(Model m) {
124124
}
125125

126126
public void CreateDictionary() {
127-
System.out.println("Creating Dictionary...");
128127
DictionaryEncoding dictionaryEncoding = new DictionaryEncoding(0, true, new ArrowType.Int(32, true));
129128
dict = new LargeVarCharVector("Resource Dictionary", allocator);
130129
dict.allocateNewSafe();
@@ -192,7 +191,6 @@ public Resource WriteDataToFile(String base, ROCrate.ROCrateBuilder roc) {
192191
Resource rde = roc.getRDE();
193192
Resource target = roc.AddFolder(rde, base, BG.BeakGraph);
194193
//CommonsCompressionFactory ha;
195-
196194
vectors.forEach(v->{
197195
System.out.println("Writing --> "+v.getName());
198196
try (VectorSchemaRoot root = new VectorSchemaRoot(List.of(v.getField()), List.of(v))) {
@@ -263,62 +261,60 @@ public void ProcessTriple(Statement stmt) {
263261
} else switch (ct) {
264262
case "org.apache.jena.rdf.model.impl.ResourceImpl": {
265263
if (!byPredicate.containsKey(p)) {
266-
byPredicate.put(p, new PAW(allocator.newChildAllocator("PAW -> "+p, 0, 1024*1024*1024), nt, p));
264+
byPredicate.put(p, new PAW(allocator.newChildAllocator("PAW -> "+p, 0, Long.MAX_VALUE), nt, p));
267265
}
268266
byPredicate.get(p).set(res, o.asResource());
269267
break;
270268
}
271269
case "java.math.BigInteger": {
272270
long oo = o.asLiteral().getLong();
273271
if (!byPredicate.containsKey(p)) {
274-
byPredicate.put(p, new PAW(allocator.newChildAllocator("PAW -> "+p, 0, 1024*1024*1024), nt, p));
272+
byPredicate.put(p, new PAW(allocator.newChildAllocator("PAW -> "+p, 0, Long.MAX_VALUE), nt, p));
275273
}
276274
byPredicate.get(p).set(res, oo);
277275
break;
278276
}
279277
case "java.lang.Integer": {
280278
int oo = o.asLiteral().getInt();
281279
if (!byPredicate.containsKey(p)) {
282-
byPredicate.put(p, new PAW(allocator.newChildAllocator("PAW -> "+p, 0, 1024*1024*1024), nt, p));
280+
byPredicate.put(p, new PAW(allocator.newChildAllocator("PAW -> "+p, 0, Long.MAX_VALUE), nt, p));
283281
}
284282
byPredicate.get(p).set(res, oo);
285283
break;
286284
}
287285
case "java.lang.Long": {
288286
long oo = o.asLiteral().getLong();
289287
if (!byPredicate.containsKey(p)) {
290-
byPredicate.put(p, new PAW(allocator.newChildAllocator("PAW -> "+p, 0, 1024*1024*1024), nt, p));
288+
byPredicate.put(p, new PAW(allocator.newChildAllocator("PAW -> "+p, 0, Long.MAX_VALUE), nt, p));
291289
}
292290
byPredicate.get(p).set(res, oo);
293291
break;
294292
}
295293
case "java.lang.Float": {
296294
float oo = o.asLiteral().getFloat();
297295
if (!byPredicate.containsKey(p)) {
298-
byPredicate.put(p, new PAW(allocator.newChildAllocator("PAW -> "+p, 0, 1024*1024*1024), nt, p));
296+
byPredicate.put(p, new PAW(allocator.newChildAllocator("PAW -> "+p, 0, Long.MAX_VALUE), nt, p));
299297
}
300298
byPredicate.get(p).set(res, oo);
301299
break;
302300
}
303301
case "java.lang.String": {
304302
String oo = o.asLiteral().toString();
305303
if (!byPredicate.containsKey(p)) {
306-
byPredicate.put(p, new PAW(allocator.newChildAllocator("PAW -> "+p, 0, 1024*1024*1024), nt, p));
304+
byPredicate.put(p, new PAW(allocator.newChildAllocator("PAW -> "+p, 0, Long.MAX_VALUE), nt, p));
307305
}
308306
byPredicate.get(p).set(res, oo);
309307
break;
310308
}
311309
default:
312-
System.out.println("Can't handle ["+ct+"]");
313-
System.out.println(s+" "+p+" "+o);
314-
throw new Error("BAMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
310+
throw new Error("Can't handle ["+ct+"] "+s+" "+p+" "+o);
315311
}
316312
}
317313

318314
public void Create(ROCrate.ROCrateBuilder roc) throws IOException {
319-
System.out.println("Creating BeakGraph...");
315+
//System.out.println("Creating BeakGraph...");
320316
int cores = Runtime.getRuntime().availableProcessors();
321-
System.out.println(cores+" cores available");
317+
//System.out.println(cores+" cores available");
322318
ThreadPoolExecutor engine = new ThreadPoolExecutor(cores,cores,0L,TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
323319
engine.prestartAllCoreThreads();
324320
CopyOnWriteArrayList<Future<Model>> list = new CopyOnWriteArrayList<>();
@@ -328,7 +324,7 @@ public void Create(ROCrate.ROCrateBuilder roc) throws IOException {
328324
list.add(engine.submit(worker));
329325
Jobs.put(k, new Job(k,worker,"WAITING"));
330326
});
331-
System.out.println("All jobs submitted --> "+list.size());
327+
//System.out.println("All jobs submitted --> "+list.size());
332328
engine.shutdown();
333329
while (!engine.isTerminated()) {
334330
int c = engine.getQueue().size()+engine.getActiveCount();
@@ -346,15 +342,15 @@ public void Create(ROCrate.ROCrateBuilder roc) throws IOException {
346342
}
347343
}
348344
//timer.cancel();
349-
System.out.println("Engine shutdown");
350-
System.out.println("engine jobs : "+list.size());
345+
//System.out.println("Engine shutdown");
346+
//System.out.println("engine jobs : "+list.size());
351347
metairi = WriteDictionaryToFile(base, roc);
352348
WriteDataToFile(base, roc);
353349
}
354350

355351
@Override
356352
public void close() {
357-
System.out.println("Close Vectors");
353+
//System.out.println("Close Vectors");
358354
vectors.forEach(v->{
359355
v.close();
360356
});
@@ -367,14 +363,18 @@ public void close() {
367363
System.out.println("OVERWATCH : "+k+" "+ex.getMessage());
368364
}
369365
});
370-
//System.out.println("Close Node Table");
371366
nt.close();
372-
//System.out.println("Close Dictionary");
373-
dict.close();
367+
try {
368+
dict.close();
369+
//System.out.println("Close Dictionary");
370+
} catch (OutOfMemoryException ex) {
371+
System.out.println("Dictionary OVERWATCH : "+ex.getMessage());
372+
Logger.getLogger(BeakWriter.class.getName()).log(Level.SEVERE, null, ex);
373+
}
374374
try (allocator) {
375-
System.out.println("Close Allocator");
375+
//System.out.println("Close Allocator");
376376
} catch (OutOfMemoryException ex) {
377-
System.out.println("FINAL OVERWATCH : "+ex.getMessage());
377+
System.out.println("Allocator OVERWATCH : "+ex.getMessage());
378378
Logger.getLogger(BeakWriter.class.getName()).log(Level.SEVERE, null, ex);
379379
}
380380
}

src/main/java/com/ebremer/beakgraph/rdf/NodeTable.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @author erich
2020
*/
21-
public class NodeTable {
21+
public class NodeTable implements AutoCloseable {
2222

2323
private final LargeVarCharVector dictionary;
2424
private final HashMap<String, Integer> map;
@@ -43,8 +43,9 @@ public void setBlankNodes(HashMap<String,Integer> blanknodes) {
4343
this.blanknodes = blanknodes;
4444
}
4545

46+
@Override
4647
public void close() {
47-
dictionary.close();
48+
4849
}
4950

5051
public HashMap<String,Integer> getBlankNodes() {

0 commit comments

Comments
 (0)