Skip to content

Commit

Permalink
Handle some PolyBinary cases in Cottontail
Browse files Browse the repository at this point in the history
  • Loading branch information
gartens committed May 3, 2024
1 parent b52bc3e commit 7b7634c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.BitSet;
import java.util.Objects;
import lombok.Value;
import org.apache.calcite.avatica.util.Base64;
import org.apache.calcite.avatica.util.ByteString;
import org.apache.calcite.linq4j.tree.Expression;
import org.apache.calcite.linq4j.tree.Expressions;
Expand Down Expand Up @@ -125,6 +126,10 @@ public String toHexString() {
return out;
}

public String as64String() {
return Base64.encodeBytes( value );
}


@Override
public @NotNull PolyString asString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,21 @@ public static CottontailGrpc.Literal toData( PolyValue value, PolyType actualTyp
}
break;
}
case VARBINARY:
if ( value.isBinary() ) {
return builder.setStringData( value.asBinary().as64String() ).build();
}
break;
case FILE:
case IMAGE:
case AUDIO:
case VIDEO:
if ( value.isBlob() ) {
return builder.setStringData( value.asBlob().as64String() ).build();
} else if ( value.isBinary() ) {
return builder.setStringData( value.asBinary().as64String() ).build();
}
break;
}

log.error( "Conversion not possible! value: {}, type: {}", value.getClass().getCanonicalName(), actualType );
Expand Down Expand Up @@ -515,4 +523,4 @@ private static Expression knnCallDistance( RexNode node, ParameterExpression dyn
throw new GenericRuntimeException( "Argument is neither an array call nor a dynamic parameter" );
}

}
}

0 comments on commit 7b7634c

Please sign in to comment.