Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urlencode nested serializer temp file names so they dont explode stuff #15068

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public int lookupString(@Nullable String value)
// for strings because of this. if other type dictionary writers could potentially use multiple internal files
// in the future, we should transition them to using this approach as well (or build a combination smoosher and
// mapper so that we can have a mutable smoosh)
File stringSmoosh = FileUtils.createTempDir(name + "__stringTempSmoosh");
File stringSmoosh = FileUtils.createTempDir(StringUtils.urlEncode(name) + "__stringTempSmoosh");
final String fileName = NestedCommonFormatColumnSerializer.getInternalFileName(
name,
NestedCommonFormatColumnSerializer.STRING_DICTIONARY_FILE_NAME
Expand Down Expand Up @@ -135,7 +135,9 @@ public int lookupString(@Nullable String value)
public int lookupLong(@Nullable Long value)
{
if (longDictionary == null) {
Path longFile = makeTempFile(name + NestedCommonFormatColumnSerializer.LONG_DICTIONARY_FILE_NAME);
final Path longFile = makeTempFile(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: seems like makeTempFile is a class method; it could be possible to push the StringUtils.urlEncode(name) into that; so that call sites could look like:

makeTempFile(NestedCommonFormatColumnSerializer.LONG_DICTIONARY_FILE_NAME)

the method already appends .tmp ; so it could pick up this as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of that too but if we are doing that, we should change the name of the method so that encoding is not done twice?

StringUtils.urlEncode(name) + NestedCommonFormatColumnSerializer.LONG_DICTIONARY_FILE_NAME
);
longBuffer = mapWriter(longFile, longDictionaryWriter);
longDictionary = FixedIndexed.read(longBuffer, TypeStrategies.LONG, ByteOrder.nativeOrder(), Long.BYTES).get();
// reset position
Expand All @@ -151,7 +153,9 @@ public int lookupLong(@Nullable Long value)
public int lookupDouble(@Nullable Double value)
{
if (doubleDictionary == null) {
Path doubleFile = makeTempFile(name + NestedCommonFormatColumnSerializer.DOUBLE_DICTIONARY_FILE_NAME);
final Path doubleFile = makeTempFile(
StringUtils.urlEncode(name) + NestedCommonFormatColumnSerializer.DOUBLE_DICTIONARY_FILE_NAME
);
doubleBuffer = mapWriter(doubleFile, doubleDictionaryWriter);
doubleDictionary = FixedIndexed.read(doubleBuffer, TypeStrategies.DOUBLE, ByteOrder.nativeOrder(), Double.BYTES).get();
// reset position
Expand All @@ -167,7 +171,9 @@ public int lookupDouble(@Nullable Double value)
public int lookupArray(@Nullable int[] value)
{
if (arrayDictionary == null) {
Path arrayFile = makeTempFile(name + NestedCommonFormatColumnSerializer.ARRAY_DICTIONARY_FILE_NAME);
final Path arrayFile = makeTempFile(
StringUtils.urlEncode(name) + NestedCommonFormatColumnSerializer.ARRAY_DICTIONARY_FILE_NAME
);
arrayBuffer = mapWriter(arrayFile, arrayDictionaryWriter);
arrayDictionary = FrontCodedIntArrayIndexed.read(arrayBuffer, ByteOrder.nativeOrder()).get();
// reset position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static void staticSetup()
@Before
public void setup() throws IOException
{
final String fileNameBase = "test";
final String fileNameBase = "test/column";
final String arrayFileNameBase = "array";
fileMapper = smooshify(fileNameBase, tempFolder.newFolder(), data);
baseBuffer = fileMapper.mapFile(fileNameBase);
Expand Down