Esempio n. 1
0
Options makeOptions(JNIEnv* env, jobject options) {
  MT_REQUIRE_NOT_NULL(options);
  const auto cls = env->GetObjectClass(options);
  mt::Check::notNull(cls, "GetObjectClass(options) failed");

  Options opts;
  const auto fid_numPartitions = env->GetFieldID(cls, "numPartitions", "I");
  mt::Check::notNull(fid_numPartitions, "GetFieldID(numPartitions) failed");
  opts.num_partitions = env->GetIntField(options, fid_numPartitions);

  const auto fid_blockSize = env->GetFieldID(cls, "blockSize", "I");
  mt::Check::notNull(fid_blockSize, "GetFieldID(blockSize) failed");
  opts.block_size = env->GetIntField(options, fid_blockSize);

  const auto fid_createIfMissing = env->GetFieldID(cls, "createIfMissing", "Z");
  mt::Check::notNull(fid_createIfMissing, "GetFieldID(createIfMissing) failed");
  opts.create_if_missing = env->GetBooleanField(options, fid_createIfMissing);

  const auto fid_errorIfExists = env->GetFieldID(cls, "errorIfExists", "Z");
  mt::Check::notNull(fid_errorIfExists, "GetFieldID(errorIfExists) failed");
  opts.error_if_exists = env->GetBooleanField(options, fid_errorIfExists);

  const auto fid_readonly = env->GetFieldID(cls, "readonly", "Z");
  mt::Check::notNull(fid_readonly, "GetFieldID(readonly) failed");
  opts.readonly = env->GetBooleanField(options, fid_readonly);

  const auto fid_verbose = env->GetFieldID(cls, "verbose", "Z");
  mt::Check::notNull(fid_verbose, "GetFieldID(verbose) failed");
  opts.verbose = env->GetBooleanField(options, fid_verbose);

  const auto fid_lessThan =
      env->GetFieldID(cls, "lessThan", "Lio/multimap/Callables$LessThan;");
  mt::Check::notNull(fid_lessThan, "GetFieldID(lessThan) failed");
  const auto less_than = env->GetObjectField(options, fid_lessThan);
  if (less_than) {
    opts.compare = JavaCompare(env, less_than);
  }

  return opts;
}
Esempio n. 2
0
void Store::replaceUnlocked(uint32_t id, const char* block) {
  MT_REQUIRE_NOT_NULL(block);
  std::memcpy(getAddressOf(id), block, getBlockSize());
}