mirror of
https://github.com/JHUAPL/AccumuloGraph.git
synced 2026-01-09 12:47:56 -05:00
Added "preload all" functionality and unit tests for same
This commit is contained in:
@@ -155,11 +155,12 @@ public class AccumuloGraph implements Graph, KeyIndexableGraph, IndexableGraph {
|
||||
// any "preloaded" properties now, which saves us a round-trip
|
||||
// to Accumulo later.
|
||||
String[] preload = globals.getConfig().getPreloadedProperties();
|
||||
if (preload == null) {
|
||||
if (preload == null && !globals.getConfig().getPreloadAllProperties()) {
|
||||
preload = new String[]{};
|
||||
}
|
||||
|
||||
Map<String, Object> props = globals.getVertexWrapper().readProperties(vertex, preload);
|
||||
Map<String, Object> props = globals.getVertexWrapper()
|
||||
.readProperties(vertex, preload);
|
||||
if (props == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1036,17 +1036,17 @@ implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
if (timeout <= 0 && conf.getProperty(Keys.PRELOADED_PROPERTIES) != null) {
|
||||
throw new IllegalArgumentException("You cannot preload properties "
|
||||
+ "without first setting #propertyCacheTimeout(String property, int millis) "
|
||||
+ "to a positive value.");
|
||||
}
|
||||
|
||||
if (getPreloadAllProperties() && getPreloadedProperties() != null) {
|
||||
throw new IllegalArgumentException("Cannot preload all properties"
|
||||
+ " and specified properties simultaneously");
|
||||
}
|
||||
}
|
||||
|
||||
if (timeout <= 0 && (getPreloadedProperties() != null || getPreloadAllProperties())) {
|
||||
throw new IllegalArgumentException("You cannot preload properties "
|
||||
+ "without first setting #propertyCacheTimeout(String property, int millis) "
|
||||
+ "to a positive value.");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPropertyValue(String prop, String val, boolean canBeEmpty) {
|
||||
if (val == null) {
|
||||
|
||||
@@ -221,6 +221,26 @@ public class ElementPropertyCachingTest {
|
||||
graph.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPreloadAllProperties() {
|
||||
AccumuloGraphConfiguration cfg =
|
||||
AccumuloGraphTestUtils.generateGraphConfig("preloadAllProperties");
|
||||
cfg.setPropertyCacheTimeout(null, TIMEOUT);
|
||||
cfg.setPreloadAllProperties(true);
|
||||
|
||||
Graph graph = open(cfg);
|
||||
|
||||
AccumuloVertex v = (AccumuloVertex) graph.addVertex("V");
|
||||
v.setProperty(NON_CACHED, true);
|
||||
v.setProperty(CACHED, true);
|
||||
|
||||
v = (AccumuloVertex) graph.getVertex("V");
|
||||
assertEquals(true, v.getPropertyInMemory(NON_CACHED));
|
||||
assertEquals(true, v.getPropertyInMemory(CACHED));
|
||||
|
||||
graph.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPreloadSomeProperties() {
|
||||
AccumuloGraphConfiguration cfg =
|
||||
|
||||
Reference in New Issue
Block a user