Skip to content

Commit

Permalink
[Issue #163]: fix bounded varchar/char type support. (#165)
Browse files Browse the repository at this point in the history
Modify PixelsTypeManager in pixels-presto to fix this issue.
  • Loading branch information
bianhq authored Feb 14, 2022
1 parent da56b57 commit 443281b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,41 @@ public static <A, B extends A> B checkObjectType(A value, Class<B> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -86,7 +88,8 @@ public List<PixelsColumnHandle> 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);
Expand Down

0 comments on commit 443281b

Please sign in to comment.