This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Integer[] flatten(Object[] inputArray) throws IllegalArgumentException { | |
if (inputArray == null) return null; | |
List<Integer> flatList = new ArrayList<Integer>(); | |
for (Object element : inputArray) { | |
if (element instanceof Integer) { | |
flatList.add((Integer) element); | |
} else if (element instanceof Object[]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void testLoad() { | |
IgniteCache<BinaryObject, BinaryObject> cache = ignite.getOrCreateCache(getConfig()).withKeepBinary(); | |
String keyValue = "3M Company"; | |
BinaryObjectBuilder keyBuilder = ignite.binary().builder("keyType") | |
.setField("f1", keyValue).hashCode(fieldValue.hashCode()); | |
BinaryObject value = cache.get(keyBuilder.build()); | |
logger.info("Loaded value {} for key {}", value, keyValue); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void loadTableWithCustomKeyColumns(Ignite ignite, Table table) { | |
CsvReader csvfile = null; | |
try (IgniteDataStreamer<BinaryObject, BinaryObject> streamer = ignite.dataStreamer(table.getName())) { | |
csvfile = new CsvReader(FILE_PATH + table.getName() + ".csv"); | |
csvfile.readHeaders(); | |
BinaryObjectBuilder keyBuilder = ignite.binary().builder(table.getCacheValueType()); | |
BinaryObjectBuilder valueBuilder = ignite.binary().builder(table.getCacheValueType()); | |
while (csvfile.readRecord()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static CacheConfiguration<String, BinaryObject> getCacheConfigWithRandomIdAsKey(Table table) { | |
CacheConfiguration<String, BinaryObject> cfg = new CacheConfiguration<>(); | |
cfg.setName(table.getName()); | |
cfg.setCacheMode(table.getCacheMode()); | |
setQueryEntities(table, cfg); | |
return cfg; | |
} | |
private static void setQueryEntities(Table table, CacheConfiguration cfg) { | |
QueryEntity qe = new QueryEntity(); |