From c9a6020c2c610de6ec81f902e19ed636fa840ffa Mon Sep 17 00:00:00 2001 From: Haoqiong Bian Date: Mon, 14 Feb 2022 13:41:04 +0100 Subject: [PATCH] finish. --- README.md | 4 ++- .../pixels/common/metadata/domain/Column.java | 4 +++ .../pixels/presto/PixelsTypeManager.java | 26 ++++++++++++++++--- .../presto/impl/PixelsMetadataProxy.java | 5 +++- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7260c5f42..87ad3b460 100644 --- a/README.md +++ b/README.md @@ -75,10 +75,12 @@ To use the columnar cache in Pixels (i.e., pixels-cache), create and mount an in sudo mkdir -p /mnt/ramfs sudo mount -t tmpfs -o size=1g tmpfs /mnt/ramfs ``` +The path `/mnt/ramfs` is determined by `cache.location` and `index.location` in `PIXELS_HOME/pixels.properties`. The `size` parameter of the mount command should be larger than or equal to the sum of `cache.size` and `index.size` in `PIXELS_HOME/pixels.properties`. And it must be smaller than the physical memory size. Also ensure that `cache.enabled` and `cache.read.direct` are set to `true` in `PIXELS_HOME/pixels.properties`. -Set `cache.enabled` to `false` if you don't want to use pixels-cache. +Set `cache.enabled` to `false` if you don't want to use pixels-cache. +But **NOTE** that the path `/mnt/ramfs` must exist even if pixels-cache is disabled, as Pixels checks this path when starts. ### Install MySQL MySQL and etcd are used to store the metadata and states of Pixels. To install MySQL: diff --git a/pixels-common/src/main/java/io/pixelsdb/pixels/common/metadata/domain/Column.java b/pixels-common/src/main/java/io/pixelsdb/pixels/common/metadata/domain/Column.java index b550c1f57..293420df9 100644 --- a/pixels-common/src/main/java/io/pixelsdb/pixels/common/metadata/domain/Column.java +++ b/pixels-common/src/main/java/io/pixelsdb/pixels/common/metadata/domain/Column.java @@ -54,6 +54,10 @@ public void setName(String name) this.name = name; } + /** + * Get the full type's display name, e.g., integer, varchar(10). + * @return + */ public String getType() { return type; diff --git a/pixels-presto/src/main/java/io/pixelsdb/pixels/presto/PixelsTypeManager.java b/pixels-presto/src/main/java/io/pixelsdb/pixels/presto/PixelsTypeManager.java index b04504c28..1d543a530 100644 --- a/pixels-presto/src/main/java/io/pixelsdb/pixels/presto/PixelsTypeManager.java +++ b/pixels-presto/src/main/java/io/pixelsdb/pixels/presto/PixelsTypeManager.java @@ -81,21 +81,41 @@ public static B checkObjectType(A value, Class target, Strin signatureToType = new HashMap<>(); for (Type type : supportedTypes) { - signatureToType.put(type.getDisplayName(), type); + /** + * Issue #163: + * Register the lowercase of the type's display name. + */ + signatureToType.put(type.getDisplayName().toLowerCase(), type); } + /** + * Issue #163: + * Support char(n) using varchar. + */ + signatureToType.put("char", VARCHAR); } private PixelsTypeManager () {} public Type getType(String signature) { - return signatureToType.get(signature); + /** + * Issue #163: + * The signature in signatureToType is the prefix in lowercase of the type's display name. + * Fore example, varchar or char instead of varchar(10) or char(10). Therefore we use the + * lowercase of the prefix of the parameter to do the matching. + */ + int index = signature.indexOf("("); + if (index > 0) + { + signature = signature.substring(0, index); + } + return signatureToType.get(signature.toLowerCase()); } @Override public Type getType(TypeSignature signature) { - return signatureToType.get(signature.toString()); + return getType(signature.toString()); } @Override diff --git a/pixels-presto/src/main/java/io/pixelsdb/pixels/presto/impl/PixelsMetadataProxy.java b/pixels-presto/src/main/java/io/pixelsdb/pixels/presto/impl/PixelsMetadataProxy.java index 10277be00..f4e6a575f 100644 --- a/pixels-presto/src/main/java/io/pixelsdb/pixels/presto/impl/PixelsMetadataProxy.java +++ b/pixels-presto/src/main/java/io/pixelsdb/pixels/presto/impl/PixelsMetadataProxy.java @@ -19,6 +19,7 @@ */ package io.pixelsdb.pixels.presto.impl; +import com.facebook.presto.spi.PrestoException; import com.facebook.presto.spi.type.Type; import com.google.inject.Inject; import io.airlift.log.Logger; @@ -31,6 +32,7 @@ import io.pixelsdb.pixels.common.utils.ConfigFactory; import io.pixelsdb.pixels.presto.PixelsColumnHandle; import io.pixelsdb.pixels.presto.PixelsTypeManager; +import io.pixelsdb.pixels.presto.exception.PixelsErrorCode; import java.util.ArrayList; import java.util.List; @@ -86,7 +88,8 @@ public List getTableColumn(String connectorId, String schema Type columnType = PixelsTypeManager.getColumnType(c); if (columnType == null) { - log.error("columnType is not defined."); + throw new PrestoException(PixelsErrorCode.PIXELS_METASTORE_ERROR, + "columnType '" + c.getType() + "' is not defined."); } String name = c.getName(); PixelsColumnHandle pixelsColumnHandle = new PixelsColumnHandle(connectorId, name, columnType, "", i);