dev.responsive.kafka.internal.db.ColumnName Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2023 Responsive Computing, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.responsive.kafka.internal.db;
import com.datastax.oss.driver.api.querybuilder.Literal;
import com.datastax.oss.driver.api.querybuilder.QueryBuilder;
import com.datastax.oss.driver.api.querybuilder.relation.ColumnRelationBuilder;
import com.datastax.oss.driver.api.querybuilder.relation.Relation;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.function.Function;
import org.apache.kafka.common.utils.Bytes;
public enum ColumnName {
// shared partition key column
PARTITION_KEY("partitionKey", "partitionkey"),
SEGMENT_START_TIMESTAMP("segmentStartTimestamp", "segmentstarttimestamp"),
// columns for the data tables
ROW_TYPE("type", "type"),
DATA_KEY("key", "datakey", b -> bytes((Bytes) b)),
DATA_VALUE("value", "value", b -> bytes((byte[]) b)),
OFFSET("offset", "offset"),
EPOCH("epoch", "epoch"),
STREAM_TIME("streamTime", "streamtime"),
WINDOW_START("windowStart", "windowstart", ts -> timestamp((long) ts)),
TIMESTAMP("ts", "ts", ts -> timestamp((long) ts));
static final Bytes METADATA_KEY
= Bytes.wrap("_metadata".getBytes(StandardCharsets.UTF_8));
static final long METADATA_TS = -1L;
private final String column;
private final String bind;
private final Function