Exemplo n.º 1
0
// getResult(id, objectWrapper):  IMMEDIATE
void queryGetResult(const Arguments & args) {
  REQUIRE_ARGS_LENGTH(2);
  v8::Isolate * isolate = args.GetIsolate();

  QueryOperation * op = unwrapPointer<QueryOperation *>(args.Holder());
  size_t id = args[0]->Uint32Value();
  Handle<Object> wrapper = args[1]->ToObject();

  QueryResultHeader * header = op->getResult(id);

  if(header) {
    if(header->data) {
      wrapper->Set(GET_KEY(K_data),
        LOCAL_BUFFER(node::Buffer::New(isolate, header->data,
                                       op->getResultRowSize(header->depth),
                                       doNotFreeQueryResultAtGC, 0)));
    } else {
      wrapper->Set(GET_KEY(K_data), Null(isolate));
    }
    wrapper->Set(GET_KEY(K_level), v8::Uint32::New(isolate, header->depth));
    wrapper->Set(GET_KEY(K_tag),   v8::Uint32::New(isolate, header->tag));
    args.GetReturnValue().Set(true);
  } else {
    args.GetReturnValue().Set(false);
  }
}
Exemplo n.º 2
0
/* DBOperationHelper takes an array of HelperSpecs.
   arg0: Length of Array
   arg1: Array of HelperSpecs
   arg2: TransactionImpl *
   arg3: Old BatchImpl wrapper (for recycling)

   Returns: BatchImpl
*/
void DBOperationHelper(const Arguments &args) {
  EscapableHandleScope scope(args.GetIsolate());

  int length = args[0]->Int32Value();
  const Local<Object> array = args[1]->ToObject();
  TransactionImpl *txc = unwrapPointer<TransactionImpl *>(args[2]->ToObject());
  Handle<Value> oldWrapper = args[3];

  BatchImpl * pendingOps = new BatchImpl(txc, length);

  for(int i = 0 ; i < length ; i++) {
    Handle<Object> spec = array->Get(i)->ToObject();

    int opcode  = spec->Get(HELPER_OPCODE)->Int32Value();
    bool is_vo  = spec->Get(HELPER_IS_VO)->ToBoolean()->Value();
    bool op_ok  = spec->Get(HELPER_IS_VALID)->ToBoolean()->Value();

    KeyOperation * op = pendingOps->getKeyOperation(i);
    
    if(op_ok) {
      op->opcode = opcode;
      if(is_vo) DBOperationHelper_VO(spec, *op);
      else      DBOperationHelper_NonVO(spec, *op);
    }
  }
  
  if(oldWrapper->IsObject()) {
    args.GetReturnValue().Set(BatchImpl_Recycle(oldWrapper->ToObject(), pendingOps));
  } else {
    args.GetReturnValue().Set(BatchImpl_Wrapper(pendingOps));
  }
}
Exemplo n.º 3
0
/* JS QueryOperation.create(ndbRootProjection, keyBuffer, depth)
*/
void createQueryOperation(const Arguments & args) {
  DEBUG_MARKER(UDEB_DEBUG);
  REQUIRE_ARGS_LENGTH(3);
  Isolate * isolate = Isolate::GetCurrent();

  int size = args[2]->Int32Value();
  QueryOperation * queryOperation = new QueryOperation(size);
  const NdbQueryOperationDef * root, * current;

  Local<Value> v;
  Local<Object> spec = args[0]->ToObject();

  setRowBuffers(queryOperation, spec);
  current = root = createTopLevelQuery(queryOperation, spec,
                                       args[1]->ToObject());

  while(! (v = spec->Get(GET_KEY(K_next)))->IsNull()) {
    spec = v->ToObject();
    current = createNextLevel(queryOperation, spec, current);
    assert(current->getOpNo() == spec->Get(GET_KEY(K_depth))->Uint32Value());
    setRowBuffers(queryOperation, spec);
  }
  queryOperation->prepare(root);
  args.GetReturnValue().Set(QueryOperation_Wrapper(queryOperation));
}
Exemplo n.º 4
0
/* getTable() method call
   ASYNC
   arg0: Ndb *
   arg1: database name
   arg2: table name
   arg3: user_callback
*/
void getTable(const Arguments &args) {
  DEBUG_MARKER(UDEB_DETAIL);
  REQUIRE_ARGS_LENGTH(4);
  GetTableCall * ncallptr = new GetTableCall(args);
  ncallptr->runAsync();
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 5
0
void closeNdb(const Arguments &args) {
  DEBUG_MARKER(UDEB_DETAIL);
  typedef NativeDestructorCall<Ndb> MCALL;
  MCALL * mcallptr = new MCALL(args);
  mcallptr->runAsync();
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 6
0
void execute(const Arguments &args) {
  EscapableHandleScope scope(args.GetIsolate());
  REQUIRE_ARGS_LENGTH(4);
  TxExecuteAndCloseCall * ncallptr = new TxExecuteAndCloseCall(args);
  ncallptr->runAsync();
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 7
0
void BatchImpl_freeImpl(const Arguments &args) {
  BatchImpl * set = unwrapPointer<BatchImpl *>(args.Holder());
  delete set;
  set = 0;
  wrapPointerInObject(set, BatchImplEnvelope, args.Holder());
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 8
0
// int nextResult(buffer) 
// IMMEDIATE
void scanNextResult(const Arguments & args) {
  DEBUG_MARKER(UDEB_DETAIL);
  EscapableHandleScope scope(args.GetIsolate());
  typedef NativeMethodCall_1_<int, ScanOperation, char *> MCALL;
  MCALL mcall(& ScanOperation::nextResult, args);
  mcall.run();
  args.GetReturnValue().Set(scope.Escape(mcall.jsReturnVal()));
}
Exemplo n.º 9
0
/* Call destructor 
*/
void destroy(const Arguments &args) {
  DEBUG_MARKER(UDEB_DEBUG);  
  REQUIRE_ARGS_LENGTH(0);

  AsyncNdbContext *c = unwrapPointer<AsyncNdbContext *>(args.Holder());
  delete c;
  args.GetReturnValue().SetUndefined();
}
void Ndb_cluster_connection_delete_wrapper(const Arguments &args) {
  DEBUG_MARKER(UDEB_DETAIL);
  EscapableHandleScope scope(args.GetIsolate());
  typedef NativeDestructorCall<Ndb_cluster_connection> MCALL;
  MCALL * mcallptr = new MCALL(args);
  mcallptr->runAsync();
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 11
0
/* IMMEDIATE.
*/
void executeAsynch(const Arguments &args) {
  EscapableHandleScope scope(args.GetIsolate());
  typedef NativeMethodCall_4_<int, BatchImpl,
                              int, int, int, Handle<Function> > MCALL;
  MCALL mcall(& BatchImpl::executeAsynch, args);
  mcall.run();
  args.GetReturnValue().Set(mcall.jsReturnVal());
}
Exemplo n.º 12
0
void end(const Arguments & args) {
  DEBUG_MARKER(UDEB_DETAIL);
  EscapableHandleScope scope(args.GetIsolate());
  typedef NativeMethodCall_0_<int, NdbScanFilter> NCALL;
  NCALL ncall(& NdbScanFilter::end, args);
  ncall.run();
  args.GetReturnValue().Set(scope.Escape(ncall.jsReturnVal()));
}
Exemplo n.º 13
0
// Constructor wrapper
void newScanOperation(const Arguments &args) {
  EscapableHandleScope scope(args.GetIsolate());
  ScanOperation * s = new ScanOperation(args);
  Local<Value> wrapper = ScanOperationEnvelope.wrap(s);
  // freeFromGC: Disabled as it leads to segfaults during garbage collection
  // ScanOperationEnvelope.freeFromGC(helper, wrapper);
  args.GetReturnValue().Set(scope.Escape(wrapper));
}
Exemplo n.º 14
0
void create_ndb(const Arguments &args) {
  REQUIRE_ARGS_LENGTH(3);  

  typedef NativeCFunctionCall_2_<Ndb *, Ndb_cluster_connection *, const char *> MCALL;
  MCALL * mcallptr = new MCALL(& async_create_ndb, args);
  mcallptr->wrapReturnValueAs(& NdbEnvelope);
  mcallptr->runAsync();
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 15
0
void querySetTransactionImpl(const Arguments &args) {
  REQUIRE_ARGS_LENGTH(1);

  typedef NativeVoidMethodCall_1_<QueryOperation, TransactionImpl *> MCALL;
  MCALL mcall(& QueryOperation::setTransactionImpl, args);
  mcall.run();
  
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 16
0
void getAutoIncValue(const Arguments &args) {
  DEBUG_MARKER(UDEB_DEBUG);
  REQUIRE_ARGS_LENGTH(4);  
  typedef NativeCFunctionCall_3_<Uint64, Ndb *, const NdbDictionary::Table *,
                                 uint32_t> MCALL;
  MCALL * mcallptr = new MCALL(& getAutoInc, args);
  mcallptr->runAsync();
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 17
0
// fetchAllResults()
// ASYNC
void queryFetchAllResults(const Arguments &args) {
  EscapableHandleScope scope(args.GetIsolate());
  REQUIRE_ARGS_LENGTH(1);
  typedef NativeMethodCall_0_<int, QueryOperation> MCALL;
  MCALL * mcallptr = new MCALL(& QueryOperation::fetchAllResults, args);
  mcallptr->errorHandler = getNdbErrorIfLessThanZero;
  mcallptr->runAsync();
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 18
0
// int fetchResults(buffer, forceSend, callback) 
// ASYNC; CALLBACK GETS (Null-Or-Error, Int) 
void scanFetchResults(const Arguments & args) {
  DEBUG_MARKER(UDEB_DETAIL);
  REQUIRE_ARGS_LENGTH(3);
  typedef NativeMethodCall_2_<int, ScanOperation, char *, bool> MCALL;
  MCALL * ncallptr = new MCALL(& ScanOperation::fetchResults, args);
  ncallptr->errorHandler = getNdbErrorIfLessThanZero;
  ncallptr->runAsync();
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 19
0
/* shutdown() 
   IMMEDIATE
*/
void shutdown(const Arguments &args) {
  DEBUG_MARKER(UDEB_DEBUG);  
  REQUIRE_ARGS_LENGTH(0);
  
  typedef NativeVoidMethodCall_0_<AsyncNdbContext> NCALL;
  NCALL ncall(& AsyncNdbContext::shutdown, args);
  ncall.run();
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 20
0
void getInterpretedCode(const Arguments & args) {
  DEBUG_MARKER(UDEB_DETAIL);
  EscapableHandleScope scope(args.GetIsolate());
  typedef NativeConstMethodCall_0_<const NdbInterpretedCode *, NdbScanFilter> NCALL;
  NCALL ncall(& NdbScanFilter::getInterpretedCode, args);
  ncall.wrapReturnValueAs(getConstNdbInterpretedCodeEnvelope());
  ncall.run();  
  args.GetReturnValue().Set(scope.Escape(ncall.jsReturnVal()));
}
Exemplo n.º 21
0
void udeb_setFileLevel(const Arguments &args) {
  unsigned char filename[250];
  
  args[0]->ToString()->WriteOneByte(filename, 0, 250);
  index_set(udeb_hash(udeb_basename((const char *) filename)));
  uni_debug = udeb_per_file = 1;

  args.GetReturnValue().Set(true);
}
/*   void set_name(const char *name);
*/
void Ndb_cluster_connection_set_name(const Arguments &args) {
  DEBUG_MARKER(UDEB_DETAIL);
  
  REQUIRE_ARGS_LENGTH(1);
  typedef NativeVoidMethodCall_1_<Ndb_cluster_connection, const char *> MCALL;
  MCALL mcall(& Ndb_cluster_connection::set_name, args);
  mcall.run();
  
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 23
0
// void prepareAndExecute() 
// ASYNC
void queryPrepareAndExecute(const Arguments &args) {
  EscapableHandleScope scope(args.GetIsolate());
  DEBUG_MARKER(UDEB_DEBUG);
  REQUIRE_ARGS_LENGTH(1);
  typedef NativeMethodCall_0_<int, QueryOperation> MCALL;
  MCALL * mcallptr = new MCALL(& QueryOperation::prepareAndExecute, args);
  mcallptr->errorHandler = getNdbErrorIfLessThanZero;
  mcallptr->runAsync();
  args.GetReturnValue().SetUndefined();
}
Exemplo n.º 24
0
void udeb_setLevel(const Arguments &args) {
  udeb_level = args[0]->Int32Value();
  // C code cannot log below UDEB_INFO
  uni_debug = (udeb_per_file || (udeb_level > UDEB_NOTICE)) ? 1 : 0;
  
  // leave uni_debug off until stack corruption in udeb_print() is fixed
  //uni_debug = 0;
  
  args.GetReturnValue().Set(true);
}
Exemplo n.º 25
0
/* listTables() Method call
   ASYNC
   arg0: SessionImpl *
   arg1: database name
   arg2: user_callback
*/
void listTables(const Arguments &args) {
  DEBUG_MARKER(UDEB_DETAIL);  
  REQUIRE_ARGS_LENGTH(3);
  
  ListTablesCall * ncallptr = new ListTablesCall(args);

  DEBUG_PRINT("listTables in database: %s", ncallptr->arg1);
  ncallptr->runAsync();

  args.GetReturnValue().SetUndefined();
}
/*   int wait_until_ready(int timeout_for_first_alive,
                          int timeout_after_first_alive,
                          callback);
     2 args SYNC / 3 args ASYNC
*/
void Ndb_cluster_connection_wait_until_ready(const Arguments &args) {
  DEBUG_MARKER(UDEB_DETAIL);
  EscapableHandleScope scope(args.GetIsolate());

  args.GetReturnValue().SetUndefined();
  REQUIRE_MIN_ARGS(2);
  REQUIRE_MAX_ARGS(3);
  
  typedef NativeMethodCall_2_<int, Ndb_cluster_connection, int, int> MCALL;

  if(args.Length() == 3) {
    MCALL * mcallptr = new MCALL(& Ndb_cluster_connection::wait_until_ready, args);
    mcallptr->runAsync();
  }
  else {
    MCALL mcall(& Ndb_cluster_connection::wait_until_ready, args);
    mcall.run();
    args.GetReturnValue().Set(mcall.jsReturnVal());
  };
}
/*  unsigned node_id();
    IMMEDIATE
*/
void Ndb_cluster_connection_node_id(const Arguments &args) {
  DEBUG_MARKER(UDEB_DETAIL);
  EscapableHandleScope scope(args.GetIsolate());
  
  REQUIRE_ARGS_LENGTH(0);  
  
  typedef NativeMethodCall_0_<unsigned int, Ndb_cluster_connection> MCALL;
  MCALL mcall(& Ndb_cluster_connection::node_id, args);
  mcall.run();
  args.GetReturnValue().Set(mcall.jsReturnVal());
 }
Exemplo n.º 28
0
/* Constructor 
*/
void createAsyncNdbContext(const Arguments &args) {
  DEBUG_MARKER(UDEB_DEBUG);

  REQUIRE_CONSTRUCTOR_CALL();
  REQUIRE_ARGS_LENGTH(1);

  JsValueConverter<Ndb_cluster_connection *> arg0(args[0]);
  AsyncNdbContext * ctx = new AsyncNdbContext(arg0.toC());
  Local<Value> wrapper = AsyncNdbContextEnvelope.wrap(ctx);
  args.GetReturnValue().Set(wrapper);
}
Exemplo n.º 29
0
void getStatistics(const Arguments &args) {
  EscapableHandleScope scope(args.GetIsolate());
  Ndb *ndb = unwrapPointer<Ndb *>(args.Holder());

  Local<Object> stats = Object::New(args.GetIsolate());
  for(int i = 0 ; i < Ndb::NumClientStatistics ; i ++) {
    stats->Set(String::NewFromUtf8(args.GetIsolate(), ndb->getClientStatName(i)),
               Number::New(args.GetIsolate(), ndb->getClientStat(i)));
  }

  args.GetReturnValue().Set(scope.Escape(stats));
}
Exemplo n.º 30
0
/* cmp() 
   ARG0: BinaryCondition
   ARG1: Column ID
   ARG2: Buffer
   ARG3: Offset
   ARG4: Length
*/
void cmp(const Arguments &args) {
  NdbScanFilter * filter = unwrapPointer<NdbScanFilter *>(args.Holder());
  int condition   = args[0]->Int32Value();
  int columnId    = args[1]->Uint32Value();
  char * buffer   = node::Buffer::Data(args[2]->ToObject());
  uint32_t offset = args[3]->Uint32Value();
  uint32_t length = args[4]->Uint32Value();

  int rval = filter->cmp(NdbScanFilter::BinaryCondition(condition), 
                         columnId, buffer + offset, length);

  args.GetReturnValue().Set(rval);
}