Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/68#discussion_r38222554
--- Diff: core/sql/optimizer/costmethod.cpp ---
@@ -13997,15 +13997,188 @@
CostMethodFastExtract::computeOperatorCostInternal(RelExpr* op,
/**********************************************************************/
//<pb>
-// ----QUICKSEARCH FOR DP2Insert........................................
+// ----QUICKSEARCH FOR HbaseInsert........................................
/**********************************************************************/
/* */
-/* CostMethodDP2Insert */
+/* CostMethodHbaseInsert */
/* */
/**********************************************************************/
-#pragma nowarn(262) // warning elimination
+// -----------------------------------------------------------------------
+// CostMethodHbaseInsert::cacheParameters()
+// -----------------------------------------------------------------------
+void CostMethodHbaseInsert::cacheParameters(RelExpr* op, const Context *
myContext)
+{
+ CostMethod::cacheParameters(op, myContext);
+
+ HbaseInsert* insOp = (HbaseInsert *)op;
+
+ CMPASSERT(partFunc_ != NULL);
+ NodeMap * nodeMap = (NodeMap *)partFunc_->getNodeMap();
+ if (nodeMap)
+ activePartitions_ = (CostScalar)nodeMap->getNumActivePartitions();
+ else
+ // Occasionally (e.g., regress/fullstack2/test023, the insert/select
+ // from t023t1 into t023t2 using a transpose operator), we get
+ // a ReplicateNoBroadcastPartitioningFunction lacking a node map.
+ // In this case we'll just use the number of partitions from the
+ // partitioning function itself -- which is probably an ESP count.
+ activePartitions_ = (CostScalar)partFunc_->getCountOfPartitions();
+
+ // The number of asynchronous streams is USUALLY the # of active parts.
+ countOfAsynchronousStreams_ = activePartitions_;
+} // CostMethodHbaseInsert::cacheParameters()
+
+
+
+// -----------------------------------------------------------------------
+// CostMethodHbaseInsert::computeOperatorCostInternal()
+// -----------------------------------------------------------------------
+Cost* CostMethodHbaseInsert::computeOperatorCostInternal(RelExpr* op,
+ const Context* myContext,
+ Lng32& countOfStreams)
+{
+ cacheParameters(op, myContext);
+ estimateDegreeOfParallelism();
+
+ // ------------------------------------------------------
+ // Save off our current estimated degree of parallelism.
+ // in the 'out' parameter; we might revise it below
+ // ------------------------------------------------------
+ countOfStreams = countOfStreams_;
+
+ CostScalar currentCpus =
+
(CostScalar)myContext->getPlan()->getPhysicalProperty()->getCurrentCountOfCPUs();
+ activeCpus_ = MINOF(countOfAsynchronousStreams_, currentCpus);
+
+ // update count of streams; the caller of the method uses this value
+ if ((countOfAsynchronousStreams_ > 0) &&
+ (countOfAsynchronousStreams_ < countOfStreams)
+ )
+ countOfStreams = (Lng32)countOfAsynchronousStreams_.getValue();
+
+
+ streamsPerCpu_ =
+ (countOfAsynchronousStreams_ / activeCpus_).getCeiling();
+
+ CostScalar noOfProbesPerStream(csOne);
+
+ // Determine the number of probes per stream. Use this number as
+ // the number of rows to insert (this is "per-stream" costing).
+
+ noOfProbesPerStream =
+ (noOfProbes_ / countOfAsynchronousStreams_).minCsOne();
+
+ // ************************************************************
+ // Compute the write/read cost for the insert
--- End diff --
Good question. From a SQL point of view, there should be, because we need
to check for primary key constraint violation. From an HBase point of view, we
must be doing a separate 'get' in order to check for this as 'put' doesn't care
if a row with the given key already exists. I will address this in the next
check-in.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---