[ 
https://issues.apache.org/jira/browse/DRILL-5043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15679161#comment-15679161
 ] 

Nagarajan Chinnasamy commented on DRILL-5043:
---------------------------------------------

Locally, I've implemented a new function session_id as one of the 
ContextFunctions and it seems to working fine in an embedded mode installation 
on windows.

Following are the changes I made:

# I introduced a new function session_id() in ContextFunctions.java that 
returns its output through BigIntHolder
# sessionId is a variable maintained in UserSession.java as per the following 
and has a getter method:
{code}
           private static final AtomicLong nextSessionId = new AtomicLong(1);
           private final long sessionId;

           private UserSession() {
             queryCount = new AtomicInteger(0);
             sessionId = nextSessionId.getAndIncrement();
           } 
{code}
# ContextInformation.java is modified to introduce sessionId as one of the 
properties with a getter method.
# Utility.createQueryContexInformation is modified to accept sessionId as 
additional argument to set the sessionId through QueryContextInformation's 
builder interface. QueryContext.java, TestLocalExchange.java, 
TestPartitionSender.java, TestFragmentChecker.java are modified to invoke new 
Utilities.createQueryContextInformation method.
# QueryContextInformation.java is modified to set and get sessionId and to 
serialize sessionId.
# BitControl.java and SchemaBitControl.java are modified to include sessionId.

I am not sure about one change I made in BitControl.java in the following block:
{code}
    @@ -6934,10 +6934,15 @@ public final class BitControl {
             case 26: {
               bitField0_ |= 0x00000004;
               defaultSchemaName_ = input.readBytes();
               break;
             }
    +       case 36: {
    +         bitField0_ |= 0x00000008;
    +         sessionId_ = input.readInt64();
    +         break;
    +       }
{code}

I am not sure what value I should use in the "case" condition. I have randomly 
put 36 there!!!!

Please review the above approach and let me know if I am in right direction. 
Thanks.


> Function that returns a unique id per session/connection similar to MySQL's 
> CONNECTION_ID()
> -------------------------------------------------------------------------------------------
>
>                 Key: DRILL-5043
>                 URL: https://issues.apache.org/jira/browse/DRILL-5043
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Functions - Drill
>    Affects Versions: 1.8.0
>            Reporter: Nagarajan Chinnasamy
>            Priority: Minor
>              Labels: CONNECTION_ID, SESSION, UDF
>
> Design and implement a function that returns a unique id per 
> session/connection similar to MySQL's CONNECTION_ID().



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to