c

    cl

    3 weeks ago
    Hi, I am running 6.5.1 jdk8 ILP java client. For Sender class, I need to have a better way to handle null. Some fields in the same object could be null for int, short, or long column. I am looking for a better way dynamically to skip some columns which contain null value.
    Andrey Pechkurov

    Andrey Pechkurov

    3 weeks ago
    Hello
    You could simply skip those columns. The inserted row would get null values for the skipped columns then
    c

    cl

    3 weeks ago
    right, but I need to handle all cases. So, I don't want to rebuild all column call every time.
    Andrey Pechkurov

    Andrey Pechkurov

    3 weeks ago
    if (objectLongValue != null) {
        sender.longColumn("my_long_col", objectLongValue);
    }
    or something like that
    c

    cl

    3 weeks ago
    will it create multiple row if I check for each column.
    Andrey Pechkurov

    Andrey Pechkurov

    3 weeks ago
    No, it'll be the same row. The row gets "finalized" only when you call at/atNow
    c

    cl

    3 weeks ago
    great. Let me give it a try. Thanks a lot.
    sender.table("connections")
    .timestampColumn("ts", Os.currentTimeNanos())
    .stringColumn("tenantid", "localhost-08312022")
    .longColumn("id", conn.getId())
    if (conn.getMachine() != null)
    	sender.table("connections").stringColumn("machine", conn.getMachine());
    if (conn.getPort() != null)
    	sender.table("connections").longColumn("port", conn.getPort());
    sender.table("connections").atNow();
    The second null check is trying to append more columns, but it failed with error
    io.questdb.cutlass.line.LineSenderException: duplicated table. call <http://sender.at|sender.at>() or sender.atNow() to finish the current row first
    Andrey Pechkurov

    Andrey Pechkurov

    3 weeks ago
    You should remove extra .table() calls
    sender.table("connections")
    .timestampColumn("ts", Os.currentTimeNanos())
    .stringColumn("tenantid", "localhost-08312022")
    .longColumn("id", conn.getId())
    if (conn.getMachine() != null)
    	sender.stringColumn("machine", conn.getMachine());
    if (conn.getPort() != null)
    	sender.longColumn("port", conn.getPort());
    sender.atNow();
    c

    cl

    3 weeks ago
    I am able to by-pass exception, but no row in db. I do use sender.flush() right away.
    Andrey Pechkurov

    Andrey Pechkurov

    3 weeks ago
    You should call .flush() for a batch of rows, ideally. This would bring the best performance. But for local testing it's fine to call it on each row individually
    As for the inserted rows becoming visible with a delay, we have a concept of "commit lag". Please check this doc page:https://questdb.io/docs/guides/out-of-order-commit-lag
    c

    cl

    3 weeks ago
    ok, but row does not create in questdb.
    Andrey Pechkurov

    Andrey Pechkurov

    3 weeks ago
    That's because you need to call .flush().
    c

    cl

    3 weeks ago
    yes, I did after I set atNow().
    Thanks Andrey. I have a bug in my code. It works now.