Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packaging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@
<artifactId>hive-standalone-metastore-rest-catalog</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-standalone-metastore-search</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs-client</artifactId>
Expand Down
219 changes: 219 additions & 0 deletions standalone-metastore/metastore-search/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hive-standalone-metastore</artifactId>
<groupId>org.apache.hive</groupId>
<version>4.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hive-standalone-metastore-search</artifactId>
<name>Hive Metastore Search</name>
<properties>
<standalone.metastore.path.to.root>..</standalone.metastore.path.to.root>
<langchain4j.version>1.16.2</langchain4j.version>
<langchain4j.embeddings.version>1.16.1-beta26</langchain4j.embeddings.version>
<lucene.version>10.4.0</lucene.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-standalone-metastore-server</artifactId>
<version>${hive.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-reload4j</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.reload4j</groupId>
<artifactId>reload4j</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs-client</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-reload4j</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.reload4j</groupId>
<artifactId>reload4j</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j</artifactId>
<version>${langchain4j.version}</version>
</dependency>
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-embeddings-bge-small-en-v15</artifactId>
<version>${langchain4j.embeddings.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analysis-common</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-standalone-metastore-server</artifactId>
<version>${hive.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hive.hcatalog</groupId>
<artifactId>hive-hcatalog-server-extensions</artifactId>
<version>${hive.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>setup-test-dirs</id>
<phase>process-test-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete dir="${test.tmp.dir}"/>
<delete dir="${test.warehouse.external.dir}"/>
<delete dir="${test.warehouse.dir}"/>
<mkdir dir="${test.tmp.dir}"/>
<mkdir dir="${test.warehouse.dir}"/>
<mkdir dir="${test.warehouse.external.dir}"/>
</target>
</configuration>
</execution>
<execution>
<id>setup-metastore-scripts</id>
<phase>process-test-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<mkdir dir="${test.tmp.dir}/scripts/metastore/upgrade"/>
<copy todir="${test.tmp.dir}/scripts/metastore/upgrade">
<fileset dir="${basedir}/../metastore-server/src/main/sql/"/>
</copy>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<reuseForks>false</reuseForks>
<argLine>-Xmx2048m --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED --add-opens java.base/java.util.regex=ALL-UNNAMED --add-opens java.sql/java.sql=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED</argLine>
<systemPropertyVariables>
<build.dir>${project.build.directory}</build.dir>
<datanucleus.schema.autoCreateAll>true</datanucleus.schema.autoCreateAll>
<derby.version>${derby.version}</derby.version>
<derby.stream.error.file>${test.tmp.dir}/derby.log</derby.stream.error.file>
<java.io.tmpdir>${test.tmp.dir}</java.io.tmpdir>
<javax.jdo.option.ConnectionURL>jdbc:derby:memory:${test.tmp.dir}/junit_metastore_db;create=true</javax.jdo.option.ConnectionURL>
<metastore.schema.verification>false</metastore.schema.verification>
<test.tmp.dir>${test.tmp.dir}</test.tmp.dir>
<metastore.warehouse.dir>${test.warehouse.scheme}${test.warehouse.dir}</metastore.warehouse.dir>
<hive.metastore.warehouse.external.dir>${test.warehouse.scheme}${test.warehouse.external.dir}</hive.metastore.warehouse.external.dir>
</systemPropertyVariables>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.testOutputDirectory}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.hive.search.config;

import java.time.Duration;

import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;

public record IndexConfig(Configuration configuration) {
public static final String INDEX_RAM_SIZE = "metastore.index.write.ram.size";
public static final int INDEX_RAM_SIZE_DEFAULT = 128 * 1024 * 1024;

public static final String FLUSH_INTERVAL_MS = "metastore.index.flush.interval.ms";
public static final long FLUSH_INTERVAL_MS_DEFAULT = 60 * 1000L;

public static final String INDEX_NAME = "metastore.index.name";
public static final String INDEX_NAME_DEFAULT = "hive_tables";

public static final String POLL_NOTIFICATION_INTERVAL = "metastore.index.poll.notification.ms";
public static final long POLL_NOTIFICATION_INTERVAL_DEFAULT = 1000;

public static final String INDEX_SYNC_INTERVAL = "metastore.index.sync.interval.minutes";
public static final long INDEX_SYNC_INTERVAL_DEFAULT = 360;

/** Force a metadata-only commit when this many events are ahead of the last committed checkpoint. */
public static final String FORCE_FLUSH_EVENT_GAP = "metastore.index.force.flush.event.gap";
public static final long FORCE_FLUSH_EVENT_GAP_DEFAULT = 3000L;

/** Tables per metastore fetch batch during leader bootstrap. */
public static final String BOOTSTRAP_BATCH_SIZE = "metastore.index.bootstrap.batch.size";
public static final int BOOTSTRAP_BATCH_SIZE_DEFAULT = 2000;

/** In-flight document batches between fetch workers and the index writer. */
public static final String BOOTSTRAP_QUEUE_DEPTH = "metastore.index.bootstrap.queue.depth";
public static final int BOOTSTRAP_QUEUE_DEPTH_DEFAULT = 16;

/** Parallel metastore fetch workers during bootstrap. */
public static final String BOOTSTRAP_FETCH_THREADS = "metastore.index.bootstrap.fetch.threads";
public static final int BOOTSTRAP_FETCH_THREADS_DEFAULT = 4;

/** Lucene commits after this many Lucene auto-flushes during incremental indexing. 0 commits immediately. */
public static final String COMMIT_FLUSHES = "metastore.index.commit.flushes";
public static final int COMMIT_FLUSHES_DEFAULT = 3;

/** Progress log interval during bootstrap. */
public static final String BOOTSTRAP_PROGRESS_INTERVAL_MS =
"metastore.index.bootstrap.progress.interval.ms";
public static final long BOOTSTRAP_PROGRESS_INTERVAL_MS_DEFAULT = 30_000L;

/** Max HMS events fetched per poll. */
public static final String EVENT_POLL_MAX = "metastore.index.event.poll.max";
public static final int EVENT_POLL_MAX_DEFAULT = 3000;

/** Consecutive batch failures before falling back to single-event apply. */
public static final String EVENT_BATCH_MAX_FAILURES =
"metastore.index.event.batch.max.failures";
public static final int EVENT_BATCH_MAX_FAILURES_DEFAULT = 3;

/** Extra sleep after a failed batch before the poller retries (ms). */
public static final String EVENT_FAILURE_BACKOFF_MS = "metastore.index.event.failure.backoff.ms";
public static final long EVENT_FAILURE_BACKOFF_MS_DEFAULT = 10_000L;

/** Skip a single poison event during individual fallback (index may diverge for that table). */
public static final String EVENT_SKIP_POISON = "metastore.index.event.skip.poison";
public static final boolean EVENT_SKIP_POISON_DEFAULT = false;

/** Poller sleep after index is marked unhealthy (ms). */
public static final String EVENT_UNHEALTHY_BACKOFF_MS = "metastore.index.event.unhealthy.backoff.ms";
public static final long EVENT_UNHEALTHY_BACKOFF_MS_DEFAULT = 10 * 60 * 1000L;

public int getWriteBufferSize() {
return configuration.getInt(INDEX_RAM_SIZE, INDEX_RAM_SIZE_DEFAULT);
}

public Duration getFlushInterval() {
return Duration.ofMillis(configuration.getLong(FLUSH_INTERVAL_MS, FLUSH_INTERVAL_MS_DEFAULT));
}

public double getWriteBufferSizeMb() {
return getWriteBufferSize() / (1024.0 * 1024.0);
}

public long getPollNotificationInterval() {
return configuration.getLong(POLL_NOTIFICATION_INTERVAL, POLL_NOTIFICATION_INTERVAL_DEFAULT);
}

public long getSyncInterval() {
return configuration.getLong(INDEX_SYNC_INTERVAL, INDEX_SYNC_INTERVAL_DEFAULT) * 60 * 1000;
}

public long getForceFlushEventGap() {
return configuration.getLong(FORCE_FLUSH_EVENT_GAP, FORCE_FLUSH_EVENT_GAP_DEFAULT);
}

public int getBootstrapBatchSize() {
return configuration.getInt(BOOTSTRAP_BATCH_SIZE, BOOTSTRAP_BATCH_SIZE_DEFAULT);
}

public int getBootstrapQueueDepth() {
return configuration.getInt(BOOTSTRAP_QUEUE_DEPTH, BOOTSTRAP_QUEUE_DEPTH_DEFAULT);
}

public int getBootstrapFetchThreads() {
return configuration.getInt(BOOTSTRAP_FETCH_THREADS, BOOTSTRAP_FETCH_THREADS_DEFAULT);
}

public int getCommitFlushes() {
return configuration.getInt(COMMIT_FLUSHES, COMMIT_FLUSHES_DEFAULT);
}

public long getBootstrapProgressIntervalMs() {
return configuration.getLong(BOOTSTRAP_PROGRESS_INTERVAL_MS,
BOOTSTRAP_PROGRESS_INTERVAL_MS_DEFAULT);
}

public int getEventPollMax() {
return configuration.getInt(EVENT_POLL_MAX, EVENT_POLL_MAX_DEFAULT);
}

public int getEventBatchMaxFailures() {
return configuration.getInt(EVENT_BATCH_MAX_FAILURES, EVENT_BATCH_MAX_FAILURES_DEFAULT);
}

public long getEventFailureBackoffMs() {
return configuration.getLong(EVENT_FAILURE_BACKOFF_MS, EVENT_FAILURE_BACKOFF_MS_DEFAULT);
}

public boolean isEventSkipPoison() {
return configuration.getBoolean(EVENT_SKIP_POISON, EVENT_SKIP_POISON_DEFAULT);
}

public long getEventUnhealthyBackoffMs() {
return configuration.getLong(EVENT_UNHEALTHY_BACKOFF_MS, EVENT_UNHEALTHY_BACKOFF_MS_DEFAULT);
}

public String indexName() {
String name = configuration.get(INDEX_NAME);
return StringUtils.isEmpty(name) ? INDEX_NAME_DEFAULT : name;
}
}
Loading
Loading